asLongas and counter


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”)
.check(jsonPath("$.status").dontValidate.saveAs(“Status”) )
//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.


Forum rules plz:!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.