Issue manipulating string read from a feeder

Hi,

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)
}

Scenario:

Versions:

<gatling-plugin.version>2.2.4</gatling-plugin.version>
<gatling.version>2.3.0</gatling.version>
<mssql.jdbc.version>6.1.0.jre8</mssql.jdbc.version>
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>

Same with updated version

<gatling.version>2.3.1</gatling.version>
<gatling-plugin.version>2.2.4</gatling-plugin.version>
<scala-maven-plugin.version>3.4.2</scala-maven-plugin.version>

Hi,

Can someone please help? It looks like a bug to me in gatling, did anyone else have a similar experience? If so how did you fix it?

Try removing the ‘s’ before the opening triple quote. See here for details.

https://docs.scala-lang.org/overviews/core/string-interpolation.htmln

RequestBody.itemDetailRequest(“${u}”, “${i}”, “${a}”, “${ii}”))

This is not a Gatling issue, you can’t pass some Gatling EL String to your own code and expect replacement to magically happen.
From https://gatling.io/docs/current/session/expression_el/#expression-language:

Warning

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)
 RequestBody.itemDetailRequest(u, "${i}", "${a}", "${ii}"))


I tried a few more things too, but i am still unable to solve this problem. Can help is greatly appreciated.