knittl
knittl

Reputation: 265817

Execute a Gatling scenario exactly once

I want to execute a Gatling scenario exactly once (i.e. execute a single virtual user with a single iteration). I don't want to execute it for a duration, I don't want to concurrent users, I don't want to have users per sec.

final ScenarioBuilder scenario = scenario("exactly once")
  .exec(http.get("/something"))
  .exec(http.get("/somethingelse"));

setUp(scenario.injectClosed(
  constantConcurrentUsers(1).iterations(1) // what to put here?
);

Running this test, I expect exactly 2 requests hitting my web server: 1 request to /something and 1 request to /somethingelse.

The injection docs don't really mention anything about iterations.

Coming from k6, this would be as simple as k6 run -u1 -i1 test.js (actually the default, equivalent to k6 run test.js) or with shared-iterations executor (again, defaults to 1 user with 1 iteration).

Upvotes: 1

Views: 149

Answers (1)

Amerousful
Amerousful

Reputation: 2545

Pretty simple - atOnceUsers(1)
atOnceUsers(nbUsers): Injects a given number of users at once.

Upvotes: 3

Related Questions