# Ignoring failure when retry succeeds

**URL:** <https://community.gatling.io/t/ignoring-failure-when-retry-succeeds/3638>\
**Category:** Gatling (Open-Source)\
**Created:** [March 28, 2017, 2:05pm UTC](https://community.gatling.io/t/ignoring-failure-when-retry-succeeds/3638 "2017-03-28T14:05:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magnus\_Reftel](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Magnus\_Reftel](https://community.gatling.io/u/Magnus_Reftel)\
**Post date:** [March 28, 2017, 2:05pm UTC](https://community.gatling.io/t/ignoring-failure-when-retry-succeeds/3638/1 "2017-03-28T14:05:27Z")

</div>

Hi,

I’m doing load testing on a combination of two services. The first one occasionally fails, but succeeds on retry. As long as it succeeds after not too many retries, this is OK. If the service fails too many times, or if the second service fails, then I’d like to report this as a failure. I’m trying to set this up using .check on the first service, inside a tryMax block, and while it does retry the failing call, continuing to the second service, the intermittent failure is counted as a KO, and Gatling exits with exit code 2, indicating a failure.  
Is there a way to get Gatling to ignore the intermittent failures of the first service completely, so that I can use the exit code to tell if there was a severe failure?

Best Regards  
Magnus Reftel

---

<div class="post-metadata">

**Author:** ![Barry\_Perez](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@Barry\_Perez](https://community.gatling.io/u/Barry_Perez)\
**Post date:** [March 28, 2017, 6:28pm UTC](https://community.gatling.io/t/ignoring-failure-when-retry-succeeds/3638/2 "2017-03-28T18:28:54Z")

</div>

Hi,

You can make a check optional and save the result (status code etc) but AFAIK Gatling doesn’t currently support being able to programmatically pass or fail a transaction (that would be really handy IMO).

I’m sure it’s possible if you dig down into the source but I just haven’t had the time to look into it.

Please share your solution if you manage to crack this one!

Thanks,  
Barry

---

<div class="post-metadata">

**Author:** ![Magnus\_Reftel](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Magnus\_Reftel](https://community.gatling.io/u/Magnus_Reftel)\
**Post date:** [April 5, 2017, 2:00pm UTC](https://community.gatling.io/t/ignoring-failure-when-retry-succeeds/3638/3 "2017-04-05T14:00:07Z")

</div>

Thanks for the suggestion! I ended up with doing a version of that: first do the request and save the value I’m interested in as a session variable via an optional check, and then do the same request again (this time without the optional in the check) inside a doIf that checks whether the session variable is set. Could probably use a repeat to get a configurable number of retries, but a single one is good enough for now =)

BR  
Magnus
