I am trying to separate the chain and keep it in a re-usable variable
`
package computerdatabase
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import io.gatling.jsonpath._
class Test1 extends Simulation {
//Global Users
val userMap = scala.collection.concurrent.TrieMapString, String
//Randomiser
val rnd = new scala.util.Random
val httpConf = http
.baseURL(“http://demo1263864.mockable.io/”) // Here is the root for all relative URLs
.acceptHeader(“application/json”) // Here are the common headers
.doNotTrackHeader(“1”)
.acceptLanguageHeader(“en-US,en;q=0.5”)
.acceptEncodingHeader(“gzip, deflate”)
.userAgentHeader(“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0”)
val headers_1 = scala.collection.mutable.Map(“Content-Type” → “application/json”)
val chain1 = exec(
http(“chain request “)
.post(“gatling1”)
.headers((headers_1 += “pList” → “${pList}”).toMap)
.body(StringBody(””"{"${pList}"}"""))
.check(status.is(404)))
val scn = scenario(“Simple request”)
.exec(
http(“If request “)
.get(“gatling1”)
.headers(headers_1.toMap)
.check(jsonPath(”$.result”).is(“SUCCESS”),
jsonPath("$.data[*]").ofType[Map[String, Any]].findAll.saveAs(“pList”)))
.exec(chain1)
setUp(scn.inject(atOnceUsers(1)).protocols(httpConf))
}
`
This compiles fine but during runtime gives me following error
`
16:35:25.156 [INFO ] i.g.h.c.HttpProtocol - Start warm up
16:35:25.681 [INFO ] i.g.h.c.HttpProtocol - Warm up done
16:35:25.731 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘pList’ is defined
16:35:25.732 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘pList’ is defined
`
It does not gives any line number but I am sure its the following line which has a problem.
.headers((headers_1 += “pList” → “${pList}”).toMap)
When I use chain1 inline in the exec , it works fine.