【问题标题】:How to make nested request call in gatling scala如何在 gatling scala 中进行嵌套请求调用
【发布时间】:2015-01-24 09:13:21
【问题描述】:

我能够在 2 个级别调用嵌套请求,但在第三个级别它不执行,所以我做对与否,如果不是基于响应执行嵌套请求的正确方法是什么

这是我使用的代码

import scala.concurrent.duration._
import java.net.{URLDecoder, URLEncoder}
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class NestedRequestResoponse extends Simulation {
val scn = scenario("NestedRequestResoponse ")
.exec(http("request_2")
            .post("https://myurl:443/autho/login/login.html""")
            .formParam("""userid""", """userName""")
            .formParam("""password""", """password""")
            .formParam("""target""", """""")
            .formParam("""smauthreason""", """""")
            .formParam("""smquerydata""", """""")
            .formParam("""smagentname""", """""")
            .formParam("""postpreservationdata""", """""")
            .formParam("""SMENC""", """""")
            .formParam("""SMLOCALE""", """""")
            .check(currentLocation.transform(s => {
                val locationRegex = """.*/autho/fed/(.*)/.*""".r
                val locationKey = locationRegex findFirstIn s
                URLDecoder.decode(locationKey.get.replace("somepath/to/replace", ""), "UTF-8")
              }).saveAs("redirectURL") )
            .resources(         
                http("request_3 ${redirectURL}")
                .get("https://go.to.this.url:443${redirectURL}")
                .check(currentLocation.transform(s => {
                    val locationRegexN = """.*/*/.*""".r
                    val locationKeyN = locationRegexN findFirstIn s
                    URLDecoder.decode(locationKeyN.get, "UTF-8")
                  }).saveAs("pingURL") )
                    .resources(
                        http("request_4  ${pingURL}").get("${pingURL}").check(status.is(200))
                    )
            ))
}



所以在这里我无法执行“request_4”,请建议我正确的做法。

【问题讨论】:

    标签: scala stress-testing gatling


    【解决方案1】:

    我们只支持一个级别的资源。

    【讨论】:

    • 那么如何根据一个请求的响应进行嵌套调用呢?
    • resources 块用于执行并发批次的请求,例如获取页面资源。否则就写 exec(request1).exec(request2)
    • 感谢您的快速响应 Stephane,我也尝试过,但问题是如果以这种方式执行,响应会给出 500 作为状态。在这两种情况下,我都尝试过解码第一个请求的 URL,但它确实给出了相同的响应 500。而它在加特林录音机中显示了正确的响应。那么加特林录音机是如何完成它的工作以获得正确的输出的呢。
    猜你喜欢
    • 2019-01-25
    • 2016-05-13
    • 2023-02-23
    • 1970-01-01
    • 2020-08-27
    • 2022-01-11
    • 2021-01-01
    • 1970-01-01
    • 2017-04-08
    相关资源
    最近更新 更多