I have a Gatling script with few objects that I use for my tests. One of the objects is used to authenticate users and users are passed to test using a feeder. The feeder is now defined on top in the beginning of the simulation class like this:
val feeder = csv("users.csv").circular
The feeder provides pairs of usernames and passwords. The object looks like:
object Auth {
val login = {
feed(feeder)
.exec(http("get_auth_token")
.post("/get_auth_token")
.body(StringBody("""{
"username": "${username}",
"password": "${password}"
}""")).asJSON
// this check extracts accessToken from JSON received in response
.check(
status.find.in(200,304,201,202,203,204,205,206,207,208,209),
jsonPath("$.response_body.access.token").saveAs("accessToken"),
jsonPath("$.response_body.refresh.token").saveAs("refreshToken")
)
).exitHereIfFailed
}
val refreshAuthToken = {
exec(http("refresh_auth_token")
.post("/refresh_auth_token")
.header("Authorization", "Bearer ${refreshToken}")
.check(
status.find.in(200,304,201,202,203,204,205,206,207,208,209),
jsonPath("$.response_body.access.token").saveAs("accessToken")
)
).exitHereIfFailed
}
}
Then I have a scenario that looks like:
val myScenario = scenario("My test")
.exec(Auth.login)
// Do some stuff here
.exec(Auth.refreshAuthToken)
// Do more stuff here
Then I have a setup that runs this single scenario.
What I would like to have is additional scenario that will run alongside with the get additional scenario that will run alongside with myScenario
. This scenario will also perform Auth.login
, but I want it to use a different set of users - so I need to have two separate feeders that will be passed to Auth.login
from scenario. Can someone suggest how this can be achieved?