|
4 | 4 | import org.testcontainers.utility.TestcontainersConfiguration; |
5 | 5 |
|
6 | 6 | /** |
7 | | - * This container wraps Apache pulsar running in stanalone mode |
| 7 | + * This container wraps Apache Pulsar running in standalone mode |
8 | 8 | */ |
9 | 9 | public class PulsarContainer extends GenericContainer<PulsarContainer> { |
10 | 10 |
|
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"; |
12 | 16 |
|
13 | 17 | public PulsarContainer() { |
14 | | - this("2.1.0-incubating"); |
| 18 | + this(PULSAR_VERSION); |
15 | 19 | } |
16 | 20 |
|
17 | 21 | public PulsarContainer(String pulsarVersion) { |
18 | 22 | 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)); |
27 | 26 | } |
28 | 27 |
|
29 | 28 | 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)); |
31 | 30 | } |
32 | 31 |
|
| 32 | + public String getHttpServiceUrl() { |
| 33 | + return String.format("http://%s:%s", getContainerIpAddress(), getMappedPort(BROKER_HTTP_PORT)); |
| 34 | + } |
33 | 35 | } |
| 36 | + |
0 commit comments