This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch camel-4.4.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit d600230e058ec36b08b0089a6bf40540506f5cb0 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Mon Jan 6 13:22:41 2025 +0000 CAMEL-21585: resolve platform containers automatically --- .../test/infra/common/LocalPropertyResolver.java | 19 +++++++++++++++++++ .../services/OpenSearchLocalContainerService.java | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java index 884a5f478fe..3d5fa1d440c 100644 --- a/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java +++ b/test-infra/camel-test-infra-common/src/test/java/org/apache/camel/test/infra/common/LocalPropertyResolver.java @@ -24,6 +24,12 @@ public class LocalPropertyResolver { public static final String CONTAINER_PROPERTIES_FILE_NAME = "container.properties"; + /** + * Resolves the container to use. Platform-specific containers are resolved automatically + * + * @param propertyName The property name pointing to the container + * @return + */ public static String getProperty(Class<?> clazz, String propertyName) { return System.getProperty(propertyName, getPropertyFromContainersPropertiesFile(clazz, propertyName)); } @@ -39,6 +45,19 @@ public class LocalPropertyResolver { throw new RuntimeException(errorMessage, e); } + return resolveProperty(properties, propertyName); + } + + private static String resolveProperty(Properties properties, String propertyName) { + // This should append the 'os.arch' version to the property (typically, one of amd64, aarch64, ppc64le or s390x) + String platformProperty = String.format("%s.%s", propertyName, System.getProperty("os.arch")); + + // Platform properties take precedence + String value = properties.getProperty(platformProperty); + if (value != null && !value.isEmpty()) { + return value; + } + return properties.getProperty(propertyName); } diff --git a/test-infra/camel-test-infra-opensearch/src/test/java/org/apache/camel/test/infra/opensearch/services/OpenSearchLocalContainerService.java b/test-infra/camel-test-infra-opensearch/src/test/java/org/apache/camel/test/infra/opensearch/services/OpenSearchLocalContainerService.java index f572c629355..b0ae96a116c 100644 --- a/test-infra/camel-test-infra-opensearch/src/test/java/org/apache/camel/test/infra/opensearch/services/OpenSearchLocalContainerService.java +++ b/test-infra/camel-test-infra-opensearch/src/test/java/org/apache/camel/test/infra/opensearch/services/OpenSearchLocalContainerService.java @@ -28,6 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; +import org.testcontainers.utility.DockerImageName; public class OpenSearchLocalContainerService implements OpenSearchService, ContainerService<OpensearchContainer> { private static final Logger LOG = LoggerFactory.getLogger(OpenSearchLocalContainerService.class); @@ -50,7 +51,7 @@ public class OpenSearchLocalContainerService implements OpenSearchService, Conta } protected OpensearchContainer initContainer(String imageName) { - OpensearchContainer opensearchContainer = new OpensearchContainer(imageName); + OpensearchContainer opensearchContainer = new OpensearchContainer(DockerImageName.parse(imageName)); // Increase the timeout from 60 seconds to 90 seconds to ensure that it will be long enough // on the build pipeline opensearchContainer.setWaitStrategy(