简体   繁体   中英

How to make nested request call in gatling scala

I was able to call nested request at 2 levels but at third level it does not execute, so is am I doing it correct or not, if not what is correct way to execute nested request on basis of response

Here is my code what I have used

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))
                    )
            ))
}



So here I'm unable to execute "request_4", please suggest me right way of doing it.

我们仅支持一种资源。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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