Gatling 场景检查状态,然后响应 header。使用 `checkIf`?
Gatling scenario to check status, then response header. Use `checkIf`?
我希望创建一个场景,在其中执行以下速率限制测试:
- 每秒请求一次
- 检查状态
- 如果状态是
200
,没有进一步的
- 如果状态为
429
,则断言出现新的响应header (X-Ratelimited
)
到目前为止我的场景是这样设置的:
val throttleTest = scenario("Throttle access-code").during(60 seconds) {
exec(http("put")
.put("/auth/code")
.check(
checkIf(status.is(429))(header("X-Ratelimited"))
)
.body(StringBody(s"""{"foo": "$bar"}""")))
.pause(1)
}
目前这给我一个错误:
overloaded method value checkIf with alternatives:
[R, C <: io.gatling.core.check.Check[R]](condition: (R, io.gatling.core.session.Session) => io.gatling.commons.validation.Validation[Boolean])(thenCheck: C)(implicit cw: io.gatling.core.check.TypedConditionalCheckWrapper[R,C])C <and>
[C <: io.gatling.core.check.Check[_]](condition: io.gatling.core.session.Expression[Boolean])(thenCheck: C)(implicit cw: io.gatling.core.check.UntypedConditionalCheckWrapper[C])C
cannot be applied to (io.gatling.core.check.CheckBuilder[io.gatling.http.check.status.HttpStatusCheckType,io.gatling.http.response.Response,Int])
checkIf(status.is(429))(header("X-Ratelimited"))
在这种情况下我应该使用 checkIf
还是其他?
我希望创建一个场景,在其中执行以下速率限制测试:
- 每秒请求一次
- 检查状态
- 如果状态是
200
,没有进一步的 - 如果状态为
429
,则断言出现新的响应header (X-Ratelimited
)
到目前为止我的场景是这样设置的:
val throttleTest = scenario("Throttle access-code").during(60 seconds) {
exec(http("put")
.put("/auth/code")
.check(
checkIf(status.is(429))(header("X-Ratelimited"))
)
.body(StringBody(s"""{"foo": "$bar"}""")))
.pause(1)
}
目前这给我一个错误:
overloaded method value checkIf with alternatives:
[R, C <: io.gatling.core.check.Check[R]](condition: (R, io.gatling.core.session.Session) => io.gatling.commons.validation.Validation[Boolean])(thenCheck: C)(implicit cw: io.gatling.core.check.TypedConditionalCheckWrapper[R,C])C <and>
[C <: io.gatling.core.check.Check[_]](condition: io.gatling.core.session.Expression[Boolean])(thenCheck: C)(implicit cw: io.gatling.core.check.UntypedConditionalCheckWrapper[C])C
cannot be applied to (io.gatling.core.check.CheckBuilder[io.gatling.http.check.status.HttpStatusCheckType,io.gatling.http.response.Response,Int])
checkIf(status.is(429))(header("X-Ratelimited"))
在这种情况下我应该使用 checkIf
还是其他?