Search code examples
scalagatling

Gatling - how do I run a particular scenario for a specific duration


I have two scenarios which I want to execute in parallel, ramp up and maintain the load for 5 minutes before stopping the users. similiar to the scheduler in loadrunner.

I have used the below approach, please advice if this is right way of doing it.

val BP01AddSearch = scenario("BP01Search").during (5 minutes)
            {
                exec(Homepage.homepage, Login.login, SearchLink.search,  Logout.logout)
            }
        val BP02GASearch = scenario("BP02GASearch").during (5 minutes) {
            exec(Homepage.homepage, Login.login, SearchLink.search, Logout.logout)
        }

setUp(
            BP01AddSearch.inject(rampUsers(5) during (15 seconds)).protocols(httpProtocol),
            BP02GASearch.inject(rampUsers(2) during (15 seconds)).protocols(httpProtocol)
        )   .maxDuration(300 seconds)

Solution

  • Yes, that would work.

    Note 1: you can use a forever loop instead of a during one as you're interrupting with maxDuration anyway.

    Note 2: if you're setting the same httpProtocol on each scenario, you can define it on the setUp just like you did for maxDuration.

    Note 3: you can use maxDuration(5.minutes) instead of maxDuration(300 seconds).