ALS
ALS

Reputation: 163

Saving session attribute in a list

I would like to save a session attribute in a list in my gatling simulation. What am trying to do is to get all the values of my JSON who are defined in a CV file and write it in a file. In my example below "test" is always equal to the value of the first jsonPath.

Here what I am doing:

val scn1 = scenario("[SCENARIO] GET")
.repeat(Nbproduct-1, "counter") (
  feed(csv(CSV).circular)
  .exec(http("get JSON")
    .get(url_1")
    .check(jsonPath("""$.${meta_ref}""").find.saveAs("test")))
    .pause(1) 
    .exec(session => {
            writer.write("\""+session("meta_cts").as[String]+"\":\"" +  session("test").as[String]+"\",\n")
       session
               }         
            )

I also tried this but it get the value of the counter... .check(jsonPath("""$.${meta_ref}""").find.saveAs("""jdd_value("${counter}")""")))

Thanks for the help!

Upvotes: 0

Views: 685

Answers (1)

Stephane Landelle
Stephane Landelle

Reputation: 7038

Feeders are shared datasources, so first user will pop the first record, second user the second record, etc...

Then, it's not possible to define checks at runtime (depending on some entries in a file). All DSL components are builders that are only resolved once when the Simulation is loaded.

Upvotes: 1

Related Questions