FrankChen021 commented on code in PR #19564:
URL: https://github.com/apache/druid/pull/19564#discussion_r3388210746


##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/consul/ConsulClusterResource.java:
##########
@@ -106,6 +123,96 @@ protected GenericContainer<?> createContainer()
     }
   }
 
+  private void waitForConsulApi()
+  {
+    final long deadline = System.nanoTime() + READINESS_TIMEOUT.toNanos();
+    final HttpClient httpClient;
+    Exception lastException = null;
+
+    try {
+      httpClient = createHttpClient();
+    }
+    catch (Exception e) {
+      throw new RuntimeException("Failed to create Consul readiness client", 
e);
+    }
+
+    while (System.nanoTime() < deadline) {
+      try {
+        final HttpRequest request = 
HttpRequest.newBuilder(getHttpUri("/v1/status/leader"))
+                                               .timeout(Duration.ofSeconds(5))
+                                               .GET()
+                                               .build();
+        final HttpResponse<String> response = httpClient.send(request, 
HttpResponse.BodyHandlers.ofString());
+        if (response.statusCode() == 200 && response.body() != null && 
!response.body().trim().isEmpty()) {

Review Comment:
   Thanks, the update addresses my earlier concern: the readiness check now 
parses the leader response as a JSON string and rejects the empty leader value. 
Reviewed 4 of 4 changed files; no new findings.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to