Extracting method with session

I have this method that works perfectly:

.exec(http(“Vajuta kustuta”)
.get(session => “/?0-1.ILinkListener-bodyPanel-contentComponent-vat_declarations-” + someCounter + “-delete”)
)
.pause(2)

For each user it increments the counter which is defined:

def someCounter = deleteCounter.getAndIncrement

But when I create a method:

def testGetIt(requestTitle: String,
requestURL: String,
pause: Int) = {
exec(http(requestTitle).get(session => requestURL)
).pause(pause)
}

and when I call it, it doesn’t get incremented and instead of deleting any number of rows from DB it only deletes 1.

Still haven’t found the solution. The same problem occurs with my post request method:

def postMePlease(requestTitle: String,
requestURL: String,
pause: Int,
listOfParams: Seq[(String, String)]) = {
exec(http(requestTitle)
.post(requestURL)
.formParamSeq(listOfParams))
.pause(pause)
}

Where the list of params is:

Seq((“transactionsWithRate20”, someNumber.toString),
(“someParam”, “someValue”))

And someNumber is def someNumber = randomNumber.nextInt(40)

The value is the same for all sessions. What could I do so someNumber would acquire different values?

It’s just impossible to get a picture of what you’re doing with just those fragments.
Could you post a gist, please?

Thank you for a reply! Here is a sample of what I’m trying to do:
https://gist.github.com/anonymous/f26b7a0334ce15a6fe17

Your gist doesn’t compile!

https://gist.github.com/anonymous/f26b7a0334ce15a6fe17#file-loadtest-scala-L37: getIt expects 3 parameters and you pass 4

https://gist.github.com/anonymous/f26b7a0334ce15a6fe17#file-loadtest-scala-L42: what is this leading dot doing here?!

Sorry for that, this should compile:
https://gist.github.com/anonymous/57570cbeba8c42a58da4

Here’s the sequence of what happens:

  • Gatling loads the Simulation and build the whole scenario workflow

  • It hits .exec(delete), so delete gets called ONCE, when the scenario is built

  • delete calls getId with the requestUrl String parameter set with “SomeUrlPart_1_” + deleteCounter.getAndIncrement + “_SomeUrlPart_2”
    So clearly, this can not work.
    You have to make requestUrl an Expression[String]:

requestURL: io.gatling.core.session.Expression[String]

and indeed pass it a function:

getIt(“delete”, session => “SomeUrlPart_1_” + deleteCounter.getAndIncrement + “_SomeUrlPart_2”, 3)

Thanks a lot. Works flawlessly. Couldn’t do it without you.