You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2021/04/27 14:59:27 UTC

[camel-quarkus] branch main updated: #2490 fix camel-quarkus-hbase-integration-test

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

ppalaga 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 8ce4b46  #2490 fix camel-quarkus-hbase-integration-test
8ce4b46 is described below

commit 8ce4b466fde503c5485e26a3efa36b0c2aa982b6
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Apr 22 19:12:07 2021 -0400

    #2490 fix camel-quarkus-hbase-integration-test
---
 .../component/hbase/it/HBaseTestResource.java      | 25 +++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/extensions-jvm/hbase/integration-test/src/test/java/org/apache/camel/quarkus/component/hbase/it/HBaseTestResource.java b/extensions-jvm/hbase/integration-test/src/test/java/org/apache/camel/quarkus/component/hbase/it/HBaseTestResource.java
index fc7c27a..375c264 100644
--- a/extensions-jvm/hbase/integration-test/src/test/java/org/apache/camel/quarkus/component/hbase/it/HBaseTestResource.java
+++ b/extensions-jvm/hbase/integration-test/src/test/java/org/apache/camel/quarkus/component/hbase/it/HBaseTestResource.java
@@ -16,9 +16,15 @@
  */
 package org.apache.camel.quarkus.component.hbase.it;
 
+import java.net.InetAddress;
 import java.util.Collections;
 import java.util.Map;
+import java.util.function.Consumer;
 
+import com.github.dockerjava.api.command.CreateContainerCmd;
+import com.github.dockerjava.api.model.ExposedPort;
+import com.github.dockerjava.api.model.PortBinding;
+import com.github.dockerjava.api.model.Ports;
 import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
 import org.jboss.logging.Logger;
 import org.testcontainers.containers.GenericContainer;
@@ -35,12 +41,21 @@ public class HBaseTestResource implements QuarkusTestResourceLifecycleManager {
     public Map<String, String> start() {
 
         try {
-            //there is only one tag for this docker image -  latest. See https://hub.docker.com/r/dajobe/hbase/tags
-            //Hbase is using zookeeper. Hbase client gets location of hbase master from zookeeper, which means that
-            //location uses internal hostnames from the docker.  Network mode `host` is the only way how to avoid
-            //manipulation with the hosts configuration at the test server.
+            String hostname = InetAddress.getLocalHost().getHostName();
+            Consumer<CreateContainerCmd> cmd = e -> {
+                e
+                        .withPortBindings(new PortBinding(Ports.Binding.bindPort(2181),
+                                new ExposedPort(2181)),
+                                new PortBinding(Ports.Binding.bindPort(16000),
+                                        new ExposedPort(16000)),
+                                new PortBinding(Ports.Binding.bindPort(16020),
+                                        new ExposedPort(16020)));
+                e.withHostName(hostname);
+            };
+
             container = new GenericContainer<>("dajobe/hbase:latest")
-                    .withNetworkMode("host")
+                    .withExposedPorts(2181, 16000, 16020)
+                    .withCreateContainerCmdModifier(cmd)
                     .withLogConsumer(frame -> System.out.print(frame.getUtf8String()))
                     .waitingFor(
                             Wait.forLogMessage(".*Finished refreshing block distribution cache for 2 regions\\n", 1));