AsLongAs end scenario ?

Hello,

On my scenario, I used an AsLongAs method to check whether a condition is valid or not, and then, use a get request. Yet, my get request never happen…

Here is what was on my scenario :
scenario(“XXX”).exec(http(“action”)…)
.asLongAs( condition ) (
exec( http(“action”).get( … ) )
)
.exec(
http(“this-request-never-happened”)
.get(" ")
)

Am I doing it wrong ?

Thanks for your feedback.

You have to be more specific.
Are you sure that your condition become invalid at some point so you exit the loop?
Are you sure your condition is something that gets reevaluated on each iteration and not a static value?

Yes I am sure the condition become invalid at some point. I do exit the loop, the simulation ends well.

Here is my code :

.exec(
http(“get-status”)
.get("/action/show/${id}").asJSON
.check(jsonPath("$…status").saveAs(“new_status”)
.asLongAs(session => session(“new_status”).as[String] != “done” && session(“new_status”).as[String] != “killed”) (
exec(
http(“follow-action”)
.get("/action/show/${id}").asJSON
.check(jsonPath("$…status").saveAs(“new_status”)
)
.exec(
http(“the-request-that-ever-happen”)
.get(“action/show/${id}).asJSON
.check(jsonPath(”$…status").is(“done”)

Thanks again for your feedback.
Maybe there is a better way to do it…

There’s a cleaner way to write the asLongAs condition so you don’t have to perform the request once before the loop:

session => session(“new_status”).asOption[String].map(value => value != “done” && value != “killed”).getOrElse(true))

Then, I have no idea why you don’t get the expected behavior.

I would need you to provide a runnable sample so I can reproduce.

Cheers,