asLongas and counter

Hi,

As per our requirement we need to wait either REST API response as “Completed” or 6 iterations of that call. Below is our Gatling script.

//.asLongAs((session => session(“counter”).as[Int] < 7 || session(“Status”).as[String] != “Completed”), “counter”)
//.asLongAs((session => session(“Status”).as[String] != “Completed”), “counter”)
//.asLongAs((session => session(“counter”).as[Int] < 7 ), “counter”)
{
group(“Check Status”)
{
exec(http(“request_17”)
.get("""/api/jobs/id""")
.headers(headers_0)
.check(jsonPath("$.status").dontValidate.saveAs(“Status”) )
).pause(5)
//counter = counter.intValue() + 1
} }

If we combined both above condition with OR, it goes in infinte loop; However both this condition works individually. I am not sure what is wrong in combined condition.

Thanks,
Chetan

Forum rules plz: https://groups.google.com/forum/#!forum/gatling

We are using Gatling 2.0.3

I suspect that your loop condition crashes because you use as[] that throws an Exception if the attribute is missing, which is the case for Status.
You should be using asOption.