This is an automated email from the ASF dual-hosted git repository. jxue pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/helix.git
commit c98dfa056e8ff67666b90827f369d74eea8213bf Author: Harry Zhang <[email protected]> AuthorDate: Tue Dec 4 14:58:27 2018 -0800 improve unstable test TestResourceThreadpoolSize --- .../handling/TestResourceThreadpoolSize.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java index c86f533..46d67bb 100644 --- a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java +++ b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java @@ -48,10 +48,15 @@ public class TestResourceThreadpoolSize extends ZkStandAloneCMTestBase { @Test public void TestThreadPoolSizeConfig() { - setResourceThreadPoolSize("NextDB", 12); + String resourceName = "NextDB"; + int numPartition = 64; + int numReplica = 3; + int threadPoolSize = 12; - _gSetupTool.addResourceToCluster(CLUSTER_NAME, "NextDB", 64, STATE_MODEL); - _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, "NextDB", 3); + setResourceThreadPoolSize(resourceName, threadPoolSize); + + _gSetupTool.addResourceToCluster(CLUSTER_NAME, resourceName, numPartition, STATE_MODEL); + _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, resourceName, numReplica); Assert.assertTrue(_clusterVerifier.verifyByPolling()); @@ -62,13 +67,18 @@ public class TestResourceThreadpoolSize extends ZkStandAloneCMTestBase { HelixTaskExecutor helixExecutor = svc.getExecutor(); ThreadPoolExecutor executor = (ThreadPoolExecutor) (helixExecutor._executorMap.get(MessageType.STATE_TRANSITION + "." - + "NextDB")); + + resourceName)); Assert.assertNotNull(executor); - Assert.assertEquals(12, executor.getMaximumPoolSize()); + Assert.assertEquals(threadPoolSize, executor.getMaximumPoolSize()); taskcount += executor.getCompletedTaskCount(); Assert.assertTrue(executor.getCompletedTaskCount() > 0); } - Assert.assertEquals(taskcount, 64 * 4); + + // (numPartition * numReplica) O->S, numPartition S->M + // Plus possible racing condition: when preference list is [n1, n2, n3], + // but n2 or n3 becomes Slave before n1 and captured by controller, i.e. [n1:O, n2:S, n3:O], + // controller will set n2 to Master first and then change it back to n1 + Assert.assertTrue(taskcount >= numPartition * (numReplica + 1)); } @Test
