File tree 2 files changed +23
-1
lines changed
main/java/org/testcontainers/containers
test/java/org/testcontainers/containers
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> {
17
17
18
18
public static final int BROKER_HTTP_PORT = 8080 ;
19
19
20
+ /**
21
+ * @deprecated The metrics endpoint is no longer being used for the WaitStrategy.
22
+ */
23
+ @ Deprecated
20
24
public static final String METRICS_ENDPOINT = "/metrics" ;
21
25
26
+ private static final String ADMIN_CLUSTERS_ENDPOINT = "/admin/v2/clusters" ;
27
+
22
28
/**
23
29
* See <a href="https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/naming/SystemTopicNames.java">SystemTopicNames</a>.
24
30
*/
@@ -92,7 +98,12 @@ protected void setupCommandAndEnv() {
92
98
93
99
List <WaitStrategy > waitStrategies = new ArrayList <>();
94
100
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
+ );
96
107
if (transactionsEnabled ) {
97
108
withEnv ("PULSAR_PREFIX_transactionCoordinatorEnabled" , "true" );
98
109
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 {
122
122
}
123
123
}
124
124
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
+
125
136
protected void testPulsarFunctionality (String pulsarBrokerUrl ) throws Exception {
126
137
try (
127
138
PulsarClient client = PulsarClient .builder ().serviceUrl (pulsarBrokerUrl ).build ();
You can’t perform that action at this time.
0 commit comments