Decrementing a counter after an injection event

Hello,

I have a scenario where a set of users gets in injected at the beginning, then they do an action for some time before stopping, waiting for a while, and then repeating the action n more times.

However, I would like to be able to inject new users in between action trials.

So, for example:

`
N = Total number of actions
A = Action

for (i ← N) {
inject users
do A
wait
}
`

However, I’m not sure how to do this in Gatling. This is what I have so far:

`
private val globalUsers = new AtomicInteger(1)

exec(_.set("_id", globalUsers.getAndIncrement))
.repeat(N) {
pause(wait)
.exec(A)
.exec(rendezVous(globalUsers.get))
}

`

with a splitUsers as the injection step. However, this doesn’t do what I need it to do since every new set of user that gets injected will repeat the operation N times. I need each set of users to repeat N-M (where M = 1,2,3…N).

So in theory, the whole simulation should ONLY repeat do A N times for ALL users, regardless of how many users are added. This is essentially trying to simulate a video live stream, where users can come in at any point but the number of operations on it doesn’t change.

I’m was thinking of maybe using an AtomicInteger that changes per injection step, but there doesn’t seem to be a way to hook into the injections that way. Any ideas?

Thanks,
~Pedro