Hello, wonderful people!
I spent a few hours trying to google any solution of how to break the loop on condition but nothing works. Please help me
I have the following blocks in my scenario but attribute “continue” is always “true”. I tried lots of things including session reset() and creating new attribute with the name “continue” - but still can’t override it
.exec(session => session.set("continue", true))
.asLongAs(session => session("continue").as[Boolean]) {
pause(15 seconds)
.exec(
http("check job status")
.get("/v1/commercial-schemes/" + commercialScheme + "/accounts/inventory/imports/${jobid}")
.header("Authorization", "Bearer " + "${token}")
.check(
status.in(200),
jsonPath("$.value.state").saveAs("state"),
jsonPath("$.value.result").saveAs("result")
)
)
.exec { session =>
logger.debug("Current job state: " + session("state").as[String] + " and job result: " + session("result").as[String])
if (session("state").as[Int] == 7) {
logger.info("Bulk cards import job finished with status: " + session("result").as[String] + " card prefix is: " + session("cardprefix").as[String])
session.set("continue", false)
}
session
}
}
Please give me some clues on how I can implement a loop and exit it as soon as service returns job status "7 - COMPLETED"
P.S. I use version 3.3.0