saving session variables from checks to an Array // need help with custom feeder

Hey there,

I have an authentication service, returning auth-tokens for every login session (basically cookies).
I’m trying find a nice solution for gatling to deal with this.

My first approach was to repeat my auth call and save the returned tokens into an array:

`

val SessionIds = new ArrayString
object Auth {
val auth = repeat(10, “n”) {
exec(http(“auth”)
.get(“http://auth..org/login")
.basicAuth("user+${n}@
.org”,“123456”)
.check(jsonPath("$.token").saveAs(“token”))
)
.exec(session => {
println(session(“token”).as[String])
session
})
}

`

The problem I’m facing is, that println prints the same token 10 times. Probably because of some internal concurrent executions?

So, my question is. What is the preferable way to do this?
Is there a better way, using a custom feeder? Any hints on that?

Best,
Tim

got it, it was actually way easier with a feeder:

`

// create a user-id feeder
val users = new ArrayBuffer[Map[String,Int]]
for( i ← 0 to 10){
users += Map(“user” → i)
}
val feeder = users.queue

object Auth {
val auth = feed(feeder)
.exec(http(“auth”)
.get(“http://auth..org/login")
.basicAuth("user+${user}@
.org”,“123456”)
.check(jsonPath("$.token").saveAs(“token”))
)
}

`

basically I’m creating a feeder (a really easy one in my case, since I only need to iterate an integer in my usernames) and then use the session-variable ${name} - created by the feeder - to do my auth.

val feeder = (0 to 10).map(i => “user” → i).toMap

Sorry: (0 to 10).map(i => Map(“user” → i))

thank you for optimizing!
for reference the resulting one-liner:

`

val feeder = (0 to 2000).map(i => Map(“user” → i)).queue

`

Thanks,
Tim