I am making a load testing program using K6, JavaScript in which I want to request an API sequentially based on VU id.
For example, let suppose I have 5 different payloads and 5 VU one for each payload.
I want my program to run such as, for the 1st min only VU-1 will get executed requesting continuously with my 1st payload, then for next min, VU-2 will execute and so on till 5th and then again 1st VU will get executed.
Based on the VU Id I will be changing the payload.
I have tried setTimeout() method of JavaScript but not working with k6.
Also I have tried the scenario option from k6 documentation but its running parallelly. here is the code snippet I tried.
export let options = {
scenarios: {
execution: {
scenario1: {
type: "per-vu-iterations",
vus: 1,
iterations: 1,
maxDuration: "15s",
exec: "scenario1",
},
scenario2: {
type: "per-vu-iterations",
vus: 1,
iterations: 1,
maxDuration: "15s",
exec: "scenario2",
},
}
}
}
export function scenario1() {
let res = http.get("https://test.loadimpact.com/");
console.log(__VU);
check(res, {
"is status 200": (r) => r.status === 200
});
};
export function scenario2() {
let res = http.get("https://test.loadimpact.com/");
console.log(__VU);
check(res, {
"is status 200": (r) => r.status === 200
});
};
Is their any method in K6 to achieve this?
question from:
https://stackoverflow.com/questions/65952304/k6-request-an-api-sequentially-based-on-vu-id 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…