File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
main/java/org/testcontainers/containers
test/java/org/testcontainers/containers Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,14 @@ public class PulsarContainer extends GenericContainer<PulsarContainer> {
1717
1818 public static final int BROKER_HTTP_PORT = 8080 ;
1919
20+ /**
21+ * @deprecated The metrics endpoint is no longer being used for the WaitStrategy.
22+ */
23+ @ Deprecated
2024 public static final String METRICS_ENDPOINT = "/metrics" ;
2125
26+ private static final String ADMIN_CLUSTERS_ENDPOINT = "/admin/v2/clusters" ;
27+
2228 /**
2329 * See <a href="https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/naming/SystemTopicNames.java">SystemTopicNames</a>.
2430 */
@@ -92,7 +98,12 @@ protected void setupCommandAndEnv() {
9298
9399 List <WaitStrategy > waitStrategies = new ArrayList <>();
94100 waitStrategies .add (Wait .defaultWaitStrategy ());
95- waitStrategies .add (Wait .forHttp (METRICS_ENDPOINT ).forStatusCode (200 ).forPort (BROKER_HTTP_PORT ));
101+ waitStrategies .add (
102+ Wait
103+ .forHttp (ADMIN_CLUSTERS_ENDPOINT )
104+ .forPort (BROKER_HTTP_PORT )
105+ .forResponsePredicate ("[\" standalone\" ]" ::equals )
106+ );
96107 if (transactionsEnabled ) {
97108 withEnv ("PULSAR_PREFIX_transactionCoordinatorEnabled" , "true" );
98109 waitStrategies .add (Wait .forHttp (TRANSACTION_TOPIC_ENDPOINT ).forStatusCode (200 ).forPort (BROKER_HTTP_PORT ));
Original file line number Diff line number Diff line change @@ -122,6 +122,17 @@ public void testTransactionsAndFunctionsWorker() throws Exception {
122122 }
123123 }
124124
125+ @ Test
126+ public void testClusterFullyInitialized () throws Exception {
127+ try (PulsarContainer pulsar = new PulsarContainer (PULSAR_IMAGE )) {
128+ pulsar .start ();
129+
130+ try (PulsarAdmin pulsarAdmin = PulsarAdmin .builder ().serviceHttpUrl (pulsar .getHttpServiceUrl ()).build ()) {
131+ assertThat (pulsarAdmin .clusters ().getClusters ()).hasSize (1 ).contains ("standalone" );
132+ }
133+ }
134+ }
135+
125136 protected void testPulsarFunctionality (String pulsarBrokerUrl ) throws Exception {
126137 try (
127138 PulsarClient client = PulsarClient .builder ().serviceUrl (pulsarBrokerUrl ).build ();
You can’t perform that action at this time.
0 commit comments