Using loop counter in the URL

930 views
Skip to first unread message

MyGoul

unread,
Apr 18, 2014, 4:45:51 AM4/18/14
to gat...@googlegroups.com
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.

MyGoul

unread,
Apr 18, 2014, 4:47:36 AM4/18/14
to gat...@googlegroups.com
By the way, i'm using Gatling 1.5.5.

Maxime Tual

unread,
Apr 18, 2014, 5:07:35 AM4/18/14
to gat...@googlegroups.com
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

Sylvain Goulmy

unread,
Apr 18, 2014, 5:10:18 AM4/18/14
to gat...@googlegroups.com
Thnaks for your support, you solved my problem.

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


--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/3-AJTEVK57A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maxime Tual

unread,
Apr 18, 2014, 5:11:15 AM4/18/14
to gat...@googlegroups.com
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)

Maxime Tual

unread,
Apr 18, 2014, 5:14:30 AM4/18/14
to gat...@googlegroups.com
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/

Maxime Tual

unread,
Apr 18, 2014, 5:28:18 AM4/18/14
to gat...@googlegroups.com
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 ><

Maxime Tual

unread,
Apr 18, 2014, 5:56:32 AM4/18/14
to gat...@googlegroups.com
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. :)
Reply all
Reply to author
Forward
0 new messages