This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c6e1d553ab1 (chores) camel-test-infra-elasticsearch: retry the
container startup if it fails
c6e1d553ab1 is described below
commit c6e1d553ab1d1603bec39ddac590c3dc70e92c88
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Fri Jan 27 13:32:51 2023 +0100
(chores) camel-test-infra-elasticsearch: retry the container startup if it
fails
---
.../camel/test/infra/common/services/ContainerEnvironmentUtil.java | 7 +++++++
.../test/infra/elasticsearch/common/ElasticSearchProperties.java | 4 ++++
.../elasticsearch/services/ElasticSearchLocalContainerService.java | 4 ++++
3 files changed, 15 insertions(+)
diff --git
a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
index a5964bb041b..dbe6c58c666 100644
---
a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
+++
b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
@@ -20,8 +20,10 @@ package org.apache.camel.test.infra.common.services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;
+import org.testcontainers.containers.GenericContainer;
public final class ContainerEnvironmentUtil {
+ public static final String STARTUP_ATTEMPTS_PROPERTY = ".startup.attempts";
private static final Logger LOG =
LoggerFactory.getLogger(ContainerEnvironmentUtil.class);
private static boolean dockerAvailable;
@@ -49,4 +51,9 @@ public final class ContainerEnvironmentUtil {
return dockerAvailable;
}
+
+ public static void configureContainerStartup(GenericContainer<?>
container, String property, int defaultValue) {
+ int startupAttempts = Integer.valueOf(System.getProperty(property,
String.valueOf(defaultValue)));
+ container.setStartupAttempts(startupAttempts);
+ }
}
diff --git
a/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/common/ElasticSearchProperties.java
b/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/common/ElasticSearchProperties.java
index 04309f396ea..07a7bda5090 100644
---
a/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/common/ElasticSearchProperties.java
+++
b/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/common/ElasticSearchProperties.java
@@ -17,10 +17,14 @@
package org.apache.camel.test.infra.elasticsearch.common;
+import org.apache.camel.test.infra.common.services.ContainerEnvironmentUtil;
+
public final class ElasticSearchProperties {
public static final String ELASTIC_SEARCH_HOST = "elasticsearch.host";
public static final String ELASTIC_SEARCH_PORT = "elasticsearch.port";
public static final String ELASTIC_SEARCH_CONTAINER =
"elasticsearch.container";
+ public static final String ELASTIC_SEARCH_CONTAINER_STARTUP
+ = ELASTIC_SEARCH_CONTAINER +
ContainerEnvironmentUtil.STARTUP_ATTEMPTS_PROPERTY;
private ElasticSearchProperties() {
diff --git
a/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/services/ElasticSearchLocalContainerService.java
b/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/services/ElasticSearchLocalContainerService.java
index da5c1aaa152..6339b7f3d3b 100644
---
a/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/services/ElasticSearchLocalContainerService.java
+++
b/test-infra/camel-test-infra-elasticsearch/src/test/java/org/apache/camel/test/infra/elasticsearch/services/ElasticSearchLocalContainerService.java
@@ -17,6 +17,7 @@
package org.apache.camel.test.infra.elasticsearch.services;
+import org.apache.camel.test.infra.common.services.ContainerEnvironmentUtil;
import org.apache.camel.test.infra.common.services.ContainerService;
import
org.apache.camel.test.infra.elasticsearch.common.ElasticSearchProperties;
import org.slf4j.Logger;
@@ -71,6 +72,9 @@ public class ElasticSearchLocalContainerService implements
ElasticSearchService,
@Override
public void initialize() {
LOG.info("Trying to start the ElasticSearch container");
+ ContainerEnvironmentUtil.configureContainerStartup(container,
ElasticSearchProperties.ELASTIC_SEARCH_CONTAINER_STARTUP,
+ 2);
+
container.start();
registerProperties();