Command line parameters usage

Gatling 2.0.0M3a

Objective to use command line parameters to specify users, ramp up time and duration of simulation.

Question: I got the code to compile as below, but, was wondering if there is a better way.

e.g. gatling.sh -s basic.mysimulation -Dusers=100 -Drampup=100 -Dsimulation_duration=3600

And the simulation would run with 100 users, coming in over 100 seconds (1 user per second)
and run the main simulation for 1 hour.

In my simulation, I do the following

40 val number_of_users = userNumber(Integer.getInteger(“users”))
41 val rampup = intToFiniteDuration(Integer.getInteger(“rampup”))
139 setUp(myScenario.inject(ramp(number_of_users) over (rampup))).protocols(httpProtocol)

I cannot use code like:
ramp(Integer.getInteger(“users”) users) over (Integer.getInteger(“rampup”) seconds)

10:34:06.054 [ERROR] i.g.a.ZincCompiler$ - mySimulation.scala:139: value seconds is not a member of scala.concurrent.duration.FiniteDuration
10:34:06.056 [ERROR] i.g.a.ZincCompiler$ - setUp(myScenario.inject(ramp(number_of_users) over (rampup seconds))).protocols(httpProtocol)

and

10:20:46.582 [ERROR] i.g.a.ZincCompiler$ - /mySimulation.scala:137: value users is not a member of String
10:20:46.584 [ERROR] i.g.a.ZincCompiler$ - setUp(myScenario.inject(ramp(System.getProperty(“users”) users) over (Integer.getInteger(“rampup”, 100) seconds))).protocols(httpProtocol)

Question2: How can I invoke scala compiler (ZincCompiler) from the command line for a specific scala file, instead of running gatling.sh to compile the changed code?

Thanks
Sajjad

Scala Int and Java Integer are different.
When you write 2 users, there’s an implicit conversion from Int to SomethingElse that make the users method available.
The thing is that the Scala compiler can’t trigger 2 implicit conversions at the same time.
When you write “Integer.getInteger(“users”) users”, you’d indeed need two: one from Integer to Int and the one mentioned above.
Write Integer.getInteger(“users”).toInt users and you’ll be back to 1 and it will work.

This behavior is the exact reason why we dropped this users “unit” in upcoming 2M4: ramp becomes rampUsers and rampUsersPerSec, so rampUsers(Integer.getInteger(“users”)) will work.

Regarding the second tentative: System.getProperty returns a String, so this will never work.

Get it?

I understand clearly. Thanks!

I keep struggling with implicit type conversions … knowing that two conversions are not allowed answers most of the issues I see.

Question2: How can I invoke scala compiler (ZincCompiler) from the command line for a specific scala file, instead of running gatling.sh to compile the changed code?