Skip to main content
Version: 9.0.0

Multi Operators Manager

A Multi-operators manager is an essential part of the parallel execution. In many cases, the usage of the same operator at the same time for different cases will cause conflicts and error messages in Pega. Now with a Multi-Operator Manager you can create a pool of users and a smart mechanism inside the library will manage users according to their roles. The operators-manager is taking the first free operator with a given role and logs in to Pega (while the test case is executed, the operator is considered as busy). Do not forget to unassign the operator if he is not required anymore, otherwise there won't be free operators for the next test case. For unit testing or API calls to Pega you can use assignOperatorWithoutLocking function that assigns the operator but doesn't block him for the user pool (hence, you don't need to unassign the operator afterwards).

Steps to set up a multi-operator manager

  • create an operator manager instance in the configuration file:
export const operatorsManager = new OperatorsManager();
  • in the configuration file, hooks section, set the operators source (pay attention it must be set only once before test execution started, that is why it is in the beforeAll hook). You can also configure it depending on the environment name, then several user pools should be created and passed depending on environment name:
 hooks: {
beforeAll: (async (runInfo) => {
let name = runInfo.configuration.extra.env.name;
console.log(`Current environment is ${name}`);
await operatorsManager.SetOperatorsSource(getUsersPool(name));
}),
}
  • in the ./src/specs/user-data.ts (or any other file) an export function getUsersPool sets the users according to the environment chosen:
export let users = [];
export function getUsersPool(env: string) {
switch (env) {
case `dev`:
users = dev_users;
break;
case `stage`:
users = staging_users;
break;
default:
users = [
{
id: `operator`,
alt: [{ username: `test.maker`, password: `Rules12345$` }],
},
];
break;
}
return users;
}
  • in the same file you can keep all your user credentials and to group them by their role. For example, you can create a group of users with the manager role or type of access:
const dev_users = [
{
id: `manager`,
alt: [
{ username: `manager1`, password: `Rules21!`},
{ username: `manager2`, password: `Rules22!`},
],
},
];

const staging_users = [
{
id: `manager`,
alt: [
{ username: `manager1`, password: `Rules23!`},
{ username: `manager2`, password: `Rules24!`},
],
},
];


info

Typically, we recommend having for n threads n+1 users.

With the above configuration, you can assign the user by its role before the login action and unassign after it:

let operator = await runInfo.configuration.extra.operatorsManager.assignOperator('manager');

await runInfo.configuration.extra.operatorsManager.unAssignOperator('manager', operator.username);