[英]How to call resource request in a foreach loop in Gatling?
As I read right from the Gatling documentation, foreach
loop expects ChainBuilder
as an executable expression.正如我从 Gatling 文档中读到的那样,
foreach
循环期望ChainBuilder
作为一个可执行表达式。
foreach(sequence, elementName){chain} The chain is repeated for every element in the sequence and the current element is stored in the Session under the elementName key
foreach(sequence, elementName){chain} 对序列中的每个元素都重复该链,当前元素存储在 Session 中 elementName 键下
However, if I want to use it inside resource
method, it expects HttpRequestBuilder
s.但是,如果我想在
resource
方法中使用它,它需要HttpRequestBuilder
s。 Here's my usecase:这是我的用例:
.exec(
http("Some name.")
.get("/api/call1?viewType=REGULAR")
.check(
jsonPath("$..reviewers[*]").ofType[Seq[Any]].saveAs("reviewers")
)
.resources(
foreach(session => session("reviewers").as[Seq[Any]], "reviewer") {
http("Request resource.")
.get("/api/users/${reviewer}/photo")
.headers(resourceRequestHeaders)
}
)
)
That's not possible as of Gatling 3.3 (and upcoming 3.4).从 Gatling 3.3(和即将推出的 3.4)开始,这是不可能的。 Number of requests in the
resources
can only be static. resources
的请求数只能是静态的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.