DEV Community

özkan pakdil
özkan pakdil

Posted on • Originally published at ozkanpakdil.gitlab.io on

Gatling parameterize

In order to send testing parameters from command line like below

mvn -ntp -f $retDir/gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=3

Enter fullscreen mode Exit fullscreen mode

these users and repeat can be used from load scala like below

class LoadTest extends Simulation {

    val nbUsers = Integer.getInteger("users", 1000)
    val myRepeat = java.lang.Long.getLong("repeat", 2)

    val httpProtocol = http.baseUrl("http://localhost:8080")

    val scn = scenario("hello").repeat(myRepeat.toInt) {
        exec(http("GetApplicationInfo")
            .get("/hello")
            .check(status.is(200))
            .check(jsonPath("$.name")))
    }

    setUp(
        scn.inject(
            rampUsers(nbUsers) during (5 seconds)
        ).protocols(httpProtocol)
    )
}

Enter fullscreen mode Exit fullscreen mode

that test will send nbUsers of request to localhost:8080/hello myRepeat times, For full file check and how to call it from here

Top comments (0)