Dynamic scenario

Hi,

I’m building a scenario which discovers its next steps from the responses. I’m stuck at using session directly; a following is a simplified example:

scenario("test") .exec { http("get first").get("/first").check(bodyString.transform{ bs => //json parsing using play-json, jsonPath did not seem exactly convenient for complex transformation val theMap: Map[String,Seq[String]] = ... //this is the signature I want and get theMap }.saveAs("theMap")) }.exec { session => val theMap = session("theMap").as[Map[String,Seq[String]]] val requests = theMap("second").map { id => http(s"get $id").get(s"/$id")) } http("whatever").resources(requests:_*) //yes, I really really really need to fetch all of these requests in parallel session }

Now, what happens is that no request is emitted in the second exec; I guess it’s because I’m returning session and hence the requests are kinda side effect.

How can I achieve what I want? What am I missing here?

Thanks,

Zdenek

The warning in this section may provide some explanation:

http://gatling.io/docs/2.2.3/general/scenario.html#exec

I understand the explanation, but I could use some directions how to achieve what I want.

Maybe using repeat?

I just don’t understand why there is no exec which would take (Session) => ActionBuilder for situations when you want to do read-only ops over Session.

Hello,

I’m not quite sure about my idea, I haven’t much time to test it but maybe you could try creating this method to generate your HttpRequestBuilder with resources:

`

def generateResources(request: HttpRequestBuilder) = {
  var requests = _
  exec { session =>

  val theMap = session("theMap").as[Map[String,Seq[String]]]
  requests = theMap("second").map { id =>
    http(s"get $id").get(s"/$id")
  }
  session
}
request.resources(requests)
}

`

And use it in the scenario like this :

exec(generateResources(http("whatever")))

Hope it could help