This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new fdd73156dc Avoid hard coded use of localhost in Google cloud extension 
tests
fdd73156dc is described below

commit fdd73156dc7e653d4c38db010995204f512d6474
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Tue Feb 27 14:12:07 2024 +0000

    Avoid hard coded use of localhost in Google cloud extension tests
---
 .../quarkus/component/google/pubsub/it/GooglePubSubCustomizer.java | 2 +-
 .../quarkus/component/google/storage/it/GoogleStorageResource.java | 7 +++----
 .../component/google/storage/it/GoogleStorageTestResource.java     | 7 +++++--
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git 
a/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubCustomizer.java
 
b/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubCustomizer.java
index 7f42af04b5..b7f0a3625d 100644
--- 
a/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubCustomizer.java
+++ 
b/integration-tests/google-pubsub/src/test/java/org/apache/camel/quarkus/component/google/pubsub/it/GooglePubSubCustomizer.java
@@ -164,7 +164,7 @@ public class GooglePubSubCustomizer implements 
GoogleTestEnvCustomizer {
 
     private FixedTransportChannelProvider 
createChannelProvider(GoogleCloudContext context) {
         ManagedChannel channel = ManagedChannelBuilder
-                .forTarget(String.format("%s:%s", "localhost", 
container.getFirstMappedPort()))
+                .forTarget(String.format("%s:%s", container.getHost(), 
container.getFirstMappedPort()))
                 .usePlaintext()
                 .build();
 
diff --git 
a/integration-tests/google-storage/src/main/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageResource.java
 
b/integration-tests/google-storage/src/main/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageResource.java
index 23fa010661..edfb7d938a 100644
--- 
a/integration-tests/google-storage/src/main/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageResource.java
+++ 
b/integration-tests/google-storage/src/main/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageResource.java
@@ -59,8 +59,7 @@ public class GoogleStorageResource {
 
     public static final String DIRECT_POLLING = "direct:polling";
 
-    public static final String PARAM_PORT = 
"org.apache.camel.quarkus.component.googlr.storage.it.GoogleStorageClientProducer_port";
-
+    public static final String GOOGLE_STORAGE_URL_CONFIG_KEY = 
"google.storage.url";
     public static final String QUERY_OBJECT_NAME = "objectName";
     public static final String QUERY_BUCKET = "bucketName";
     public static final String QUERY_OPERATION = "operation";
@@ -78,9 +77,9 @@ public class GoogleStorageResource {
     Storage storageClient() throws IOException {
         Storage storage;
         if (GoogleStorageHelper.usingMockBackend()) {
-            String port = 
ConfigProvider.getConfig().getValue(GoogleStorageResource.PARAM_PORT, 
String.class);
+            String host = 
ConfigProvider.getConfig().getValue(GOOGLE_STORAGE_URL_CONFIG_KEY, 
String.class);
             storage = StorageOptions.newBuilder()
-                    .setHost("http://localhost:"; + port)
+                    .setHost(host)
                     .setProjectId("dummy-project-for-testing")
                     .build()
                     .getService();
diff --git 
a/integration-tests/google-storage/src/test/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageTestResource.java
 
b/integration-tests/google-storage/src/test/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageTestResource.java
index dbc6e09e14..3a22955f1e 100644
--- 
a/integration-tests/google-storage/src/test/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageTestResource.java
+++ 
b/integration-tests/google-storage/src/test/java/org/apache/camel/quarkus/component/google/storage/it/GoogleStorageTestResource.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
 import org.apache.camel.quarkus.test.AvailablePortFinder;
 import org.eclipse.microprofile.config.ConfigProvider;
+import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.FixedHostPortGenericContainer;
 import org.testcontainers.containers.GenericContainer;
 
@@ -39,13 +40,15 @@ public class GoogleStorageTestResource implements 
QuarkusTestResourceLifecycleMa
         Map<String, String> properties = new HashMap<>();
 
         if (GoogleStorageHelper.usingMockBackend()) {
+            String url = 
"http://%s:%s".formatted(DockerClientFactory.instance().dockerHostIpAddress(), 
PORT);
             container = new FixedHostPortGenericContainer<>(CONTAINER_NAME)
                     .withFixedExposedPort(PORT, PORT)
                     .withCreateContainerCmdModifier(
-                            it -> it.withEntrypoint("/bin/fake-gcs-server", 
"-scheme", "http", "-port", String.valueOf(PORT)));
+                            it -> it.withEntrypoint("/bin/fake-gcs-server", 
"-external-url", url, "-scheme", "http", "-port",
+                                    String.valueOf(PORT)));
             container.start();
 
-            properties.put(GoogleStorageResource.PARAM_PORT, 
String.valueOf(PORT));
+            
properties.put(GoogleStorageResource.GOOGLE_STORAGE_URL_CONFIG_KEY, url);
         }
 
         return properties;

Reply via email to