Support & information center

Writing Scripts – Sessions

In many test cases, you may want to run different probes that are logically “linked” to sessions. For example, you may wish that different users connect to different video chat rooms when testing a system.

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


Activate Sessions’ Logic

Things to note when reading the following information;

  • Concurrent probes = the number of browsers/users.
  • Session size = the limit of probes per room.
  • Number of sessions = the number of rooms.

To activate the sessions’ logic, you must use the ‘Session size’ parameter in the test script editor. The logic will be enabled if the value is set to two or higher. The number of sessions is then generated by dividing the number set for concurrent probes by the session size.

Example: If the number of concurrent probes is set to 10 and the session size is set to 2, it will create 5 sessions.

Figure: Session Configuration

You can use two powerful tools when using sessions in testRTC:

  1. Synchronization: You can synchronize between probes within the same sessions, having a probe wait on actions taken by other probes by using the .rtcWaitForSessionValue().
  2. Variables: New environment variables will be created and managed for you by the testRTC manager so you can use them in the test script.

  • 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 = "https://service.com/" + sessionName;

Introduction to Handling Sessions:

The following videos give an introduction to the sessions’ logic and how it can be used.

Part 1
Part 2

Code Sample: Multiple rooms with 2 probes in each

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);
  }

Was this article helpful?

Related Articles