Hello All,
I'm looking for some inputs related to tracking(saving) http call responses
of Gatling virtual user. its straight forward in simple case like below
(session variable "user" contains user details say 1020101 (user-id))
//get user account attributes
def getAttributes : ChainBuilder = {
exec(session =>
session.set("reqUrl",
"https://my-server/getAttributes"+session("user").as[String]
))
.exec(
http("Get Player Attributes")
.post(session => session("reqUrl").as[String])
.header("Content-Type", "application/x-www-form-urlencoded")
.check(status.is(200))
.check(jsonPath("$['player_att']").saveAs("attributes"))
//response is saved in "attributes"
)
}
But my actual need is asking for attributes of a list of users obe by one
and save responses of all of them in proper manner
.exec(myUtils.getListOfUsers(20) //Save 20 users list in "usersList"
session variable
.doIf("${usersList.exists()}") {
foreach("${usersList}", "user") {
exec(getAttributes)
.exec(pause(2 second, 5 seconds))
.exec(session => session.remove("user"))
}
}
I'm not able to differentiate or not finding a better way to save responses
of each request for a user in the list. As you can see all 20 responses
will be saved/updated in the same "user-attributes" session variable. So, i
would like use "user-attributes" to save responses for each user in list
and "user" should be replaced by "1020101-attributes"
//get user account attributes
def getAttributes : ChainBuilder = {
exec(session =>
session.set("reqUrl",
"https://my-server/getAttributes"+session("user").as[String]
))
.exec(
http("Get Player Attributes")
.post(session => session("reqUrl").as[String])
.header("Content-Type", "application/x-www-form-urlencoded")
.check(status.is(200))
.check(jsonPath("$['player_attr']").saveAs("user-attributes"))
)
}
/Mahesh