在我的 Gatling 场景中,一个值存储在用户的会话中。稍后在同一场景中,调用 feed 并将其传递给自定义 feeder。自定义馈线需要使用会话中存储的值生成其下一个值。
val MyScenario = scenario("ScenerioName")
.repeat(10, "repetition") {
exitBlockOnFail {
group("WorkflowGroupName") {
exec(session => {
// SETTING A VALUE INTO THE USER'S SESSION
session.set("sessionVariable", 99) // value that is stored changes for every run of the workflow (99 just for example purposes)
})
// CUSTOM FEEDER THAT GENERATES ITS NEXT VALUE USING THE SESSION VARIABLE 'sessionVariable' STORED ABOVE
.feed(myFeeder)
.group("RequestGroup1") {
exec(httpPost1)
}
}
}
}
val myFeeder = Iterator.continually(Map("jsonFileValue" -> {
// WANT TO RETRIEVE VALUE OF 'sessionVariable' STORED IN THE SESSION
val returnValue = /* logic that generates its value based on value of 'sessionVariable' retrieved */
returnValue
}
))
val httpPost1 = http("Request1")
.post("http://IPAddress/service.svc")
.headers(httpHeaders)
.body(ELFileBody("MyJsonFile.json"))
.check(status.is(200))
val httpHeaders = Map(
"Content-Type" -> "application/json; charset=UTF-8",
"X-Pod" -> ""
)
如何将此存储的会话值传递给馈线或让馈线从会话中检索此值?