Hi @amosbird
For sure. Based on the docs for how to pass environment variables to a k6 script you can create your script.js
with rate:
${__ENV.K6_RATE}``:
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'constant-arrival-rate',
// Our test should last 30 seconds in total
duration: '30s',
// It should start 30 iterations per `timeUnit`. Note that iterations starting points
// will be evenly spread across the `timeUnit` period.
rate: `${__ENV.K6_RATE}`,
// It should start `rate` iterations per second
timeUnit: '1s',
// It should preallocate 2 VUs before starting the test
preAllocatedVUs: 2,
// It is allowed to spin up to 50 maximum VUs to sustain the defined
// constant arrival rate.
maxVUs: 50,
},
},
};
export default function () {
http.get('https://test.k6.io/contacts.php');
sleep(0.5);
}
And then run k6 run script.js -e K6_RATE=10
, which will pass the value to the scenario.
I hope this helps.
Cheers!