【问题标题】:How to pass value between requests in the Gatling resources method?如何在 Gatling 资源方法中的请求之间传递值?
【发布时间】:2021-05-27 11:29:49
【问题描述】:

我有一个脚本,其中包含多个请求作为主请求的资源发送。我需要从 1 个资源请求中提取价值并传递给另一个。由于所有这些请求都是并行执行的,因此我正在寻找一个选项来暂停其中一个请求的执行,直到提取参数为止。

这是我请求的一部分

.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。 我尝试过使用会话参数,但没有成功。

将不胜感激。

【问题讨论】:

    标签: scala performance-testing gatling scala-gatling


    【解决方案1】:

    那是行不通的。 resources 定义为异步并发执行,因此您无法保证 request_29 完成,您可以在 request_34 开始之前捕获您的令牌。

    您必须在 request_2 之后按顺序执行 request_34,耗尽其资源。

    【讨论】:

    • 谢谢。我已经使用过这种解决方法,但我想也许有一些方法可以管理订单或向资源添加条件。但无论如何,感谢您的澄清。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-10
    • 2012-06-03
    • 1970-01-01
    • 2013-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多