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

Fix #90: Integrations tests not working on OSX #92

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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