Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Pulsar Container #858

Merged
merged 1 commit into from
Sep 13, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,33 @@
import org.testcontainers.utility.TestcontainersConfiguration;

/**
* This container wraps Apache pulsar running in stanalone mode
* This container wraps Apache Pulsar running in standalone mode
*/
public class PulsarContainer extends GenericContainer<PulsarContainer> {

public static final int PULSAR_PORT = 6850;
public static final int BROKER_PORT = 6650;
public static final int BROKER_HTTP_PORT = 8080;
public static final String METRICS_ENDPOINT = "/metrics";

private static final String PULSAR_VERSION = "2.1.0-incubating";

public PulsarContainer() {
this("2.1.0-incubating");
this(PULSAR_VERSION);
}

public PulsarContainer(String pulsarVersion) {
super(TestcontainersConfiguration.getInstance().getPulsarImage() + ":" + pulsarVersion);
withExposedPorts(PULSAR_PORT);
withCommand("/bin/bash", "-c", "" +
"servicePort=6850 webServicePort=8280 webServicePortTls=8643 bin/apply-config-from-env.py conf/proxy.conf && " +
"bin/pulsar standalone & " +
"bin/pulsar proxy --zookeeper-servers localhost:2181 --global-zookeeper-servers localhost:2181"
);

waitingFor(Wait.forLogMessage(".*messaging service is ready.*\\s", 1));
withExposedPorts(BROKER_PORT, BROKER_HTTP_PORT);
withCommand("/pulsar/bin/pulsar", "standalone", "--no-functions-worker", "-nss");
waitingFor(Wait.forHttp(METRICS_ENDPOINT).forStatusCode(200).forPort(BROKER_HTTP_PORT));
}

public String getPulsarBrokerUrl() {
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getFirstMappedPort());
return String.format("pulsar://%s:%s", getContainerIpAddress(), getMappedPort(BROKER_PORT));
}

public String getHttpServiceUrl() {
return String.format("http://%s:%s", getContainerIpAddress(), getMappedPort(BROKER_HTTP_PORT));
}
}