You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by jl...@apache.org on 2019/01/10 17:26:52 UTC
[incubator-pinot] branch master updated: Try fixing flaky tests by
adding 0.5s sleep (#3667)
This is an automated email from the ASF dual-hosted git repository.
jlli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new a7bf571 Try fixing flaky tests by adding 0.5s sleep (#3667)
a7bf571 is described below
commit a7bf571f4f05e179d8a0e81b9cae5ecaea2a1b35
Author: Jialiang Li <jl...@linkedin.com>
AuthorDate: Thu Jan 10 09:26:46 2019 -0800
Try fixing flaky tests by adding 0.5s sleep (#3667)
* Try fixing flaky tests by adding 0.5s sleep
* Leverage waitForCondition method in test jar
---
pinot-controller/pom.xml | 6 +++++
.../PinotInstanceRestletResourceTest.java | 29 ++++++++++++++++------
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/pinot-controller/pom.xml b/pinot-controller/pom.xml
index 48652fc..989e40a 100644
--- a/pinot-controller/pom.xml
+++ b/pinot-controller/pom.xml
@@ -70,6 +70,12 @@
</dependency>
<dependency>
<groupId>com.linkedin.pinot</groupId>
+ <artifactId>pinot-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>com.linkedin.pinot</groupId>
<artifactId>pinot-server</artifactId>
<scope>test</scope>
<exclusions>
diff --git a/pinot-controller/src/test/java/com/linkedin/pinot/controller/api/resources/PinotInstanceRestletResourceTest.java b/pinot-controller/src/test/java/com/linkedin/pinot/controller/api/resources/PinotInstanceRestletResourceTest.java
index d40fa8c..c9ab9e6 100644
--- a/pinot-controller/src/test/java/com/linkedin/pinot/controller/api/resources/PinotInstanceRestletResourceTest.java
+++ b/pinot-controller/src/test/java/com/linkedin/pinot/controller/api/resources/PinotInstanceRestletResourceTest.java
@@ -20,6 +20,7 @@ package com.linkedin.pinot.controller.api.resources;
import com.linkedin.pinot.common.utils.CommonConstants;
import com.linkedin.pinot.controller.helix.ControllerTest;
+import com.linkedin.pinot.util.TestUtils;
import java.io.IOException;
import org.json.JSONObject;
import org.testng.annotations.BeforeClass;
@@ -53,9 +54,15 @@ public class PinotInstanceRestletResourceTest extends ControllerTest {
sendPostRequest(_controllerRequestURLBuilder.forInstanceCreate(), serverInstance.toString());
// Check that there are two instances
- instanceList = new JSONObject(sendGetRequest(_controllerRequestURLBuilder.forInstanceList()));
- assertEquals(instanceList.getJSONArray("instances").length(), 2,
- "Expected two instances after creation of untagged instances");
+ TestUtils.waitForCondition(aVoid -> {
+ try {
+ // Check that there are four instances
+ JSONObject instanceList1 = new JSONObject(sendGetRequest(_controllerRequestURLBuilder.forInstanceList()));
+ return instanceList1.getJSONArray("instances").length() == 2;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }, 500L, 10_000L, "Expected two instances after creation of tagged instances");
// Create tagged broker and server instances
brokerInstance.put("tag", "someTag");
@@ -66,10 +73,16 @@ public class PinotInstanceRestletResourceTest extends ControllerTest {
serverInstance.put("host", "2.3.4.5");
sendPostRequest(_controllerRequestURLBuilder.forInstanceCreate(), serverInstance.toString());
- // Check that there are four instances
- instanceList = new JSONObject(sendGetRequest(_controllerRequestURLBuilder.forInstanceList()));
- assertEquals(instanceList.getJSONArray("instances").length(), 4,
- "Expected two instances after creation of tagged instances");
+ // It may take some time for cache data accessor to update its data.
+ TestUtils.waitForCondition(aVoid -> {
+ try {
+ // Check that there are four instances
+ JSONObject instanceList1 = new JSONObject(sendGetRequest(_controllerRequestURLBuilder.forInstanceList()));
+ return instanceList1.getJSONArray("instances").length() == 4;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }, 500L, 10_000L, "Expected four instances after creation of tagged instances");
// Create duplicate broker and server instances (both calls should fail)
try {
@@ -89,7 +102,7 @@ public class PinotInstanceRestletResourceTest extends ControllerTest {
// Check that there are four instances
instanceList = new JSONObject(sendGetRequest(_controllerRequestURLBuilder.forInstanceList()));
assertEquals(instanceList.getJSONArray("instances").length(), 4,
- "Expected two instances after creation of duplicate instances");
+ "Expected four instances after creation of duplicate instances");
// Check that the instances are properly created
JSONObject instance =
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org