You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by di...@apache.org on 2022/12/14 15:58:22 UTC
[oozie] branch master updated: OOZIE-3688 Introduce retry mechanism when starting embedded servlet containers in unit tests (jmakai via dionusos)
This is an automated email from the ASF dual-hosted git repository.
dionusos pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/oozie.git
The following commit(s) were added to refs/heads/master by this push:
new e78ffb563 OOZIE-3688 Introduce retry mechanism when starting embedded servlet containers in unit tests (jmakai via dionusos)
e78ffb563 is described below
commit e78ffb56310f4bee7ac053a448b2f25437f22321
Author: Denes Bodo <di...@apache.org>
AuthorDate: Wed Dec 14 16:52:59 2022 +0100
OOZIE-3688 Introduce retry mechanism when starting embedded servlet containers in unit tests (jmakai via dionusos)
---
.../oozie/test/EmbeddedServletContainer.java | 29 ++++++++++++++++++----
release-log.txt | 1 +
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java b/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java
index 2fb099f7d..132a69ec9 100644
--- a/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java
+++ b/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java
@@ -49,6 +49,9 @@ public class EmbeddedServletContainer {
private String contextPath;
private ServletContextHandler context;
+ private static final int CONTAINER_START_DEFAULT_RETRIES = 30;
+ private static final long CONTAINER_START_DEFAULT_WAIT_BETWEEN_RETRIES_IN_SECS = 1;
+
/**
* Create a servlet container.
*
@@ -121,14 +124,30 @@ public class EmbeddedServletContainer {
}
/**
- * Start the servlet container. <p> The container starts on a free port or a specific port.
+ * Start the servlet container with retry mechanism. The default retry attempts are 30 with wait times of 30 seconds
+ * in between. The container starts on a free port or a specific port.
*
- * @throws Exception thrown if the container could not start.
+ * @throws Exception thrown if the container could not start after `retries` number of tries.
*/
public void start() throws Exception {
- host = InetAddress.getLocalHost().getHostName();
- port = startServerWithPort(port);
- System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
+ for (int i = 0; i <= CONTAINER_START_DEFAULT_RETRIES; i++) {
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ port = startServerWithPort(port);
+ System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
+ break;
+ } catch (Exception ex) {
+ System.err.println("An exception is thrown while starting embedded servlet container at port: "
+ + port + ". Exception:\n" + ex.getMessage());
+
+ // throw exception if the last re-try fails
+ if (i >= CONTAINER_START_DEFAULT_RETRIES) {
+ throw ex;
+ }
+
+ Thread.sleep(CONTAINER_START_DEFAULT_WAIT_BETWEEN_RETRIES_IN_SECS * 1000);
+ }
+ }
}
/**
diff --git a/release-log.txt b/release-log.txt
index 15f3e58ff..8f067d7ad 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 5.3.0 release (trunk - unreleased)
+OOZIE-3688 Introduce retry mechanism when starting embedded servlet containers in unit tests (jmakai via dionusos)
OOZIE-3685 Repair flaky testCoordActionInputCheckXCommandUniqueness unit test (jmakai via dionusos)
OOZIE-3686 Repair flaky testRetryConsoleUrlForked unit test (jmakai via dionusos)
OOZIE-3684 Migrate to commons-lang3 again (jmakai via dionusos)