How to loop a csv file

6,444 views
Skip to first unread message

Paul Langeard

unread,
May 10, 2012, 3:50:36 AM5/10/12
to Gatling User Group
Hi,
I have created a csv files which has 10 000 different user's requests
(10000 lines ).
I want gatling to run all these requests with 10 conncurrent users:

val scn = scenario("Scenario name")
.feed(csv("collectorcallurl.csv"))
.loop(
chain
.exec(
http("request_collectorevent")
.get("/${collectorcallurl}")
.check(status.is(200)))
.pause(0, 10, MILLISECONDS)
).
during(1200, SECONDS)

List(scn.configure.users(10).ramp(10).protocolConfig(httpConf))

My issue is that gatling loop on the 10 first line of my csv file.
What's the way to do that ?

--
Paul


Stéphane Landelle

unread,
May 10, 2012, 3:54:14 AM5/10/12
to gat...@googlegroups.com

Romain Sertelon

unread,
May 10, 2012, 3:59:53 AM5/10/12
to gat...@googlegroups.com

Hi!

The call to feed should be made in the loop just before the exec instruction.

This way, a record of the feeder will be popped for each loop.

Cheers,
BluePyth

Stéphane Landelle

unread,
May 10, 2012, 3:59:59 AM5/10/12
to gat...@googlegroups.com
Sorry, didn't read thoroughly.

Your problem is that you didn't call feed at the right place. Calling "feed" pops an entry from the feeder and inject it into the user's Session.
So in your case, you have to put it inside the loop:

 val scn = scenario("Scenario name")
     .loop(
          chain
               .feed(csv("collectorcallurl.csv"))
               .exec(http("request_collectorevent")

                        .get("/${collectorcallurl}")
                        .check(status.is(200)))
                        .pause(0, 10, MILLISECONDS)
       ).during(1200, SECONDS)

2012/5/10 Stéphane Landelle <slan...@excilys.com>

Stéphane Landelle

unread,
May 10, 2012, 4:00:42 AM5/10/12
to gat...@googlegroups.com
You were faster, buddy! Your win ;-)

2012/5/10 Romain Sertelon <blue...@gmail.com>

Paul Langeard

unread,
May 10, 2012, 5:34:22 AM5/10/12
to Gatling User Group
Thnks Guys,
once again I am surpise by your reactivity!

--
Paul

On 10 mai, 10:00, Stéphane Landelle <slande...@excilys.com> wrote:
> You were faster, buddy! Your win ;-)
>
> 2012/5/10 Romain Sertelon <bluep...@gmail.com>
>
>
>
>
>
>
>
> > Hi!
>
> > The call to feed should be made in the loop just before the exec
> > instruction.
>
> > This way, a record of the feeder will be popped for each loop.
>
> > Cheers,
> > BluePyth
> > On May 10, 2012 9:54 AM, "Stéphane Landelle" <slande...@excilys.com>
> > wrote:
>
> >>https://github.com/excilys/gatling/wiki/Feeders#wiki-circular
>
> >> Cheers,
>
> >> Stephane
>
> >>  2012/5/10 Paul Langeard <agpa...@gmail.com>

Rohan S Raju

unread,
Jan 29, 2014, 3:00:53 AM1/29/14
to gat...@googlegroups.com
The below loop code looks to be broken in gatling 2.0.0-M3, Not able to get the example for the Loop. Please post some example if you have for the 2.0.0-M3 release of gatling.

Thanks in advance.

Regards,
Rohan S Raju.

Stéphane Landelle

unread,
Jan 29, 2014, 3:09:18 AM1/29/14
to gat...@googlegroups.com


2014-01-29 Rohan S Raju <42r...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Raja Thumati

unread,
Oct 17, 2014, 5:23:04 AM10/17/14
to gat...@googlegroups.com
hi Stephane,

i want to pass .param(b(0),b(1)) values iteratively 

val httpProtocol = http
.baseURL("url")
.disableFollowRedirect
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.doNotTrackHeader("1")
.acceptLanguageHeader("en-US,en;q=0.5")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0")
.acceptLanguageHeader("en-US,en;q=0.5")
               .acceptEncodingHeader("gzip, deflate")
                .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")
.connection("keep-alive")

val header = Map("Content-Type" -> "application/x-www-form-urlencoded")

var i=0
var j=0
val prop = new Properties()
val writer = {
                val fos = new java.io.FileOutputStream("D:/test-data.properties")
                          new java.io.PrintWriter(fos,true)
                             }
val writer1 = {
                val fos = new java.io.FileOutputStream("D:/test-data.csv")
                          new java.io.PrintWriter(fos,true)
                             }
writer1.println("key,value")
try {
val file1 = new FileInputStream("D:\\Config.properties")
prop.load(file1);
}
catch {
     case ex: IOException => Logger.getLogger(classOf[RecordedSimulation123].getName).log(Level.SEVERE, null, ex)
}
val list = prop.propertyNames()
try {
while (list.hasMoreElements()) {
val key = list.nextElement().asInstanceOf[String]
val s=prop.get(key).toString()
val a:Array[String]=s.split("&")
writer.println(a(0)+"\t\t"+a(1)+"\n\n\n")
j=a.length
           
while( i != a.length)
{
val b:Array[String]=a(i).split("\\^")
     writer1.println(b(0)+","+b(1))
     
  i+=1
}
val productIems = csv("D:/test-data.csv").queue
   val scn = scenario("scenario param")
        
.exec(http("GET web service")
                      .headers(header)
     .post(key)
     .repeat(b.length){        
                     .param(b(0), b(1)) 
                    }     
  )
 
  setUp(scn.inject(atOnce(1 user))).protocols(httpProtocol)     
         
      }
}
catch {
 case e: Exception =>e.printStackTrace()
} finally {
}

}our suggetions are most useful to me 
thanks in advance


y
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages