Skip to main content

How to login multiple test user accounts for large stress tests?

When running a large stress test you need a lot of machines and mock-users. In many cases, you can’t have guest access and need the users to be able to login and identify themselves in your service. Here are two simple ways (and a suggestion) to address this using testRTC.

Note: For these types of tests, please be sure to also read our stress testing checklist

1. Programmatically

When there’s an easy way to correlate a user to a counter, then you can create the username programmatically.

Here are three examples for this approach.
  1. Each user that joins needs to login:
    var count = Number(process.env.RTC_AGENT_NUM);
    var username = 'testrtc' + count + '@example.com';
    
    var password = 'password';
  2. When you need a single logged in user in each session/room since the rest of the users are going to be anonymous guests:
    var sessionId = Number(process.env.RTC_SESSION_IDX);
    var username = 'testrtc' + sessionId + '@example.com';
    
    var password = 'password';
  3. When you have a different users logging in, in this example, a doctor and a patient. It also assumes the same password for everyone and two probes per session:
    var probeType = Number(process.env.RTC_IN_SESSION_ID);
    var sessionId = Number(process.env.RTC_SESSION_IDX);
    
    if (probeType === 1) {
        var username = 'doctor' + sessionId + '@example.com';
    } else {
        var username = 'patient' + sessionId + '@example.com';
    }
    
    var password = 'password';

2. Use an array

When you have seemingly “random” usernames or passwords that you need to have logging in, then an array would work better.
var users = [];
users[0] = {username: 'john', pwd: 'password'};
users[1] = {username: 'doe', pwd: '123456'};

var count = Number(process.env.RTC_AGENT_NUM);
username = users[count].username;
password = users[count].pwd;

Another suggestion here would be to place this array in the Assets folder so that you can reuse them across tests.

Suggestion: Automate user creation

On your end, make sure you have an easy way in your service to automatically create a batch of test users. That way, when you’ll need to test a large number of users it will be easy to create them on your end.

Was this article helpful?

0 out of 0 found this helpful