繁体   English   中英

如何在Gatling Scala中进行嵌套的请求调用

[英]How to make nested request call in gatling scala

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

这是我使用的代码

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”,请提出正确的建议方法。

我们仅支持一种资源。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM