I found a problem with scala + gatling combination, and after a lot of research, looks like gatling feeder does not pass the value correctly reading from CSV to the session, especially when you do a string manipulation ( using split() in my case). I do not think there is a logical problem with my code, since the same thing works, if i hardcode the values, but does not split when i read from csv.
Simulation Class:
class DPerfTest extends Simulation {
setUp(
DScenario.checkKIE
.inject(constantUsersPerSec(RequestHelper.keepItUsers) during (RequestHelper.keepItDuration))
).protocols(RequestHelper.httpRequest)
}
This Expression Language only works on the final value that is passed to the DSL method when the Simulation is instantiated.
For example, queryParam("latitude", "${latitude}".toInt + 24) won’t work, the program will blow on "${latitude}".toInt as this String can’t be parsed into an Int.
The solution here would be to pass a function:
session => session("latitude").validate[Int].map(i => i + 24).
Hi Stephene,
Thanks for pointing out to that link. I did read that document again today, but it still seems impossible to get the string to split in my scenarioIf I use exec(POST), I do not have access to the session. If I use exec(session), my POST does not work.( UnsupportedOperationException: There were no requests sent during the simulation, reports won’t be generated)
Can you please provide an example as to how to use validate() in this case? Most examples on stackoverflow and here, manipulate the string in the response. I have not come across a working solution where someone was successful in manipulating string read from the feeder. Thanks for your time!
My solution, which fails to compile or which cannot do a POST
.exec{ session =>
if (session.contains("u")) {
val u = session("u").toString.split(":").get(0)