I am iterating over the same post statement and would like to save each response somehow in a list. Is this possible?
From the reference it only looks like you can save this as a string? And it looks like if I try to do this multiple times it does not save anything?
https://gatling.io/docs/gatling/reference/current/http/check/#saving
Thanks!
Tom
Hi!
it looks like if I try to do this multiple times it does not save anything?
saveAs
should save your last result.
Are you sure that your last result is not empty?
would like to save each response somehow in a list
My approach is:
- to create a session variable (
acc
) with an empty list
- save the current result in another variable (
tmp
)
- make a step to add the second variable to the first one
Something like:
.exec(session => session.set("acc", session("acc").as[List[String]] :+ session("tmp").as[String])
(warning: not tested)
I hope that helps!
Cheers!
Hmm ya that doesn’t seem to be working. But I’m not sure I initiated the list correctly? Is this how you would to create a session variable ( resourceUidList ) with an empty list (couldn’t find anything in the doc about this)?
.exec(session => session.set(“resourceUidList”, {}))
If that is correct… it doesnt seem to work when I try to add to it like so
exec(session => session.set(“resourceUidList”, session(“resourceUidList”).as[List[String]] :+ session(“resourceUid”).as[String]))
the session var is empty
resourceUidList → ()
What I would like to do is take this list and iterate each value to a PUT request.
Another way I could do that is I add all the resourceIds to a local array variable (not is session)
Then I can iterate over using repeat
repeat(times, counterName) {
myChain
}
according to the docs times can be an Int,
so my code looks like this
.repeat(numberOfRulesets, “counter”) {
TestUtil.putRuleset("${rulesetId}", rulesetFilePath, “${counter}”).pause(2) // This is my PUT request
}
However it does not seem like this counter is working? Not sure what I am doing wrong but it seems unable to get that value to index on my array.
please let me know if you see anything incorrect about either option thanks!?
Curly braces are only empty block in Scala.
Try with Nil or List() to initialize it
hmm not sure that is going to work :(. Not sure what I am missing this should be pretty simple… I posted another question as a workaround