I have a scenario where each virtual user writes a number of documents to a REST API.
I have the document writes in a loop
val write = repeat(100, “n”) {
exec(http(“Create New Doc”)
.put("/doc${n}")
.headers(headers)
.body(RawFileBody(“create_doc_request.txt”)))
.pause(1)
}
This is working great.
But the document names are the same for all users so there are conflicts in the server.
I’m looking for the simplest way to inject a user specific value into the doc names to avoid the conflicts.
I had seen examples where sessionId or userId were being used, so I tried adding ${userId} to the put method:
val write = repeat(100, “n”) {
exec(http(“Create New Doc”)
.put("/doc${userId}${n}")
.headers(headers)
.body(RawFileBody(“create_doc_request.txt”)))
.pause(1)
}
I looked at the Session class in gatling repo and it looks like there is a userId property, but at runtime the above fails because it can not find attribute ‘userId’
I have printed out the session object, using:
.exec { session =>
println(session)
session
And I can’t see a userId property.
Is there any unique value per user session that is pre-populated that I can use to make the doc names unique in the put method. If yes what is the correct way to access it and add it to the put method()?
Andy