Hey, I have a question which as far as I see, was already asked long time ago here: Shared state or unique sequential vu index per scenario
But it looks like there’s still no answer) Or maybe I just couldn’t find it.
I need to use data parameterization per scenario. Using VU indexes works fine if working with 1 scenario. But when it comes to several scenarios - I couldn’t find the answer how to do this.
Let’s say I have 4 scenarios. Each scenario uses 25 users. So in the setup() I create arrays of users and share them. It’s not a problem to access the needed array itself. The question is - how do I make each VU working with only 1 user from the shared array? Especially assuming those VU indexes are random and scenario 1 might get VU index 90 etc. So I can’t use VU index to access the array. Some VU index per scenario would work but it looks like there’s no any.
Or maybe there is a way to read some file per scenario and use only 1 line per virtual user inside that scenario? It’s possible in jMeter but I can’t figure out how to do this in K6.
Please help
Hi @eugene_tst,
Welcome back to the community forum 
did you try to use exec.scenario.iterationInTest
index as explained in the Data Parameterization guide?
If it is not enough, can you clarify better your case, please?
1 Like
Hi, @codebien , the scenario.iterationInTest is not what I needed because it’s not connected to the VU itself. I ended up using 2 instances of k6 for what I need…
The case is the following:
First of all, I’m using more than 1 scenario (let’s say, 2 scenarios).
I register users during the setup and put them to arrays so each array is made for it’s own scenario (scenario a1 users might have some own properties).
What I need is being able to work with exact array for exact scenario (array a1 is used in scenario a1 only). As VUs indexes are allocated randomly, I can’t rely on the VU index and use it as an array index. Of course, I could use iteration indexes in some simple cases but in my specific situation this would lead to re-login each user which is absolutely not what I wanted. Having some kind of scenario VU indexes would help me because I need to use each VU with the same app user during the whole run.
Also, being able to modify the shared objects would help here so I could use 1 shared array and set needed properties during the test runtime but it’s not possible, I can only read the shared data from setup and not modify it…