jackjlli 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_r328381508
##########
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.get("instances").size() == 1 &&
jsonNode.get("instances").get(0).asText()
+ .startsWith(Helix.PREFIX_OF_CONTROLLER_INSTANCE);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
Review comment:
The thrown exception will directly fail the test instead of retry.
The cache data accessor may return null, which will exactly be caught here.
Returning false would be good.
----------------------------------------------------------------
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]