Skip to content

Commit 45e6860

Browse files
committed
Update Pulsar Container
1 parent 2957046 commit 45e6860

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

modules/pulsar/src/main/java/org/testcontainers/containers/PulsarContainer.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,33 @@
44
import org.testcontainers.utility.TestcontainersConfiguration;
55

66
/**
7-
* This container wraps Apache pulsar running in stanalone mode
7+
* This container wraps Apache Pulsar running in standalone mode
88
*/
99
public class PulsarContainer extends GenericContainer<PulsarContainer> {
1010

11-
public static final int PULSAR_PORT = 6850;
11+
public static final int BROKER_PORT = 6650;
12+
public static final int BROKER_HTTP_PORT = 8080;
13+
public static final String METRICS_ENDPOINT = "/metrics";
14+
15+
private static final String PULSAR_VERSION = "2.1.0-incubating";
1216

1317
public PulsarContainer() {
14-
this("2.1.0-incubating");
18+
this(PULSAR_VERSION);
1519
}
1620

1721
public PulsarContainer(String pulsarVersion) {
1822
super(TestcontainersConfiguration.getInstance().getPulsarImage() + ":" + pulsarVersion);
19-
withExposedPorts(PULSAR_PORT);
20-
withCommand("/bin/bash", "-c", "" +
21-
"servicePort=6850 webServicePort=8280 webServicePortTls=8643 bin/apply-config-from-env.py conf/proxy.conf && " +
22-
"bin/pulsar standalone & " +
23-
"bin/pulsar proxy --zookeeper-servers localhost:2181 --global-zookeeper-servers localhost:2181"
24-
);
25-
26-
waitingFor(Wait.forLogMessage(".*messaging service is ready.*\\s", 1));
23+
withExposedPorts(BROKER_HTTP_PORT, BROKER_PORT);
24+
withCommand("/bin/bash", "-c", "/pulsar/bin/pulsar standalone --no-functions-worker -nss");
25+
waitingFor(Wait.forHttp(METRICS_ENDPOINT).forStatusCode(200));
2726
}
2827

2928
public String getPulsarBrokerUrl() {
30-
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getFirstMappedPort());
29+
return String.format("pulsar://%s:%s", getContainerIpAddress(), getMappedPort(BROKER_PORT));
3130
}
3231

32+
public String getHttpServiceUrl() {
33+
return String.format("http://%s:%s", getContainerIpAddress(), getMappedPort(BROKER_HTTP_PORT));
34+
}
3335
}
36+

0 commit comments

Comments
 (0)