Fix test TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit The test becomes unstable due to pipeline runtime changed. Change to poll and wait style check.
Project: http://git-wip-us.apache.org/repos/asf/helix/repo Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/c783ae78 Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/c783ae78 Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/c783ae78 Branch: refs/heads/master Commit: c783ae788f03c55122858eb552963de5c9a264dd Parents: 30c0eff Author: Jiajun Wang <[email protected]> Authored: Thu Oct 11 17:37:15 2018 -0700 Committer: Junkai Xue <[email protected]> Committed: Thu Nov 1 14:38:48 2018 -0700 ---------------------------------------------------------------------- ...ceModeWhenReachingOfflineInstancesLimit.java | 31 +++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/helix/blob/c783ae78/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit.java b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit.java index 0de2fe3..9067bb5 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit.java +++ b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit.java @@ -19,7 +19,6 @@ package org.apache.helix.integration.rebalancer; * under the License. */ -import java.io.IOException; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Date; @@ -30,6 +29,7 @@ import org.apache.helix.ConfigAccessor; import org.apache.helix.HelixAdmin; import org.apache.helix.HelixDataAccessor; import org.apache.helix.PropertyKey; +import org.apache.helix.TestHelper; import org.apache.helix.common.ZkTestBase; import org.apache.helix.integration.manager.ClusterControllerManager; import org.apache.helix.integration.manager.MockParticipantManager; @@ -197,19 +197,22 @@ public class TestClusterInMaintenanceModeWhenReachingOfflineInstancesLimit System.out.println("END " + CLASS_NAME + " at " + new Date(System.currentTimeMillis())); } - private void checkForRebalanceError(boolean expectError) - throws MalformedObjectNameException, AttributeNotFoundException, MBeanException, - ReflectionException, InstanceNotFoundException, IOException { - /* TODO re-enable this check when we start recording rebalance error again - ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor); - PropertyKey errorNodeKey = - accessor.keyBuilder().controllerTaskError(RebalanceResourceFailure.name()); - Assert.assertEquals(accessor.getProperty(errorNodeKey) != null, expectError); - */ - - Long value = - (Long) _server.getAttribute(getClusterMbeanName(CLUSTER_NAME), "RebalanceFailureGauge"); - Assert.assertEquals(value != null && value.longValue() > 0, expectError); + private void checkForRebalanceError(final boolean expectError) throws Exception { + boolean result = TestHelper.verify(new TestHelper.Verifier() { + @Override + public boolean verify() throws Exception { + /* TODO re-enable this check when we start recording rebalance error again + ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor); + PropertyKey errorNodeKey = + accessor.keyBuilder().controllerTaskError(RebalanceResourceFailure.name()); + Assert.assertEquals(accessor.getProperty(errorNodeKey) != null, expectError); + */ + Long value = + (Long) _server.getAttribute(getClusterMbeanName(CLUSTER_NAME), "RebalanceFailureGauge"); + return expectError == (value != null && value.longValue() > 0); + } + }, 5000); + Assert.assertTrue(result); } private void cleanupRebalanceError() {
