user2948219
user2948219

Reputation: 17

Gatling 2.0: Parse CSV file to POST method

I have read the following documentation on csv parsing. http://gatling.io/docs/2.0.1/session/feeder.html#feeder

I am still unable to capture the following implementation:

What I am trying to achieve:

  1. Gatling reads the CSV file which contains the SIM serial number and reason details, represented by variable "SimSerial" and "ReasonID"
  2. The values of the CSV file are inserted into the parameters shown the code below

    package sim_replacement
    import scala.concurrent.duration._
    import io.gatling.core.Predef._
    import io.gatling.http.Predef._
    import io.gatling.jdbc.Predef._
    import io.gatling.core.feeder._
    
    class shakeout3a extends Simulation {
    
    val serialNumReasonID= csv("search2.csv")
    
    val scn = scenario("shakeout3")
            .group("5. Check SIM model"){
             exec(http("request_24")
                .post("""/SimReplacement/CheckSimModel""")
                .headers(headers_24)
                .formParam("""sim""", """${SimSerial}""")
                .resources(http("request_25")
                .post(uri2 + """/SIMReplacement/GetReasonDetails""")
                .headers(headers_25)
                .formParam("""strReasonId""", """${ReasonID}""")
            }}
    

Upvotes: 0

Views: 1985

Answers (1)

Stephane Landelle
Stephane Landelle

Reputation: 7038

How does one create variables in Scala, representing each column in the csv file?

Use feed. Attribute names ate taken from CSV headers (first line).

If I have 2 users running in sequence, how does Gatling parses the CSV file for both of the users? Does it automatically look up the next value after the first value have been parsed?

Built-in implementations read everything in memory on start up. A Feeder is an Iterator, so yes, it moves the cursor to the next record, according to the selected strategy (default is queue).

Everything is properly explained in the documentation link you mentioned.

Upvotes: 1

Related Questions