There are two approaches the "old" and the "new" (from v0.27.0) onward.
The old approach is to have a default function that chooses to do one or the other on some condition, for example, each third VU iteration is unsuccessful, the others are successfule ones:
export default function() {
if (__ITER % 3 == 2) {
call_to_unsuccessful_login();
} else {
call_to_successful_login();
}
}
In the above example, you obviously need to define the two functions either in the same script or import them from another
After v0.27.0 and the new execution model, you have multiple scenarios using different executors each execution a different "default" function.
So in this case instead of having one default function which chooses, we can configure different execution plans for the successful and unsuccessful logins and directly call the functions that do them.
export let options = {
"scenarios": {
"successful": {
"executor": "constant-vus".
"vus": 2,
"duration": 1m,
"exec": "call_to_successful_login"
},
"unsuccessful": {
"executor": "constant-vus".
"vus": 1,
"duration": 1m,
"exec": "call_to_unsuccessful_login"
}
}
}
In this case both call... functions need to also be exported in the main script.
You can read more on how to configure scenarios and their different options in the documentation.