How to test multiple URLs from a csv file

Hi,

Could I ask about testing multiple URLs from a csv file using Gatling? Thanks for your help. I have spent tens of hours on this performance testing, but still cannot get it right.

My urls.csv file is like this:
query=1
query=1
query=1

And my scala script is:
val url = csv(“urls.csv”).circular
val scn = scenario(“urls_test”).feed(url).during(10 seconds) {
exec(
http(“Performance Test for URLs”)
.get("/search?${url}")
.check(status.is(200)))
}

Best,
Phy.

The way you wrote it, each virtual user will be only fed once. Is this what you really want?
Otherwise, you have to move feed inside the during loop.

Then, note that the queries inside your csv file have to be proper queries (keys and values properly urlencoded).

You have to define a first line that contains the headers. Those will be used for naming the session attributes (“url” in your case).
Please properly read the documentation: https://github.com/excilys/gatling/wiki/Feeders#fileParsers

Hi, maybe I misunderstood but It looks like csv will work for you as you have 1 record per line and one column only resulting in no commas.

You could try it out with a limited data set to see if it produces the output you expect?

Thanks
Alex

@Phy What’s your problem exactly.
I think the only thing you have to change is to just add a first header line in your file with the string “url”.

OK, so as I said earlier, “the queries inside your csv file have to be proper queries (keys and values properly urlencoded)”.
pipe, comma and question mark are definitively NOT valid and have to be urlencoded.
http://en.wikipedia.org/wiki/Percent-encoding

Best would be that you have properly encoded queries in your csv file.

You only have 1 column, so you don’t even have to care about the column separator.

The other solution is to encode on the fly, but there’s of course an overhead:

.get(session => “search?” + java.net.URLEncoder.encode(session(“url”).as[String]))

This assumes that url is one single query parameter value that can be urlencoded as a whole.

Actually, that’s java.net.URLEncoder.encode(session(“url”).as[String], “UTF-8”) or whatever encoding you use.

I assumed Gatling 2M3a. If not please checkout Session API documentation and adapt.
https://github.com/excilys/gatling/wiki/Session#members