This is an automated email from the ASF dual-hosted git repository. av pushed a commit to branch ignite-ducktape in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/ignite-ducktape by this push: new 879fa1f Fail fast (#8147) 879fa1f is described below commit 879fa1f53d2f757059868cf21d9c9761ed49de19 Author: Anton Vinogradov <a...@apache.org> AuthorDate: Thu Aug 13 11:46:17 2020 +0300 Fail fast (#8147) --- .../ducktest/utils/IgniteAwareApplication.java | 55 ++++++++++++++++++---- .../ignitetest/services/utils/ignite_aware_app.py | 11 ++++- .../tests/ignitetest/tests/utils/ignite_test.py | 2 +- 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/utils/IgniteAwareApplication.java b/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/utils/IgniteAwareApplication.java index 7a173a5..5e610f1 100644 --- a/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/utils/IgniteAwareApplication.java +++ b/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/utils/IgniteAwareApplication.java @@ -37,6 +37,9 @@ public abstract class IgniteAwareApplication { /** App finished. */ private static final String APP_FINISHED = "IGNITE_APPLICATION_FINISHED"; + /** App broken. */ + private static final String APP_BROKEN = "IGNITE_APPLICATION_BROKEN"; + /** App terminated. */ private static final String APP_TERMINATED = "IGNITE_APPLICATION_TERMINATED"; @@ -46,9 +49,15 @@ public abstract class IgniteAwareApplication { /** Finished. */ private static volatile boolean finished; + /** Broken. */ + private static volatile boolean broken; + /** Terminated. */ private static volatile boolean terminated; + /** Shutdown hook. */ + private static volatile Thread hook; + /** Ignite. */ protected Ignite ignite; @@ -59,10 +68,15 @@ public abstract class IgniteAwareApplication { * Default constructor. */ protected IgniteAwareApplication() { - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - terminate(); + Runtime.getRuntime().addShutdownHook(hook = new Thread(() -> { + log.info("SIGTERM recorded."); - while (!finished()) { + if (!finished && !broken) + terminate(); + else + log.info("Application already done [finished=" + finished + ", broken=" + broken + "]"); + + while (!finished && !broken) { log.info("Waiting for graceful termnation."); try { @@ -72,8 +86,6 @@ public abstract class IgniteAwareApplication { e.printStackTrace(); } } - - log.info("SIGTERM recorded."); })); log.info("ShutdownHook registered."); @@ -95,25 +107,44 @@ public abstract class IgniteAwareApplication { */ protected void markFinished() { assert !finished; + assert !broken; log.info(APP_FINISHED); + removeShutdownHook(); + finished = true; } /** * */ - protected void markSyncExecutionComplete() { - markInitialized(); - markFinished(); + private void markBroken() { + assert !finished; + assert !broken; + + log.info(APP_BROKEN); + + removeShutdownHook(); + + broken = true; } /** * */ - private boolean finished() { - return finished; + private void removeShutdownHook() { + Runtime.getRuntime().removeShutdownHook(hook); + + log.info("Shutdown hook removed."); + } + + /** + * + */ + protected void markSyncExecutionComplete() { + markInitialized(); + markFinished(); } /** @@ -173,6 +204,10 @@ public abstract class IgniteAwareApplication { } catch (Throwable th) { log.error("Unexpected Application failure... ", th); + + recordResult("ERROR", th.getMessage()); + + markBroken(); } finally { log.info("Application finished."); diff --git a/modules/ducktests/tests/ignitetest/services/utils/ignite_aware_app.py b/modules/ducktests/tests/ignitetest/services/utils/ignite_aware_app.py index b05f5a1..29e0a2c 100644 --- a/modules/ducktests/tests/ignitetest/services/utils/ignite_aware_app.py +++ b/modules/ducktests/tests/ignitetest/services/utils/ignite_aware_app.py @@ -49,7 +49,13 @@ class IgniteAwareApplicationService(IgniteAwareService): self.logger.info("Waiting for Ignite aware Application (%s) to start..." % self.java_class_name) self.await_event("Topology snapshot", self.timeout_sec, from_the_beginning=True) - self.await_event("IGNITE_APPLICATION_INITIALIZED", self.timeout_sec, from_the_beginning=True) + self.await_event("IGNITE_APPLICATION_INITIALIZED\\|IGNITE_APPLICATION_BROKEN", self.timeout_sec, + from_the_beginning=True) + + try: + self.await_event("IGNITE_APPLICATION_INITIALIZED", 1, from_the_beginning=True) + except Exception: + raise Exception("Java application execution failed. %s" % self.extract_result("ERROR")) def start_cmd(self, node): cmd = self.env() @@ -70,7 +76,8 @@ class IgniteAwareApplicationService(IgniteAwareService): assert stopped, "Node %s: did not stop within the specified timeout of %s seconds" % \ (str(node.account), str(self.stop_timeout_sec)) - self.await_event("IGNITE_APPLICATION_FINISHED", from_the_beginning=True, timeout_sec=timeout_sec) + self.await_event("IGNITE_APPLICATION_FINISHED\\|IGNITE_APPLICATION_BROKEN", from_the_beginning=True, + timeout_sec=timeout_sec) def clean_node(self, node): if self.alive(node): diff --git a/modules/ducktests/tests/ignitetest/tests/utils/ignite_test.py b/modules/ducktests/tests/ignitetest/tests/utils/ignite_test.py index df0d30e..c0c35c7 100644 --- a/modules/ducktests/tests/ignitetest/tests/utils/ignite_test.py +++ b/modules/ducktests/tests/ignitetest/tests/utils/ignite_test.py @@ -34,7 +34,7 @@ class IgniteTest(Test): Print stage mark. :param msg: Stage mark message. """ - self.logger.info("[TEST_STAGE] " + msg + "...") + self.logger.info("[TEST_STAGE] " + msg) @staticmethod def monotonic():