On our Pipeline, Katalon Runtime Engine execution timeouts sometimes. I would like to allow KRE to be SIGTERMed gently (or KRE should understand any other signal from kill -l list, or have parameter with whole job timeout), allowing it to end execution of Test Cases as it and generate report of what actually have been done, do other necessary steps at the end like upload to TestOps.
Is it possible somehow? I tested SIGINT and SIGTERM without success.
not sure what do you mean by ‘KRE times-out’ but the actual issue seems to be with your testcases.
you should carefully inspect where it got stuck and handle that from the code you run.
that is the first problem to solve, doing a kill switch is also doable by why would you need that? kill -9 usually solves everything
Example. I have pipeline (on any CI/CD) with usage of official docker image with KRE. I execute test suite collection in that container.
Next, I get normal run of test cases, but sometimes I have a situation when execution blocks on random test case but I won’t get report as it would run infinitely, and be killed by 2h timeout (SIGABRT/aka kill -9)
not sure what do you mean by ‘KRE times-out’
You are right. I haven’t definied it. I have 2h (time boundary) for KRE execution to end. Not always, but sometimes KRE box slow down much and stop on one testcase.
To debug it, I would like to have Reports from machine even I need to stop (but gently) test suite (collection) execution. I do not care what is the progress, if it last more than 2h I need to stop execution and generate report. This is main point, I just want to have partial report for TestOps just in case whole run is not possible in specified timeframe.
Now, when I “kill switch” with -9 or -15 it works like -9, just stops execution, no report is generated or send to TestOps from what test cases executed already. -9 abort execution eventually. Other signals could be used by administrator to stop process gently, allowing it for example, to commit transaction, end processing in threads, not be killed and forgotten as with Abort signal.
I wonder if timeout of test suite/collection run (when it would do “final” steps like report generation and upload) could be feature for future, or if I could make my KRE to generate report before being killed.
Well, as far as I know, in the actual form KRE does not have such implemented.
But your request is leggit, I would like to see such “gracefull shutdown” implemented.
How to determine the timeout will be another storry.
The only thing you can do for now is to rise a feature-request on this matter.
If, when and how may be implemented … not even god knows.
kre does not catch SIGTERM, so the graceful part has to come from inside the project. two pieces that together give you a deadline with a report.
a watchdog that unsticks the hung test case. in a @BeforeTestSuite listener start a daemon thread that, once the budget is gone, quits the web driver. the stuck keyword then throws, the test case ends with an error, and the suite continues to its report.
and a guard that skips whatever is left. in @BeforeTestCase check the same clock and if the budget is gone call KeywordUtil.markErrorAndStop('suite deadline reached'). the remaining cases finish in a second each, marked error, and kre writes the report and does the testops upload as normal.
keep the budget comfortably under the pipeline timeout (100 min inside a 120 min job) so the kill -9 never fires. for mobile use MobileDriverFactory.getDriver() in the watchdog instead.
Good approach from @depapp. A few additions for the Test Suite Collection case:
@BeforeTestSuite fires for every suite in the collection, so set the start time only once (if suiteStart is still 0), otherwise the budget resets for each suite.
Log inside the watchdog thread. DriverFactory.getWebDriver() can return null from another thread, and the ?. plus empty catch would hide that. Capturing the driver reference from the test thread is safer.
If the hang is in an API or DB call, quitting the driver won’t help, so set explicit timeouts there.
Keep the budget well under the pipeline timeout so the report and TestOps upload finish before the hard kill.