Welcome to the community! Register below to add topics and replies.

Please or Register to create posts and topics.

Example of running different user credentials for different runners

In some cases, when running parallel tests, it's useful to make sure concurrent users are always running with different user credentials. Typically, this is done by setting up separate user roles, such as "admin" and "user," and tying a "scope" and credentials to these roles.

There is a simpler case where no scope is needed. Let's say I want to run n parallel identical workers, and make sure these have different username and password. In this case, I can use the worker number as an index and load credentials dynamically at the beginning of the test.

Start by defining a credentials-file "$project.userList" with different username and passwords, like this.

username	password
Mats	secret1
Wensheng	secret2
James	secret3

You can now dynamically load username / password combinations using a Javascript action in the beginning of a test

$test.worker = $util.getCoopKey();
console.log("BZ-LOG: Worker #" + $test.worker);

$test.username = $project.userList[$test.worker].username;
$test.password = $project.userList[$test.worker].password;

console.log("BZ-LOG: Username is " + $test.username);
console.log("BZ-LOG: Password is " + $test.password);

You can now generate a set of worker URLs and make sure you are using different credentials for the workers i.e.

Worker 0, username=Mats, reserved for IDE
Worker 1, username=Wensheng,
Worker 2, username=James,

Create your account for free!

Prefer a demo instead?