Using loop counter in the URL

Hi,

I’m very new with Gatling and even after browsing the documentation i don’t know how to solve my problem. I’d like to play 6000 times a URL with using the counter and the URL itself, i tried something like this :

val scn = scenario(“Scenario Name”)
.repeat(6000, counterName) {
.exec(http(“request_1”)
.get("/checkServer/testJSP-${counterName}.jsp")
)
}

setUp(scn.users(1).protocolConfig(httpConf))

But i have an “illegal start of statement” when i try to lunch gatling.

What would be the correct way to do that ? Sorry, this is probably obvious but i don’t know scala at all…

Thanks in advance for your return.

By the way, i’m using Gatling 1.5.5.

You have two erros:

val scn = scenario(“Scenario Name”)
.repeat(6000, “counterName”) {
exec(http(“request_1”)
.get("/checkServer/testJSP-${counterName}.jsp"))
}

Use " for specify which name use to counterKey (counterName → “counterName”)
Remove the . before your exec call

Thnaks for your support, you solved my problem.

Where can i find a reference guide of the syntax of this scala “language” ?

By the way I’m already looking for some counter feature.

I’ve got a scenario which create user and I want to put somewhere the number of time the scenario is call.
Each time a user is created I want to increment the counter. How can I do that ?
var scn = exec(http(“Create User”).get("/createUser")).exec(session => //UPDATE COUNTER HERE)

Good question, I’m looking for one better than just Googling every time I get stuck on scala syntax.
You got this website: http://docs.scala-lang.org/cheatsheets/

I’ve found this post: https://groups.google.com/d/msg/gatling/16ONCJ-9PRk/O5tY2kL1PssJ

So I try to create this object in my Simulation class:

object CounterScenarios {
var c = 0
def newUserCreated() = {
c = c + 1
}
def howMany():Int = {
return c
}
}

But I don’t know how to access this object from my others objects containing scenarios ><

I found the solution, my object was good, I just move it to CreateUser object (containing scenario for create users) and now I can access it throught: CreateUser.CounterScenarios.howMany() from others object. :slight_smile: