tryMax logging

Just to cross check my understanding of tryMax functionality. Are we going to mark the request as failed only if all the attempts are failed under tryMax loop? Or Are we going to mark the request as failed for every attempt?

I am trying to implement tryMax function in my code and have been noticing that failure attempts are also being logged under “KO” section even if the request would have passed in different attempt. I mean if the request is passed in 4th attempt but all the previous 3 attempts are being logged under “KO” section which is misleading the overall error rate and creating unnecessary havoc.

Please correct me if i am missing anything here. Thanks a lot in advance for looking into this.

Just to cross check my understanding of tryMax functionality. Are we going
to mark the request as failed only if all the attempts are failed under
tryMax loop? Or Are we going to mark the request as failed for every
attempt?

The former

I am trying to implement tryMax function in my code and have been noticing
that failure attempts are also being logged under "KO" section even if the
request would have passed in different attempt. I mean if the request is
passed in 4th attempt but all the previous 3 attempts are being logged
under "KO" section which is misleading the overall error rate and creating
unnecessary havoc.

Please provide a reproducer

Hi Stephane,
I have included “tryMax” function in my code to handle the reattempt logic of Business usecase. I was expecting that it will be logging the failure after all attempts but it is logging failure under “KO” section for each attempt which is misleading the error count.

Please find the below sample code and logsnippet:

tryMax(5) {
.exec {
http(“Usecase1_Phone3”)
.get( “”“https://service3.test.com/phone/${id}”"")
.header(“X-B3-TraceId”, “Phone3_${getTime}”)
.headers(headers_common)
.check(status.is(200))
}

}

Which version do you use?

Version is 2.1.7.

Oh, right.

Yes, that’s the expected behavior.

If “failures” are expected, use a check with an optional criterion, and loop until the data could be saved.

Hi Stephane,
Let me explain application flow… whenever the app didn’t receive success status for the request, it attempts for 5 times and then only it will return the request as “Failed”. So, I have included tryMax function to handle this usecase. We are expecting to log the request as failed only after all attempts are completed but it is logging for every attempt. We need to the log the request status after all attempts incase of failures.Hope it is clear.

Can you please let me know if we have any other function/approach to handle this usecase?

Regards
TK

Can you please let me know if we have any ways to handle this usecase?

More detailed answer:

  • loop “asLongAs” some data “notExists()” + force the loop counter name to be able to determine if the iteration is the last attempt
  • on last attempt, use a check with “exist”, otherwise “optional”

Stephane

This is a lot of manual error handling. It would be really nice if TryMax had an option only log 1 KO if it was not able to be successful at all.

Contributions welcome!