siddharthteotia 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_r328397892
##########
File path:
pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotInstanceRestletResourceTest.java
##########
@@ -99,52 +110,100 @@ public void testInstanceListingAndCreation()
}
// Check that there are still 5 instances
-
assertEquals(JsonUtils.stringToJsonNode(sendGetRequest(listInstancesUrl)).get("instances").size(),
5);
+ checkForInstances(listInstancesUrl, 5);
// Check that the instances are properly created
- JsonNode instance = JsonUtils
-
.stringToJsonNode(sendGetRequest(_controllerRequestURLBuilder.forInstanceInformation("Broker_1.2.3.4_1234")));
- assertEquals(instance.get("instanceName").asText(), "Broker_1.2.3.4_1234");
- assertEquals(instance.get("hostName").asText(), "Broker_1.2.3.4");
- assertEquals(instance.get("port").asText(), "1234");
- assertTrue(instance.get("enabled").asBoolean());
- assertEquals(instance.get("tags").size(), 0);
- assertTrue(instance.get("pools").isNull());
-
- instance = JsonUtils
-
.stringToJsonNode(sendGetRequest(_controllerRequestURLBuilder.forInstanceInformation("Server_1.2.3.4_2345")));
- assertEquals(instance.get("instanceName").asText(), "Server_1.2.3.4_2345");
- assertEquals(instance.get("hostName").asText(), "Server_1.2.3.4");
- assertEquals(instance.get("port").asText(), "2345");
- assertTrue(instance.get("enabled").asBoolean());
- assertEquals(instance.get("tags").size(), 0);
- assertTrue(instance.get("pools").isNull());
-
- instance = JsonUtils
-
.stringToJsonNode(sendGetRequest(_controllerRequestURLBuilder.forInstanceInformation("Broker_2.3.4.5_1234")));
- assertEquals(instance.get("instanceName").asText(), "Broker_2.3.4.5_1234");
- assertEquals(instance.get("hostName").asText(), "Broker_2.3.4.5");
- assertEquals(instance.get("port").asText(), "1234");
- assertTrue(instance.get("enabled").asBoolean());
- JsonNode tags = instance.get("tags");
- assertEquals(tags.size(), 1);
- assertEquals(tags.get(0).asText(), "tag_BROKER");
- assertTrue(instance.get("pools").isNull());
-
- instance = JsonUtils
-
.stringToJsonNode(sendGetRequest(_controllerRequestURLBuilder.forInstanceInformation("Server_2.3.4.5_2345")));
- assertEquals(instance.get("instanceName").asText(), "Server_2.3.4.5_2345");
- assertEquals(instance.get("hostName").asText(), "Server_2.3.4.5");
- assertEquals(instance.get("port").asText(), "2345");
- assertTrue(instance.get("enabled").asBoolean());
- tags = instance.get("tags");
- assertEquals(tags.size(), 2);
- assertEquals(tags.get(0).asText(), "tag_OFFLINE");
- assertEquals(tags.get(1).asText(), "tag_REALTIME");
- JsonNode pools = instance.get("pools");
- assertEquals(pools.size(), 2);
- assertEquals(pools.get("tag_OFFLINE").asText(), "0");
- assertEquals(pools.get("tag_REALTIME").asText(), "1");
+ TestUtils.waitForCondition(new Function<Void, Boolean>() {
+ @Nullable
+ @Override
+ public Boolean apply(@Nullable Void aVoid) {
+ try {
+ String getResponse =
+
sendGetRequest(_controllerRequestURLBuilder.forInstanceInformation("Broker_1.2.3.4_1234"));
+ JsonNode instance = JsonUtils.stringToJsonNode(getResponse);
+ assertEquals(instance.get("instanceName").asText(),
"Broker_1.2.3.4_1234");
Review comment:
thanks for catching. I have made the changes to check for null results in
fields.
----------------------------------------------------------------
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]