rv2212
rv2212

Reputation: 11

Passing command line parameters in gatling sbt project

I am want to pass the ramp up users, throttle Duration, hold duration etc using command line parameters in a gatling sbt project.

for example:

val rampUpUserCount  =  Integer.parseInt(System.getProperty("rampUpUsers"))
val rampUpDuration = Integer.getInteger(System.getProperty("rampUpDuration"))

In the test I am doing

setUp(
    test.homePageScenario.inject(
      nothingFor(10 seconds),
      rampUsers(rampUpUserCount) over (rampUpDurationInMins minutes)
))

and from command line when I pass

 sbt gatling:testOnly simulations.test.gateway -DrampUpUsers=200 -DrampUpDuration=20

I am getting NumberFormatException

16:28:44.570 [INFO ] a.e.s.Slf4jLogger - Slf4jLogger started
[error] java.lang.NumberFormatException: null
[error]     at java.lang.Integer.parseInt(Integer.java:542)
[error]     at java.lang.Integer.parseInt(Integer.java:615)
[error]     at simulations.SimulationConfig.$init$(SimulationConfig.scala:185)
[error]     at simulations.engineGateway.GetRecsFromThinkGateway.<init>(GetRecsFromThinkGateway.scala:10)
[error]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[error]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error]     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[error]     at java.lang.Class.newInstance(Class.java:442)
[error]     at io.gatling.app.Runner.run0(Runner.scala:79)
[error]     at io.gatling.app.Runner.run(Runner.scala:64)
[error]     at io.gatling.app.Gatling$.start(Gatling.scala:59)
[error]     at io.gatling.app.Gatling$.fromArgs(Gatling.scala:43)
[error]     at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:51)
[error]     at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:50)
[error]     at sbt.ForkMain$Run$2.call(ForkMain.java:296)
[error]     at sbt.ForkMain$Run$2.call(ForkMain.java:286)
[error]     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]     at java.lang.Thread.run(Thread.java:748)

Please can someone help me with this? Thanks

Upvotes: 1

Views: 2149

Answers (1)

Luca T.
Luca T.

Reputation: 1651

You need to move the parameters before the task gatling:testOnly

 sbt -DrampUpUsers=200 -DrampUpDuration=20 gatling:testOnly simulations.test.gateway 

Upvotes: 1

Related Questions