This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.14.x by this push:
new dc410dffb03 Camel CLI Infra run - use the default port for custom
implementations
dc410dffb03 is described below
commit dc410dffb031c31895da0e7f61ec81ea4b62eace
Author: Croway <[email protected]>
AuthorDate: Mon Sep 22 15:48:08 2025 +0200
Camel CLI Infra run - use the default port for custom implementations
---
.../azure/common/services/AzureInfraService.java | 12 +++++++++++
.../common/services/AzureStorageInfraService.java | 2 +-
...AzureStorageBlobLocalContainerInfraService.java | 20 +++++++++++++++++
.../AzureStorageBlobRemoteInfraService.java | 20 +++++++++++++++++
.../AzureStorageDataLakeRemoteInfraService.java | 20 +++++++++++++++++
.../services/AzureStorageQueueInfraService.java | 20 +++++++++++++++++
...zureStorageQueueLocalContainerInfraService.java | 20 +++++++++++++++++
.../CassandraLocalContainerInfraService.java | 14 +++++++++++-
.../common/services/ContainerEnvironmentUtil.java | 13 +++++++++++
.../kafka/services/ConfluentInfraService.java | 13 ++++++++++-
.../services/ContainerLocalKafkaInfraService.java | 1 +
.../infra/kafka/services/RedpandaInfraService.java | 12 ++++++++++-
.../infra/kafka/services/StrimziInfraService.java | 25 ++++++++++++++++++++--
13 files changed, 186 insertions(+), 6 deletions(-)
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 942ebc062d0..0f4e7fae3bc 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 @@ public interface AzureInfraService extends
InfrastructureService {
* @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 9576b26b9b9..67b16f3afa9 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 @@ public abstract class AzureStorageInfraService implements
AzureInfraService, Con
}
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 42f077c7773..93b4827271a 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 class AzureStorageBlobLocalContainerInfraService
extends AzureStorageInfr
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 943fb1dc398..e1b942efaa9 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 @@ public class AzureStorageBlobRemoteInfraService implements
AzureInfraService {
}
};
}
+
+ @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 b5721ce5d03..c9736aa4d8f 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 class AzureStorageDataLakeRemoteInfraService
implements AzureInfraService
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 08b8e12fa99..f0c62b6a191 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 @@ public class AzureStorageQueueInfraService implements
AzureInfraService {
}
};
}
+
+ @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 49d1c206039..60801978fd1 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 class AzureStorageQueueLocalContainerInfraService
extends AzureStorageInf
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 9379a167f3a..7de7030f1dc 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 @@ public class CassandraLocalContainerInfraService implements
CassandraInfraServic
}
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 f143fd4468d..3001e17375f 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 @@ public final class ContainerEnvironmentUtil {
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 26a29879d30..49c765a1a5d 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 @@ package org.apache.camel.test.infra.kafka.services;
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 @@ public class ConfluentInfraService implements
KafkaInfraService, ContainerServic
}
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 b4646c70b2f..f9abeb77ef5 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 @@ public class ContainerLocalKafkaInfraService implements
KafkaInfraService, Conta
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 674f5b4d105..773790041dc 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 @@ public class RedpandaInfraService implements
KafkaInfraService, ContainerService
}
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 2209dd2ac99..1dca08f1861 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 @@ public class StrimziInfraService implements
KafkaInfraService, ContainerService<
}
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() {