I'm trying to save some seq in static variable and then make http get for each value of the seq:
.exec { session =>
residents = session("residents").as[String]
.split(",").toSeq
.map(f => f.replaceAll("\"", ""))
session
}
.foreach(residents, "resident") {
exec(http("resident").get("#{resident}"))
}
Each element of seq is http url.
Is it possible to send http requests dynamically in Gatling depends on count of seq elements? How can I do this beacuse this code doesn't work as I expect.
That's not how Gatling works. Your residents mutable reference is:
foreach
actionYou've pulled residents
from the current user's Session
, you must stay in this scope:
.exec { session =>
val residentsSeq = session("residents").as[String]
.split(",").toSeq
.map(f => f.replaceAll("\"", ""))
// replace the original "residents" with a Seq
session.set("residents", residentsSeq)
}
// basically equivalent to
// foreach(session => session("residents").as[Seq[String]], "resident")
.foreach("#{residents}", "resident") {
exec(http("resident").get("#{resident}"))
}