mcvsubbu commented on a change in pull request #4649: Use timed wait around
get() calls in PinotInstanceRestletResourceTest
URL: https://github.com/apache/incubator-pinot/pull/4649#discussion_r328708500
##########
File path:
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotInstanceRestletResourceTest.java
##########
@@ -54,9 +57,17 @@ public void testInstanceListingAndCreation()
throws Exception {
// Check that there is only one CONTROLLER instance in the cluster
String listInstancesUrl = _controllerRequestURLBuilder.forInstanceList();
- JsonNode instanceList =
JsonUtils.stringToJsonNode(sendGetRequest(listInstancesUrl));
- assertEquals(instanceList.get("instances").size(), 1);
-
assertTrue(instanceList.get("instances").get(0).asText().startsWith(Helix.PREFIX_OF_CONTROLLER_INSTANCE));
+
+ TestUtils.waitForCondition(aVoid -> {
+ try {
+ String getResponse = sendGetRequest(listInstancesUrl);
+ JsonNode jsonNode = JsonUtils.stringToJsonNode(getResponse);
+ return (jsonNode != null) && (jsonNode.get("instances") != null) &&
(jsonNode.get("instances").size() == 1)
+ &&
(jsonNode.get("instances").get(0).asText().startsWith(Helix.PREFIX_OF_CONTROLLER_INSTANCE));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }, 500L, 10000L, "Expected one controller instance");
Review comment:
Another implementation of waitForCond () calls every 100ms. I think that
should work fine here. We can still have the total time spent as 10s. Please
declare that as a static final int and use it everywhere.thanks
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]