如何在 Gatling 资源方法中的请求之间传递值?
How to pass value between requests in the Gatling resources method?
我有一个脚本,其中有多个请求作为主请求的资源发送。我需要从一个资源请求中提取价值并传递给另一个。由于所有这些请求都是并行执行的,所以我正在寻找一个选项来暂停其中一个请求的执行,直到提取参数。
这是我的部分请求
.exec(http("request_2")
.get(uri1 + "/app/botchat/botchatui.html?locale=en&personaType=1")
.headers(headers_0)
.resources(http("request_3")
.get(uri1 + "/app/pots/images/logo-sm.svg")
.headers(headers_3),
http("request_29")
.post(uri2 + "/bot/directline/tokens/generate")
.headers(headers_29)
.body(RawFileBody("package/website/0029_request.json"))
.check(jsonPath("$.token").saveAs("token")),
http("request_34")
.post(uri2 + "/bot/directline/conversations")
.headers(headers_34)
.header("authorization","Bearer ${token}")
.body(RawFileBody("package/website/0034_request.json")))
所以我需要从 request_29 中提取值并传递给 request_34。
我试过使用会话参数,但没有用。
感谢任何帮助。
那不行。 resources
根据定义是异步的并同时执行,因此您无法保证 request_29 完成并且您可以在 request_34 开始之前捕获您的令牌。
您必须在 request_2 之后按顺序执行 request_34,超出其资源。
我有一个脚本,其中有多个请求作为主请求的资源发送。我需要从一个资源请求中提取价值并传递给另一个。由于所有这些请求都是并行执行的,所以我正在寻找一个选项来暂停其中一个请求的执行,直到提取参数。
这是我的部分请求
.exec(http("request_2")
.get(uri1 + "/app/botchat/botchatui.html?locale=en&personaType=1")
.headers(headers_0)
.resources(http("request_3")
.get(uri1 + "/app/pots/images/logo-sm.svg")
.headers(headers_3),
http("request_29")
.post(uri2 + "/bot/directline/tokens/generate")
.headers(headers_29)
.body(RawFileBody("package/website/0029_request.json"))
.check(jsonPath("$.token").saveAs("token")),
http("request_34")
.post(uri2 + "/bot/directline/conversations")
.headers(headers_34)
.header("authorization","Bearer ${token}")
.body(RawFileBody("package/website/0034_request.json")))
所以我需要从 request_29 中提取值并传递给 request_34。 我试过使用会话参数,但没有用。
感谢任何帮助。
那不行。 resources
根据定义是异步的并同时执行,因此您无法保证 request_29 完成并且您可以在 request_34 开始之前捕获您的令牌。
您必须在 request_2 之后按顺序执行 request_34,超出其资源。