Hi all,
Gatling 2.0.0-M3a
I have a REST API that is called with variable set to a default value of 0. The returned data contains the current value of that variable on the server.
Each subsequent call to that API has to use the new value of the variable.
I was able to successfully extract the current value from a REST call and save it in a session variable. Printing the session shows the session variable has the correct value.
What I want to accomplish is:
a. Initialize the session variable with value 0
b. Make first REST call and set the session variable with the value returned by server. This can be done once per simulation and that value set in each session (each user).
c. Start the main loop with a repeat/during block that generates the load on the server.
I am thinking along the lines of:
val scn = scenario("Get Generation")
.feed(csv("user_information.csv")) // contains userid,passwd
.repeat(1) {
exec(session => {session.set("generation_current", 0)})
.exec(
http("user_config")
.get("/svc/api/v1/2/users/${userid}/user_config?generation=${generation_current}")
.basicAuth("${userid}", "${passwd}")
.check(jsonPath("$..generation").find.saveAs("generation_current"))
.check(
status.is(200))
)
}
val loopscn = scenario("Create Config")
.feed(csv("user_information.csv")) // same feed as before
.repeat(100) {
.exec(
http("user_config")
.get("/svc/api/v1/2/users/${userid}/user_config?generation=${generation_current}")
.basicAuth("${userid}", "${passwd}")
.check(
status.is(200))
)
}
setup(scn.inject(ramp(1000 users) over (100 seconds))
.loopscn.inject(ramp(1000 users) over (100 seconds))).protocols(httpProtocol)
What I do not know is if the 1000 user sessions created for the first scenario will be reused for the second scenario.
Is there a better way to construct this simulation?
Thanks
Sajjad