Feeder - Not using random value

27 views
Skip to first unread message

Gatling Learner

unread,
Feb 20, 2018, 9:37:37 AM2/20/18
to Gatling User Group
I have a script which needs to take random values from  csv


Here is a sample code 


    val feeder = csv("test.csv").random;
  val scn = scenario("Scenario Name").feed(feeder).during(5 minutes){ // A scenario is a chain of requests and pauses
   exec(flushHttpCache).exec(flushCookieJar).exec(http("request_1")
      .get("/"))
   .pause(2)
   .exec { session =>
  println("This is the value ========================="+session("number").as[String])
  session
}


The is the csv file
number
1
2
3
4
5
6
7
8
9


And i get the output as follows

2018-02-20 19:59:29                                           5s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=2      KO=0     )
> request_1                                                (OK=2      KO=0     )

---- Scenario Name -------------------------------------------------------------
[-------------------------------------                                     ]  0%
          waiting: 1      / active: 1      / done:0     
================================================================================

This is the value =========================5
This is the value =========================5

================================================================================
2018-02-20 19:59:34                                          10s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=3      KO=0     )
> request_1                                                (OK=3      KO=0     )

---- Scenario Name -------------------------------------------------------------
[-------------------------------------                                     ]  0%
          waiting: 1      / active: 1      / done:0     
================================================================================

This is the value =========================5
This is the value =========================5

================================================================================
2018-02-20 19:59:39                                          15s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=5      KO=0     )
> request_1                                                (OK=5      KO=0     )

---- Scenario Name -------------------------------------------------------------
[-------------------------------------                                     ]  0%
          waiting: 1      / active: 1      / done:0     




Should it take random values from feeder ? I see that every time its the same.

khaled.a...@gmail.com

unread,
Feb 20, 2018, 10:48:24 AM2/20/18
to Gatling User Group
try to use the below :

val feeder = csv("credentials.csv").random;
val scn = scenario("Scenario Name").during(1 minutes) { // A scenario is a chain of requests and pauses
feed(feeder).exec(flushHttpCache).exec(flushCookieJar).exec(http("request_1")

.get("/"))
.pause(2)
.exec { session =>
      println("This is the value =========================" + session("param_customerId").as[String])
session
}
}

Gatling Learner

unread,
Feb 20, 2018, 1:09:01 PM2/20/18
to Gatling User Group
Thanks much Khaled . I understood and now it works when i move the feeder inside the during block.
Reply all
Reply to author
Forward
0 new messages