Dynamic injection profile only injecting one user

I’m trying to replicate some production issues and want to recreate the arrivals of users in a simulation

I have a list of intervals between each arrival from production logs, and I want to inject a user, then nothingFor the interval, then inject the next user etc

I have the intervals in

var arrivalIntervals: Seq[FiniteDuration]

and in setUp I want to do

arrivalIntervals.flatMap(interval =>List(nothingFor(interval),atOnceUsers(1)))

but this is results in just one user being injected despite there being many entries in arrivalIntervals. No errors are displayed

When I prtinln the the arrivalIntervals.flatMap… function the log has

`
List(NothingForOpenInjection(0 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1), NothingForOpenInjection(60 seconds), AtOnceOpenInjection(1))

`

If I cut and paste this into the setup() block in place of my flatMap function, it works as expected!

Having played further with this, it seems that I can’t set variables in the ‘before’ block and have them impact my defined ‘setUp’ block.

I’m reading the intervals in from a file and was hoping to do this in ‘before’ and then use the list of intervals in ‘setUp’. But when I do this, ‘setUp’ is picking up the value of arrivalIntervals when it was defined and not using the value that gets set in the ‘before’ block.

I can do everything in the setUp block - open the file, read into a list, flatmap to generate the injection steps, but this feels really messy and I can’t do things like close the file.

Shouldn’t the setUp block be able to pick up values set by the before block?