Knowledge Base

  1. Home
  2. Knowledge Base
  3. General
  4. Getting Started
  5. Writing Scripts – Sessions
Writing Scripts – Sessions

In many test cases, you may want to run different agents 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 agents to multiple sessions and, in addition, it is possible to define different logic or role for every agent 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 agents divided to the number of agents in a session.

For example, if the number of concurrent agents 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 the expression “#session:X” in the test’s ‘run options’ field. If the sessions’ logic is active, 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 agent 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;

Handling sessions intro video – part 1 

Handling sessions intro video – part 2

The following code sample creates multiple rooms with 2 agents 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 agentType = Number(process.env.RTC_IN_SESSION_ID); 

client
  .url(process.env.SERVICE_URL)
  .waitForElementVisible('body', 1000)
  
  if (agentType === 0) {
    // 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 agents some time to run, so we can collect QoS information
      client.pause(10000);
  }

 

 

 

Was this article helpful?

Related Articles

Leave a Reply 0 comments

Leave a Reply: