0

I am trying to pass runtime args while running gatling tests for couple of fields. For example I am trying to pass number of users dynamically when running the test. How can I do that?

James Z
  • 12,104
  • 10
  • 27
  • 43
har123
  • 39
  • 5

2 Answers2

2

This is documented in the official documentation:

This can be done very easily with additional JAVA_OPTS in the launch script:

JAVA_OPTS="-Dusers=500 -Dramp=3600"

val nbUsers = Integer.getInteger("users", 1)
val myRamp = java.lang.Long.getLong("ramp", 0L)
setUp(scn.inject(rampUsers(nbUsers).during(myRamp.seconds)))

// Of course, passing a String is just as easy as:

JAVA_OPTS="-Dfoo=bar"

val foo = System.getProperty("foo")
Stéphane LANDELLE
  • 4,480
  • 2
  • 8
  • 11
1

The easiest way is going for Java system properties, for example if you have workload model defined as:

setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))

if you change it from hard-coded to dynamic reading of the system property like:

setUp(scn.inject(atOnceUsers(Integer.parseInt(System.getProperty("userCount")))).protocols(httpProtocol))

you will be able to pass the desired number of users dynamically via -D command-line argument like:

gatling.bat -DuserCount=5 -s computerdatabase.BasicSimulation

More information: Gatling Installation, Verification and Configuration - the Ultimate Guide

Dmitri T
  • 140,090
  • 4
  • 71
  • 123