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.
👉 For these types of tests, please be sure to also read our stress testing checklist
Table of contents
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';
Code language: JavaScript (javascript)
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';
Code language: JavaScript (javascript)
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';
Code language: JavaScript (javascript)
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;
Code language: JavaScript (javascript)
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.