0

I wonder if there is a way somehow to specify the load (nbr of virtual users) per call and not per scenario?

Let's say I want to stress test a game and I only need one call to open or close a game, but I want a huge deal of users playing it... Can I achieve this with Gatling?

Thanks a lot!

Foobar
  • 1

2 Answers2

1

You can always have a small scenario doing exactly what you want. If you don't want to repeat certain steps for every single user, you may probably use before/after hooks to open or close game.

Mykola Gurov
  • 8,517
  • 4
  • 29
  • 27
  • This is quite smart, but not being able to use Gatling DSL in before/after hooks is an awful limitation though. And when you say that "You can always have a small scenario doing exactly what you want", could you give me more details please? I've seen that you can execute multiple scenarios, but they execute concurrently, so I would have no guarantee that the "open game" scenario would execute before the "play game" scenario. – Foobar Jul 22 '15 at 08:21
  • I mean you can split larger scenarios into smaller reusable pieces. Don't think you can compose scenarios in a way that would allow you to replace the before/after hooks though. Doesn't seem to fit the idea of the tools like gatling as I understand it, although I might still be not 100% correct. – Mykola Gurov Jul 23 '15 at 10:42
0

One way to do it:

Steps:

  1. Wrap your Simulation in a trait.

  2. Define methods within the trait.

  3. Define the scenarios.

  4. After the closing brace of the trait, define a simulation class.

In the end you should have something like this:

package [name]

import [all the stuff]

trait Scenario2 extends Simulation {

//
// Here you should put all the VALs, baseURL, headers etc.
//

    def openGame() =
        http("Opens the game")
          .get("IP to open the game")
          .headers(headers)
          .check(status.is(200)) (optional)

    def usersPlaying() = 
        http("Users playing the game")
          .get("IP to play the game")
          .headers(headers)
          .check(status.is(200)) (optional)

  def scen(name: String) = {
   scenario(name)
          .exec(openGame())
    }

  def scen2(name: String) = {
   scenario(name)
          .exec(usersPlaying())
          .pause(5) // the pause needs to be **here** for some reason, rather than in *scen*
    }

}

// Here lies the simulation class

    class Testing_The_Game extends Scenario2 {
      setUp(
       (scen("This opens the game")
        .inject(
          atOnceUsers(1))
          .protocols(httpConf)),
       (scen2("This simulates users playing")
        .inject(
          atOnceUsers(1000))
          .protocols(httpConf))
          )
    }

Just found this answer. It looks much better than mine.

Community
  • 1
  • 1
Alichino
  • 1,668
  • 2
  • 16
  • 25