My gatling script creates a set of users (5) and then each user iterates over a loop 20 times. The contents of the loop issues a single http request.
The http request is a POST request to a rest web service.
I have a directory with 1000 request bodies. How do I grab one of those files to post (e.g. the parameter to the fileBody() method call)?
I’ve tried the following using feed(), but it just tries to load a file that that includes the expression literally (not replacing it with a value from the csv file) – e.g. http://myhost.mycompany.com:8080/my-rest-service
My csv file listing all my data files looks like this:
filename
file123.txt
file456.txt
Essentially, I do three things:
-
load the csv file with the list of all my files containing http post contents:
-
val fileList = csv(“file_listing__separated_smaller.csv”).concurrentQueue- call feed() with this fileList variable as a parameter
-
.feed(fileList)- call the fileBody() method
-
.fileBody("${filename}")
Attempted script contents:
val httpConf = httpConfig
.baseURL(“http://myhost.mycompany.com:8080”)
.acceptHeader("/")
.userAgentHeader(“curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5”)
.warmUp(“http://myhost.mycompany.com:8080”)
val headers_1 = Map(
“Content-Type” → “”“text/plain”"",
“Expect” → “”“100-continue”"",
“Proxy-Connection” → “”“Keep-Alive”""
)
val fileList = csv(“file_listing.csv”).concurrentQueue
val scn = scenario(“Scenario Name”)
.feed(fileList)
.repeat(20)
{
exec(
http(“request_1”)
.post("/my-rest-service")
.headers(headers_1)
.fileBody("${filename}")
)
.pause(3)
}
setUp(scn.users(5).protocolConfig(httpConf))
Thanks!
Matt