I have a k6 load test script that has multiple scenarios. One scenario needs parameterized unique data to be used. To simpify, one scenario simulates load by (anonymous) viewers of the data while another scenario simulates upserting data by logged in users.
I have an issue in properly fetching parameterized data from json for the logged in user scenario. If I only run this scenario, everything works fine, but once the viewing scenario is added, the indexing fails.
My parameterized data is like
{
ddd: [
{a: 1, b: 2},
{a: 3, b: 4}
]
}
And in the script I access this first with a SharedArray in the init phase as
const ddd = new SharedArray(
'ddd',
() => JSON.parse(open('./data.json')).ddd
);
and later in the test functions as
const d = ddd[vu.idInTest - 1];
After I’ve added second scenario, the indexing gets mixed and the second scenario picks up the data. I guess this makes sense, since the VU IDs are shared between scenarios.
I’ve tried scenario.iterationInTest
to access the data, and even added an empty list to data file for this, but still it’s mixed.
How can I have separated data per scenario without them getting mixed?