Hello @eyeveebe Thanks for the help above
So i followed all those steps:
1 - I used sharedArray to import data from json file where i had my username and password
2 - I used setup() where i defined my http request which has username and password as ID and password
this were my test users
{
"users": [
{ "username": "testuser1907202104@wtr-test.net", "password": "test1234" },
{ "username": "foo.aws1665706462247@email.com", "password": "test1234" }
]
}
Now i import this file in my js file using
const data = new SharedArray('some data name', function () {
return JSON.parse(open('./checkdata.json')).users;
});
I defined :
export const options = {
scenarios: {
login: {
executor: 'per-vu-iterations',
vus: data.length,
maxDuration: '1h30m',
},
},
};
export function setup() {
const importData = data[vu.idInTest - 1];
const postUrl='https://apie-eu-west-1-qa.ecom.*******.com/authentication-qa/v4/authentication/token'
const payload= JSON.stringify({
username : importData.username,
password :importData.password,
clientId :'IOS_APP',
});
const params= {
headers:{
'Content-Type':'application/json',
},
};
const res=http.post(postUrl,payload,params);
const body = res.json();
const token = body.tokenResponse.accessToken;
return token;
}
SO i am expecting this command to export token for me which i will use in another HTTP call
Also the request am sending in setup() , i am expecting unique login for each virtual user based on number of users in json file
Now ,
export default function (value) {
console.log(value);
}
I was trying to print the accessToken which i return from setup() but this is giving me an error
ERRO[0003] TypeError: Cannot read property 'username' of undefined
at setup (file:///Users//loaddemo/setupTearParam.js:28:31(15))
at native hint="script exception"
Now if i use the same logic directly inside default function , i am getting the expected refresh token , but then it is not good and looks complicated.
So can u help me on this.
Also let me know if there is a way to connect with you on same for discussion. thanks in advance
Also to mention inside function setup() , if i pass username and password value directly rather than sharedArray , i am getting the response but not with sharedArray
Also You mentioned to use setup and Tear phase but will setup Phase help me to have unique access Token for each Virtual user? I read the document and it seems like it will be one time process and same accessToken can be shared with all virtual Users but my requirement is if i am having 2 username then 2 virtual user should have unique accessToken rather than same for all virtual user