Camel CLI Infra run - use the default port for custom implementations
diff --git a/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureInfraService.java b/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureInfraService.java
index 942ebc0..0f4e7fa 100644
--- a/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureInfraService.java
+++ b/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureInfraService.java
@@ -28,4 +28,16 @@
* @return
*/
AzureCredentialsHolder azureCredentials();
+
+ String accountName();
+
+ String accessKey();
+
+ String host();
+
+ int port();
+
+ default String credentialType() {
+ return "SHARED_KEY_CREDENTIAL";
+ }
}
diff --git a/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureStorageInfraService.java b/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureStorageInfraService.java
index 9576b26..67b16f3 100644
--- a/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureStorageInfraService.java
+++ b/test-infra/camel-test-infra-azure-common/src/main/java/org/apache/camel/test/infra/azure/common/services/AzureStorageInfraService.java
@@ -46,7 +46,7 @@
}
protected AzuriteContainer initContainer(String imageName) {
- return new AzuriteContainer(imageName, ContainerEnvironmentUtil.isFixedPort(this.getClass()));
+ return new AzuriteContainer(imageName, ContainerEnvironmentUtil.isFixedPort(this.getClass().getSuperclass()));
}
public AzuriteContainer getContainer() {
diff --git a/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobLocalContainerInfraService.java b/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobLocalContainerInfraService.java
index 42f077c..93b4827 100644
--- a/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobLocalContainerInfraService.java
+++ b/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobLocalContainerInfraService.java
@@ -40,4 +40,24 @@
public AzureCredentialsHolder azureCredentials() {
return getContainer().azureCredentials();
}
+
+ @Override
+ public String host() {
+ return getContainer().getHost();
+ }
+
+ @Override
+ public int port() {
+ return getContainer().getMappedPort(AzureServices.BLOB_SERVICE);
+ }
+
+ @Override
+ public String accountName() {
+ return getContainer().azureCredentials().accountName();
+ }
+
+ @Override
+ public String accessKey() {
+ return getContainer().azureCredentials().accountKey();
+ }
}
diff --git a/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobRemoteInfraService.java b/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobRemoteInfraService.java
index 943fb1d..e1b942e 100644
--- a/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobRemoteInfraService.java
+++ b/test-infra/camel-test-infra-azure-storage-blob/src/main/java/org/apache/camel/test/infra/azure/storage/blob/services/AzureStorageBlobRemoteInfraService.java
@@ -53,4 +53,24 @@
}
};
}
+
+ @Override
+ public String host() {
+ return System.getProperty(AzureConfigs.HOST);
+ }
+
+ @Override
+ public int port() {
+ return Integer.valueOf(System.getProperty(AzureConfigs.PORT));
+ }
+
+ @Override
+ public String accountName() {
+ return System.getProperty(AzureConfigs.ACCOUNT_NAME);
+ }
+
+ @Override
+ public String accessKey() {
+ return System.getProperty(AzureConfigs.ACCOUNT_KEY);
+ }
}
diff --git a/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeRemoteInfraService.java b/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeRemoteInfraService.java
index b5721ce..c9736aa 100644
--- a/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeRemoteInfraService.java
+++ b/test-infra/camel-test-infra-azure-storage-datalake/src/main/java/org/apache/camel/test/infra/azure/storage/datalake/services/AzureStorageDataLakeRemoteInfraService.java
@@ -51,4 +51,24 @@
public void shutdown() {
}
+
+ @Override
+ public String host() {
+ return System.getProperty(AzureConfigs.HOST);
+ }
+
+ @Override
+ public int port() {
+ return Integer.valueOf(System.getProperty(AzureConfigs.PORT));
+ }
+
+ @Override
+ public String accountName() {
+ return System.getProperty(AzureConfigs.ACCOUNT_NAME);
+ }
+
+ @Override
+ public String accessKey() {
+ return System.getProperty(AzureConfigs.ACCOUNT_KEY);
+ }
}
diff --git a/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueInfraService.java b/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueInfraService.java
index 08b8e12..f0c62b6 100644
--- a/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueInfraService.java
+++ b/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueInfraService.java
@@ -53,4 +53,24 @@
}
};
}
+
+ @Override
+ public String host() {
+ return System.getProperty(AzureConfigs.HOST);
+ }
+
+ @Override
+ public int port() {
+ return Integer.valueOf(System.getProperty(AzureConfigs.PORT));
+ }
+
+ @Override
+ public String accountName() {
+ return System.getProperty(AzureConfigs.ACCOUNT_NAME);
+ }
+
+ @Override
+ public String accessKey() {
+ return System.getProperty(AzureConfigs.ACCOUNT_KEY);
+ }
}
diff --git a/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueLocalContainerInfraService.java b/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueLocalContainerInfraService.java
index 49d1c20..6080197 100644
--- a/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueLocalContainerInfraService.java
+++ b/test-infra/camel-test-infra-azure-storage-queue/src/main/java/org/apache/camel/test/infra/azure/storage/queue/services/AzureStorageQueueLocalContainerInfraService.java
@@ -40,4 +40,24 @@
public AzureCredentialsHolder azureCredentials() {
return getContainer().azureCredentials();
}
+
+ @Override
+ public String host() {
+ return getContainer().getHost();
+ }
+
+ @Override
+ public int port() {
+ return getContainer().getMappedPort(AzureServices.QUEUE_SERVICE);
+ }
+
+ @Override
+ public String accountName() {
+ return getContainer().azureCredentials().accountName();
+ }
+
+ @Override
+ public String accessKey() {
+ return getContainer().azureCredentials().accountKey();
+ }
}
diff --git a/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraLocalContainerInfraService.java b/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraLocalContainerInfraService.java
index 9379a16..7de7030 100644
--- a/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraLocalContainerInfraService.java
+++ b/test-infra/camel-test-infra-cassandra/src/main/java/org/apache/camel/test/infra/cassandra/services/CassandraLocalContainerInfraService.java
@@ -56,7 +56,19 @@
}
protected CassandraContainer initContainer(String imageName) {
- return new CassandraContainer(DockerImageName.parse(imageName).asCompatibleSubstituteFor("cassandra"));
+ class CassandraContainerWithFixedPort extends CassandraContainer {
+ public CassandraContainerWithFixedPort(boolean fixedPort) {
+ super(DockerImageName.parse(imageName).asCompatibleSubstituteFor("cassandra"));
+
+ if (fixedPort) {
+ addFixedExposedPort(9042, 9042);
+ } else {
+ withExposedPorts(9042);
+ }
+ }
+ }
+
+ return new CassandraContainerWithFixedPort(ContainerEnvironmentUtil.isFixedPort(this.getClass()));
}
@Override
diff --git a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
index f143fd4..3001e17 100644
--- a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
+++ b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
@@ -58,13 +58,26 @@
container.setStartupAttempts(startupAttempts);
}
+ /**
+ * Determines if a service class should use fixed ports (for Camel JBang compatibility) or random ports (for
+ * testcontainer isolation).
+ *
+ * Services implementing an interface with "InfraService" in the name are considered to be intended for use with
+ * Camel JBang and will use fixed default ports.
+ *
+ * @param cls the service class to check
+ * @return true if the service should use fixed ports, false for random ports
+ */
public static boolean isFixedPort(@SuppressWarnings("rawtypes") Class cls) {
for (Class<?> i : cls.getInterfaces()) {
if (i.getName().contains("InfraService")) {
+ LOG.debug("Service {} will use fixed ports (detected InfraService interface: {})",
+ cls.getSimpleName(), i.getSimpleName());
return true;
}
}
+ LOG.debug("Service {} will use random ports (no InfraService interface detected)", cls.getSimpleName());
return false;
}
diff --git a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ConfluentInfraService.java b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ConfluentInfraService.java
index 26a2987..49c765a 100644
--- a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ConfluentInfraService.java
+++ b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ConfluentInfraService.java
@@ -19,6 +19,7 @@
import org.apache.camel.spi.annotations.InfraService;
import org.apache.camel.test.infra.common.TestUtils;
+import org.apache.camel.test.infra.common.services.ContainerEnvironmentUtil;
import org.apache.camel.test.infra.common.services.ContainerService;
import org.apache.camel.test.infra.kafka.common.KafkaProperties;
import org.slf4j.Logger;
@@ -47,7 +48,17 @@
}
protected ConfluentContainer initConfluentContainer(Network network, String instanceName) {
- return new ConfluentContainer(network, instanceName);
+ class TestInfraConfluentContainer extends ConfluentContainer {
+ public TestInfraConfluentContainer(Network network, String name, boolean fixedPort) {
+ super(network, name);
+
+ if (fixedPort) {
+ addFixedExposedPort(9092, 9092);
+ }
+ }
+ }
+
+ return new TestInfraConfluentContainer(network, instanceName, ContainerEnvironmentUtil.isFixedPort(this.getClass()));
}
protected Integer getKafkaPort() {
diff --git a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ContainerLocalKafkaInfraService.java b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ContainerLocalKafkaInfraService.java
index b4646c7..f9abeb7 100644
--- a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ContainerLocalKafkaInfraService.java
+++ b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/ContainerLocalKafkaInfraService.java
@@ -63,6 +63,7 @@
if (fixedPort) {
addFixedExposedPort(9092, 9092);
}
+ // For random ports, testcontainers will handle port mapping automatically
}
}
diff --git a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/RedpandaInfraService.java b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/RedpandaInfraService.java
index 674f5b4..7737900 100644
--- a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/RedpandaInfraService.java
+++ b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/RedpandaInfraService.java
@@ -53,7 +53,17 @@
}
protected RedpandaContainer initRedpandaContainer(Network network, String instanceName) {
- return new RedpandaTransactionsEnabledContainer(RedpandaTransactionsEnabledContainer.REDPANDA_CONTAINER);
+ class TestInfraRedpandaContainer extends RedpandaTransactionsEnabledContainer {
+ public TestInfraRedpandaContainer(boolean fixedPort) {
+ super(RedpandaTransactionsEnabledContainer.REDPANDA_CONTAINER);
+
+ if (fixedPort) {
+ addFixedExposedPort(9092, 9092);
+ }
+ }
+ }
+
+ return new TestInfraRedpandaContainer(ContainerEnvironmentUtil.isFixedPort(this.getClass()));
}
protected Integer getKafkaPort() {
diff --git a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/StrimziInfraService.java b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/StrimziInfraService.java
index 2209dd2..1dca08f 100644
--- a/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/StrimziInfraService.java
+++ b/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/StrimziInfraService.java
@@ -57,11 +57,32 @@
}
protected StrimziContainer initStrimziContainer(Network network, String instanceName, String zookeeperInstanceName) {
- return new StrimziContainer(network, instanceName, zookeeperInstanceName);
+ class TestInfraStrimziContainer extends StrimziContainer {
+ public TestInfraStrimziContainer(Network network, String name, String zookeeperInstanceName, boolean fixedPort) {
+ super(network, name, zookeeperInstanceName);
+
+ if (fixedPort) {
+ addFixedExposedPort(9092, 9092);
+ }
+ }
+ }
+
+ return new TestInfraStrimziContainer(
+ network, instanceName, zookeeperInstanceName, ContainerEnvironmentUtil.isFixedPort(this.getClass()));
}
protected ZookeeperContainer initZookeeperContainer(Network network, String instanceName) {
- return new ZookeeperContainer(network, instanceName);
+ class TestInfraZookeeperContainer extends ZookeeperContainer {
+ public TestInfraZookeeperContainer(Network network, String name, boolean fixedPort) {
+ super(network, name);
+
+ if (fixedPort) {
+ addFixedExposedPort(2181, 2181);
+ }
+ }
+ }
+
+ return new TestInfraZookeeperContainer(network, instanceName, ContainerEnvironmentUtil.isFixedPort(this.getClass()));
}
protected Integer getKafkaPort() {