Is there a way of aborting a gatling test when there are too many KOs?

Is there a way to do this? Reason is because, if there are too many KOs I want the test to stop automatically so as not to keep hitting my infrastructure with requests. I want my test to run overnight for 12 hours so I won’t be around to watch it all the time :wink:
During the gatling run, the console outputs the current Global information: number of OKs and number of KOs, so I would’ve thought this information can be retrieved in code, and hence the test can be stopped if a percentage of KOs exceeds a limit. But I haven’t found a way to get this information in code and to abort a test.


I do not know if it would be the most efficient way, but You could insert a counter and increment it in case of failure. When it will reach some particular number you will stop the simulation.

Hi Oswald,

Not implemented yet, sorry.


Ok, thanks for letting me know.

It would be a nice feature though!

I agree.

It’s always the same time/money/priorities mantra…

If you are willing to go outside of Gatling a little bit, you can make it work. You start the process, and then have a script (perl, python, sed) which reads and counts the KO count in the simulation log, and creates a file if it is over some threshold. Then in your simulation, exit if said file exists. You could then use the existence of that file as a manual terminate flag. It’s a kludge, but it moves the bulk of the work outside of the Gatling process, so it should not impact performance of the test.