Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Fix #90: Integrations tests not working on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreZ committed Feb 9, 2020
1 parent df4d3f9 commit 5406c56
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/test/java/io/streamnative/kop/KafkaIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
*/
package io.streamnative.kop;

import static io.streamnative.kop.KafkaProtocolHandler.PLAINTEXT_PREFIX;
import static io.streamnative.kop.KafkaProtocolHandler.SSL_PREFIX;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;

import com.google.common.collect.Sets;
import java.net.InetAddress;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -112,8 +115,18 @@ private static void checkForErrorsInLogs(final String logs) {
protected void setup() throws Exception {

super.resetConfig();
// in order to access PulsarBroker when using Docker for Mac, we need to adjust things:
// - set pulsar advertized address to host IP
// - use the `host.testcontainers.internal` address exposed by testcontainers
String ip = InetAddress.getLocalHost().getHostAddress();
System.out.println("exposing Pulsar broker on " + ip);
super.conf.setAdvertisedAddress(ip);
this.conf.setListeners(
PLAINTEXT_PREFIX + ip + ":" + kafkaBrokerPort + ","
+ SSL_PREFIX + ip + ":" + kafkaBrokerPortTls);
super.internalSetup();


if (!this.admin.clusters().getClusters().contains(this.configClusterName)) {
// so that clients can test short names
this.admin.clusters().createCluster(this.configClusterName,
Expand Down Expand Up @@ -156,7 +169,7 @@ void simpleProduceAndConsume(final String integration, final Optional<String> to
System.out.println("topic created");

final GenericContainer producer = new GenericContainer<>("streamnative/kop-test-" + integration)
.withEnv("KOP_BROKER", "localhost:" + super.kafkaBrokerPort)
.withEnv("KOP_BROKER", "host.testcontainers.internal:" + super.kafkaBrokerPort)
.withEnv("KOP_PRODUCE", "true")
.withEnv("KOP_TOPIC", topic.orElse(integration))
.withEnv("KOP_LIMIT", "10")
Expand All @@ -165,7 +178,7 @@ void simpleProduceAndConsume(final String integration, final Optional<String> to
.withNetworkMode("host");

final GenericContainer consumer = new GenericContainer<>("streamnative/kop-test-" + integration)
.withEnv("KOP_BROKER", "localhost:" + super.kafkaBrokerPort)
.withEnv("KOP_BROKER", "host.testcontainers.internal:" + super.kafkaBrokerPort)
.withEnv("KOP_TOPIC", topic.orElse(integration))
.withEnv("KOP_CONSUME", "true")
.withEnv("KOP_LIMIT", "10")
Expand Down

0 comments on commit 5406c56

Please sign in to comment.