我们有两个服务,一个接收消息,另一个告诉我们消息何时被处理。 我正试图在一次加速测试中加以说明。 这是我迄今为止的,但我最后一点挣扎..
scenario("push message and poll for result") .feed(feeder) .group("push and check: group") { exec(http("push") .put("/create") .check(status.is(200)) ) .asLongAs(session => !session.contains("messageProcessed")) { exec(http("poll") .get("/poll") .check(status.is(200), jsonPath("$.results[0].resultCount").saveAs("resultCount")) } }我的问题是resultCount最初将为零,所以我想保持轮询,直到它变为!= 0。当发生这种情况时,我想我可以将“messageProcessed”设置为某个值,然后它将退出循环。
有没有办法做到这一点? 谢谢你的帮助。
We have two services, one which receives a message and a second which tells us when the message has been processed. I'm trying to cover this in a gatling test. Here's what I have so far but I'm struggling with the last bit..
scenario("push message and poll for result") .feed(feeder) .group("push and check: group") { exec(http("push") .put("/create") .check(status.is(200)) ) .asLongAs(session => !session.contains("messageProcessed")) { exec(http("poll") .get("/poll") .check(status.is(200), jsonPath("$.results[0].resultCount").saveAs("resultCount")) } }My problem is resultCount will initially be zero so I want to keep polling until it becomes != 0. When this happens I thought I could set "messageProcessed" to something and then it would drop out of the loop.
Is there a way to do this? Thanks for your help.
最满意答案
这是我最终使用的解决方案
.asLongAs(session => getResultCount(session) == 0) {并添加了这个方法:
def getResultCount(session: Session): Int = { session("resultCount").asOption[String].map(_.toInt).getOrElse(0) }this was the solution I used in the end
.asLongAs(session => getResultCount(session) == 0) {and added this method:
def getResultCount(session: Session): Int = { session("resultCount").asOption[String].map(_.toInt).getOrElse(0) }更多推荐
发布评论