How I can select the index of an array base on the __VU, as far as I can see in the example below the id od the VU is assigned randomly to the fisrt scenario, so that no allows me to select from the array the object from the array
maybe is more clear with the expample:
values.json
[
{ "id": 0 },
{ "id": 1 },
{ "id": 2 },
{ "id": 3 },
{ "id": 4 },
{ "id": 5 },
{ "id": 6 },
{ "id": 7 },
{ "id": 8 },
{ "id": 9 }
]
example.js
const dataInput = JSON.parse(open("../../data/values.json"));
export const options = {
scenarios: {
first: {
executor: "per-vu-iterations",
vus: 1,
iterations: dataInput.length,
exec: "first",
},
second: {
executor: "per-vu-iterations",
vus: dataInput.length,
exec: "second",
startTime: "5s",
},
},
};
export function first() {
console.log("First __VU __ITER: ", __VU, __ITER);
}
export function second(w) {
console.log("Second __VU __ITER: ", __VU, __ITER);
}
result
INFO[0000] First __VU __ITER: 2 0 source=console
INFO[0000] First __VU __ITER: 2 1 source=console
INFO[0000] First __VU __ITER: 2 2 source=console
INFO[0000] First __VU __ITER: 2 3 source=console
INFO[0000] First __VU __ITER: 2 4 source=console
INFO[0000] First __VU __ITER: 2 5 source=console
INFO[0000] First __VU __ITER: 2 6 source=console
INFO[0000] First __VU __ITER: 2 7 source=console
INFO[0000] First __VU __ITER: 2 8 source=console
INFO[0000] First __VU __ITER: 2 9 source=console
INFO[0005] Second __VU __ITER: 5 0 source=console
INFO[0005] Second __VU __ITER: 8 0 source=console
INFO[0005] Second __VU __ITER: 9 0 source=console
INFO[0005] Second __VU __ITER: 1 0 source=console
INFO[0005] Second __VU __ITER: 3 0 source=console
INFO[0005] Second __VU __ITER: 4 0 source=console
INFO[0005] Second __VU __ITER: 11 0 source=console
INFO[0005] Second __VU __ITER: 7 0 source=console
INFO[0005] Second __VU __ITER: 10 0 source=console
INFO[0005] Second __VU __ITER: 6 0 source=console
If I want to select the values form values.json, I’m not able to do it as I can do without using scenarios.
Someone know how I can achive this, basically for the second scenario I want to be able to use only once each object.
Thanks all in advance