Hi @rgordill,
Is there any way to get the VUs that are supposed to run on each replica (Total VUs/replicas)
Could you please clarify, where do you want to get them? In script?
Now that I look at it, it seems there were two examples in this thread actually…
Just in case, I’d like to clarify this part:
Regarding your example, it works because parallelism is 1
Not exactly. In this case, there will be a difference in behaviour, depending on whether one uses .js or .tar.
Assuming I have a test.js
with the following options:
const VUS = __ENV.TEST_VUS || 10000;
export const options = {
vus: VUS,
duration: '300s',
setupTimeout: '600s'
};
- If ConfigMap has
test.js
and TestRun is:
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: k6-sample
spec:
parallelism: 2
script:
configMap:
name: "env-test"
file: "env-test.js"
runner:
env:
- name: TEST_VUS
value: "42"
Then there will be 42 VUs in total, equally split between 2 runners. (This can be confirmed with execution API)
- If ConfigMap has
archive.tar
which was created with the following command:
TEST_VUS=4 k6 archive --include-system-env-vars test.js
And TestRun is:
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: k6-sample
spec:
parallelism: 2
script:
configMap:
name: "env-test"
file: "archive.tar"
runner:
env:
- name: TEST_VUS
value: "42"
Then there will be 4 VUs in total, split between 2 runners, and at the same time TEST_VUS
env variable inside the script will be equal to 42.
- If ConfigMap has
archive.tar
which was created with the following command:
TEST_VUS=4 k6 archive test.js
And the same TestRun as in 2) case, then there will be 10000 VUs in total, split between 2 runners. And TEST_VUS
inside the script will be 42 again.
This is not fully k6-operator defined behaviour: the operator only passes the env vars to the pods. But if one uses k6 archive
to create a script, the VUs will be defined at that step. This diff between configuration for k6 archive
and k6 run
is described in the docs here and here.
Let me know if that helps or if additional info is needed!