如何在gatling scala中进行嵌套请求调用

如何在gatling scala中进行嵌套请求调用,scala,stress-testing,gatling,Scala,Stress Testing,Gatling,我可以在两个级别调用嵌套请求,但在第三个级别它不会执行,所以我这样做是否正确,如果不正确,根据响应执行嵌套请求的正确方法是什么 这是我使用的代码 import scala.concurrent.duration._ import java.net.{URLDecoder, URLEncoder} import io.gatling.core.Predef._ import io.gatling.http.Predef._ import io.gatling.jdbc.Predef._ clas

我可以在两个级别调用嵌套请求,但在第三个级别它不会执行,所以我这样做是否正确,如果不正确,根据响应执行嵌套请求的正确方法是什么

这是我使用的代码

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”,请建议我正确的执行方法。

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

那么如何基于一个请求的响应进行嵌套调用呢?资源块用于执行并发的一批请求,如获取页面资源。否则,只需编写exec(request1)。exec(request2)谢谢您的快速响应Stephane,我也尝试过,但问题是如果以这种方式执行,响应会给出500作为状态。我试过对第一个请求的URL进行解码和不解码,在这两种情况下,它都会给出相同的响应。而它在gatling记录器中显示出正确的响应。那个么,加特林记录器是如何完成它的工作以获得正确的输出的呢。