Is there anyway we can share the token for multiple VUs, iterations. For my case. I just want to invoke 1 time to get token dynamically and can reuse the same token for multiple VUs and iterations.
let token;
export default function testPost () {
group('GET TOKEN', function(){
token = getCredentials();//group to get token
})
group('MY_TESTING_URL', function(){
if(token){
const res = http.get("https://loadimpact.com/" + token);
}
});
group('TESTING_URL2', function(){
if(token){
const res = http.get("https://loadimpact.com/" + token);
}
});
}
Currently, i explicitly add null check to the token to avoid it being invoked multiple times. (this is not a good solution as there are times that it got executed multiple times).
let token;
export default function testPost () {
if(!token){ // or while(true) then break if found token
group(âGET TOKENâ, function() {
token = getCredentials(); // group to get token
})
}
group(âMY_TESTING_URLâ, function(){
if(token){
const res = http.get(âhttps://loadimpact.com/â + token);
}
});
group(âTESTING_URL2â, function(){
if(token){
const res = http.get(âhttps://loadimpact.com/â + token);
}
});
}