How do we code k6 scripts that have dynamic number of stages? Essentially, If in one run I need to have 2 stages with parameters being constant or having arithmetic or geometric progression and in the second run I want to run it for 3/4/5.....n stages.
This is how one defines scenarios/stages in k6:
export let options = {
scenarios: {
stage_1: {
executor: 'constant-arrival-rate',
rate: __ENV.STAGE_1_RPS,
timeUnit: '1s',
startTime: __ENV.STAGE_1_START_TIME,
duration: __ENV.STAGE_1_DUR,
preAllocatedVUs: __ENV.STAGE_1_VUS
},
stage_2: {
executor: 'constant-arrival-rate',
rate: __ENV.STAGE_1_RPS + 100,
timeUnit: '1s',
startTime: __ENV.STAGE_2_START_TIME,
duration: __ENV.STAGE_2_DUR,
preAllocatedVUs: __ENV.STAGE_2_VUS
}
}
Using, the above format if one needs to run for n different number of stages, then n different scripts are needed to be written, which seems to be a good approach.
Have been through the k6 docs, but there doesn't seem to be some feature/parameter that can provide the above functionality : https://k6.io/docs/using-k6/