This is an automated email from the ASF dual-hosted git repository.
hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 66c9964 Fix flaky resource accessor tests (#935)
66c9964 is described below
commit 66c99644da57286ee545a999078096a362184c08
Author: Neal Sun <[email protected]>
AuthorDate: Wed Apr 8 17:34:35 2020 -0700
Fix flaky resource accessor tests (#935)
This PR fixes the flaky tests in TestResourceAccessor, namely
testPartitionHealth and testResourceHealth. The tests have been failing because
the external views created during the tests could be sometimes removed before
the health check, causing health checks to fail. How to reproduce: add time
delay before health check calls will always fail the test cases.
We believe that the reason behind external view removal is due to the
controllers, and disabling the controllers on the test clusters has made the
tests pass even with the time delay.
---
.../helix/rest/server/TestResourceAccessor.java | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestResourceAccessor.java
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestResourceAccessor.java
index 6d672ed..9f5b980 100644
---
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestResourceAccessor.java
+++
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestResourceAccessor.java
@@ -40,6 +40,7 @@ import org.apache.helix.HelixManagerFactory;
import org.apache.helix.InstanceType;
import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.TestHelper;
+import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.zookeeper.datamodel.ZNRecord;
import org.apache.helix.controller.rebalancer.waged.WagedRebalancer;
import org.apache.helix.model.ClusterConfig;
@@ -165,6 +166,9 @@ public class TestResourceAccessor extends AbstractTestClass
{
@Test(dependsOnMethods = "testExternalView")
public void testPartitionHealth() throws Exception {
System.out.println("Start test :" + TestHelper.getTestMethodName());
+ // Stop all controllers because this test case creates external views; the
external views will
+ // be deleted by the controllers if controllers are not stopped and cause
test failures
+ stopClustersControllers();
String clusterName = "TestCluster_1";
String resourceName = clusterName + "_db_0";
@@ -207,11 +211,16 @@ public class TestResourceAccessor extends
AbstractTestClass {
Assert.assertEquals(healthStatus.get("p1"), "PARTIAL_HEALTHY");
Assert.assertEquals(healthStatus.get("p2"), "UNHEALTHY");
System.out.println("End test :" + TestHelper.getTestMethodName());
+ // Restart the stopped controllers
+ startClustersControllers();
}
@Test(dependsOnMethods = "testPartitionHealth")
public void testResourceHealth() throws Exception {
System.out.println("Start test :" + TestHelper.getTestMethodName());
+ // Stop all controllers because this test case creates external views; the
external views will
+ // be deleted by the controllers if controllers are not stopped and cause
test failures
+ stopClustersControllers();
String clusterName = "TestCluster_1";
Map<String, String> idealStateParams = new HashMap<>();
@@ -290,6 +299,8 @@ public class TestResourceAccessor extends AbstractTestClass
{
Assert.assertEquals(healthStatus.get(resourceNamePartiallyHealthy),
"PARTIAL_HEALTHY");
Assert.assertEquals(healthStatus.get(resourceNameUnhealthy), "UNHEALTHY");
System.out.println("End test :" + TestHelper.getTestMethodName());
+ // Restart the stopped controllers
+ startClustersControllers();
}
/**
@@ -645,4 +656,20 @@ public class TestResourceAccessor extends
AbstractTestClass {
externalView);
System.out.println("End test :" + TestHelper.getTestMethodName());
}
+
+ private void stopClustersControllers() {
+ for (ClusterControllerManager cm : _clusterControllerManagers) {
+ if (cm != null && cm.isConnected()) {
+ cm.syncStop();
+ }
+ }
+ }
+
+ private void startClustersControllers() {
+ for (ClusterControllerManager cm : _clusterControllerManagers) {
+ if (cm != null && cm.isConnected()) {
+ cm.syncStart();
+ }
+ }
+ }
}