Support & information center

Writing Scripts – Sessions

In many test cases, you may want to run different testRTC probes that are logically “linked” to sessions. For example, you may want that different users will connect to different video chat rooms in the tested system.

testRTC supports the distribution of its probes to multiple sessions and, in addition, it is possible to define different logic or role for every probe in the session.

The size of the session is defined as part of the test configuration and the number of sessions in a test is defined by the test’s configured total number of concurrent probes divided to the number of probes in a session.

For example, if the number of concurrent probes is 10, and the size of a session is 2 – 5 sessions will be created.

In order to activate the sessions’ logic, you should use Session Size parameter in the test script editor:

If the Session size value is 2 or higher, then the sessions’ logic will be enabled. New environment variables will be created and managed for you by the testRTC manager, so you can use them in the test script.

The sessions’ logic related environment variables are:

  • RTC_SESSION_IDX – the numeric index of this session from total number of sessions in the test (starts with 1)
  • RTC_SESSION_NAME – the session unique name for the test. The session name includes the session’s (numeric) index of this session from total number of sessions in the test (starts with 1). The session name format is [Test random name]-“room”[RTC_SESSION_IDX]
  • RTC_IN_SESSION_ID – the (numeric) index of this probe in the specific session (starts with 1)

It is possible to use these values in different locations in the script. For example, the following code sample demonstrate how to generate dynamic rooms’ URLs based on the session unique name:

var sessionName = process.env.RTC_SESSION_NAME; var roomUrl = "" + sessionName;
Code language: JavaScript (javascript)

Handling sessions intro video – part 1 

Handling sessions intro video – part 2

The following code sample creates multiple rooms with 2 probes in a room, every user will run a different logic. This approach can be used, for example, to test a service that is based on calling action. In this example, the first user in every room will be the caller and the second user will be the callee.

var probeType = Number(process.env.RTC_IN_SESSION_ID); client .url(process.env.RTC_SERVICE_URL) .waitForElementVisible('body', 1000) if (probeType === 1) { // The caller client // Sign-in .setValue('#user', 'user1') .setValue('#password', ['pass1', client.Keys.ENTER]) // Call .click('#call') ... } else { // The callee client // Sign-in .setValue('#user', 'user2') .setValue('#password', ['pass2', client.Keys.ENTER]) // Wait for the call ... }); // Give both probes some time to run, so we can collect QoS information client.pause(10000); }
Code language: PHP (php)

Was this article helpful?

Related Articles