Exit scenario on condition or after 12 repeats

Hi,

I have a get request which after about 60 seconds (it can take less or more) should return “complete” status. If this didn’t happen after 2 min, this means that test is failed. The code below doesn’t exit after “final status check”:

`

.asLongAs(_("status").as[String] != "complete"){
   repeat(12){
     pause(10)
    .exec(http("status check")
        .get("/api/v2/applications/" + _("param").as[String])
        .header("Content-Type", "application/json")
        .queryParam("api_key", Settings.api).asJSON
          .check(jsonPath("$.download.status").saveAs("status"))
    )
   }
   .exec(http("final status check")
      .get("/api/v2/applications/" + _("param").as[String])
        .header("Content-Type", "application/json")
        .queryParam("api_key", Settings.api).asJSON
        .check(jsonPath("$.download.status").is("complete"))
      )
      .exitHereIfFailed
}

`

If I would simply do retries, this will add “KO” to test summary every 10 seconds. Since status “complete” is expected somewhere between 1 and 2 minutes, I want the scenario to be “fail fast”.

Is there a way to modify the code above to exit on fail after 12 retries or earlier if condition “asLongAs” is met.

Thank you!

http://gatling.io/docs/2.2.2/general/scenario.html?highlight=trymax#trymax