0
votes

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:

  • How does one create variables in Scala, representing each column in the csv file?
  • 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?

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}""")
            }}
    
1
why are you using """ for strings that don't take advantage of its features? - Electric Coffee
also, you're missing at least two ) in the code from what I can tell - Electric Coffee

1 Answers

1
votes

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.