It doesn’t appear to be possible, however, to be able to configure the ramping-arrival-state
executor with the --stage
parameter from the CLI. I used the guidance here to create a possibleScenarios
containing both constant-vus
executor and ramping-arrival-rate
executor. When I use --env
and the “filter” approach here to select the ramping arrival executor, but specify --stage
, it only does constant VU execution.
Any suggestion on how to enable my scenario? E.g. being able to select between constant-vus
and ramping-arrival-rate
executor and customize the stages for both?
E.g. something like k6 run --stage "1m:1000,2m:2000" --env SCENARIOS=ramp_up script.js
where script.js
looks like this:
import http from 'k6/http';
import { check } from "k6";
import { sleep } from "k6";
// stage configuration should be set at command line
const possibleScenarios = {
constant_vus: {
executor: 'constant-vus'
},
arrival_rate: {
executor: 'constant-arrival-rate',
rate: 5000,
timeUnit: '1s',
duration: '10m',
preAllocatedVUs: 6000,
maxVUs: 10000,
},
ramp_up: {
executor: 'ramping-arrival-rate',
startRate: 0,
timeUnit: '1s',
preAllocatedVUs: 6000,
maxVUs: 10000,
stages: [
{ target: 5000, duration: '5m' },
{ target: 5000, duration: '5m' },
],
},
};
let enabledScenarios = {};
__ENV.SCENARIOS.split(',').forEach(scenario => enabledScenarios[scenario] = possibleScenarios[scenario]);
export let options = {
scenarios: enabledScenarios,
};
export default function () {
...
EDIT:
Looks like this works - but curious about correctness?
k6 run script.js --env SCENARIOS=ramp_up --env STAGES='[ { "target": 1000, "duration": "30s" } ]'
for
import http from 'k6/http';
import { check } from "k6";
import { sleep } from "k6";
// stage configuration should be set at command line
let inputStages = JSON.parse(__ENV.STAGES);
const possibleScenarios = {
constant_vus: {
executor: 'constant-vus'
},
arrival_rate: {
executor: 'constant-arrival-rate',
rate: 5000,
timeUnit: '1s',
duration: '10m',
preAllocatedVUs: 6000,
maxVUs: 10000,
},
ramp_up: {
executor: 'ramping-arrival-rate',
startRate: 0,
timeUnit: '1s',
preAllocatedVUs: 6000,
maxVUs: 10000,
stages: inputStages,
},
};
let enabledScenarios = {};
__ENV.SCENARIOS.split(',').forEach(scenario => enabledScenarios[scenario] = possibleScenarios[scenario]);
export let options = {
scenarios: enabledScenarios,
};
export default function () {
...
Thanks!