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,209
  • 10
  • 24
  • 44
har123
  • 49
  • 6

2 Answers2

3

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
  • 6,076
  • 2
  • 10
  • 12
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
  • 159,985
  • 5
  • 83
  • 133