How to make nested request call in gatling scala

1.2k Views Asked by At

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.

1

There are 1 best solutions below

3
On

We support only one level of resources.