A legacy app has the below working Gatling test
private val getUserByTuid = scenario("GetActiveUserInfoWrapper")
.feed(users.toArray.circular)
.exec(
http("GET /v1/foo/{id}")
.get("/v1/foo/${id}")
.header("Content-Type", "application/json")
.header("User-Agent", "gatling")
.check(status is 200)
.check(jsonPath("$..ID") exists)
)
I need to change it such that either the status is 200, in which case it checks that jsonnode ID exists (just like above), or the status is 401, in which case it checks that jsonnode Description exists. Any other status should result in a failure.
This is what I have so far but it doesn't appear to be working as intended because Gatling considers all responses failures, even the ones that are 200 with ID and 401 with Description.
private val getUserByTuid = scenario("GetActiveUserInfoWrapper")
.feed(users.toArray.circular)
.exec(
http("GET /v1/foo/{id}")
.get("/v1/foo/${id}")
.header("Content-Type", "application/json")
.header("User-Agent", "gatling")
.check(checkIf((response: Response, session: Session) => response.status.get.getStatusCode == 200)(jsonPath("$..ID") exists))
.check(checkIf((response: Response, session: Session) => response.status.get.getStatusCode == 401)(jsonPath("$..Description") exists))
)
I've looked at the docs and searched around the web but haven't been able to figure out the correct way to achieve what I want, thus asking here.
.check(status.in(200, 401))
before the subsequent checks. – Leibnizimport io.gatling.core.Predef.value2Success
is required when using thecheckIf(condition: (R, Session) => Validation[Boolean])(thenCheck: C)
overload – Slumgullion