Repository: helix Updated Branches: refs/heads/master 6930d1dcf -> 4385d01a3
http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/task/TestSemiAutoStateTransition.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/task/TestSemiAutoStateTransition.java b/helix-core/src/test/java/org/apache/helix/task/TestSemiAutoStateTransition.java index 9d34980..a281863 100644 --- a/helix-core/src/test/java/org/apache/helix/task/TestSemiAutoStateTransition.java +++ b/helix-core/src/test/java/org/apache/helix/task/TestSemiAutoStateTransition.java @@ -20,7 +20,6 @@ package org.apache.helix.task; */ import java.util.Map; - import org.apache.helix.HelixDataAccessor; import org.apache.helix.PropertyKey; import org.apache.helix.integration.manager.ClusterControllerManager; @@ -32,7 +31,6 @@ import org.apache.helix.mock.participant.MockDelayMSStateModelFactory; import org.apache.helix.model.ExternalView; import org.apache.helix.model.IdealState; import org.apache.helix.participant.StateMachineEngine; -import org.apache.helix.tools.ClusterSetup; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/task/TestTaskCreateThrottling.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/task/TestTaskCreateThrottling.java b/helix-core/src/test/java/org/apache/helix/task/TestTaskCreateThrottling.java index 755f6a5..dab5ffb 100644 --- a/helix-core/src/test/java/org/apache/helix/task/TestTaskCreateThrottling.java +++ b/helix-core/src/test/java/org/apache/helix/task/TestTaskCreateThrottling.java @@ -19,6 +19,8 @@ package org.apache.helix.task; * under the License. */ +import java.util.ArrayList; +import java.util.List; import org.apache.helix.HelixException; import org.apache.helix.integration.task.MockTask; import org.apache.helix.integration.task.TaskTestBase; @@ -28,9 +30,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; - public class TestTaskCreateThrottling extends TaskTestBase { @BeforeClass public void beforeClass() throws Exception { http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/task/assigner/AssignerTestBase.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/task/assigner/AssignerTestBase.java b/helix-core/src/test/java/org/apache/helix/task/assigner/AssignerTestBase.java index 5049df7..9aac81f 100644 --- a/helix-core/src/test/java/org/apache/helix/task/assigner/AssignerTestBase.java +++ b/helix-core/src/test/java/org/apache/helix/task/assigner/AssignerTestBase.java @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.Map; import org.apache.helix.model.ClusterConfig; import org.apache.helix.model.LiveInstance; -import org.apache.helix.task.TaskConfig; /* package */ class AssignerTestBase { http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/tools/ClusterVerifiers/TestStrictMatchExternalViewVerifier.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/tools/ClusterVerifiers/TestStrictMatchExternalViewVerifier.java b/helix-core/src/test/java/org/apache/helix/tools/ClusterVerifiers/TestStrictMatchExternalViewVerifier.java index 7a90504..e88bb22 100644 --- a/helix-core/src/test/java/org/apache/helix/tools/ClusterVerifiers/TestStrictMatchExternalViewVerifier.java +++ b/helix-core/src/test/java/org/apache/helix/tools/ClusterVerifiers/TestStrictMatchExternalViewVerifier.java @@ -22,7 +22,6 @@ package org.apache.helix.tools.ClusterVerifiers; import java.util.HashSet; import java.util.List; import java.util.Map; - import org.apache.helix.model.BuiltInStateModelDefinitions; import org.apache.helix.util.HelixUtil; import org.apache.helix.util.TestInputLoader; http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java b/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java index ec2c5a9..ec80e64 100644 --- a/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java +++ b/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java @@ -22,25 +22,23 @@ package org.apache.helix.tools; import java.io.IOException; import java.util.Arrays; import java.util.Date; - import org.apache.helix.BaseDataAccessor; import org.apache.helix.HelixDataAccessor; import org.apache.helix.HelixException; import org.apache.helix.PropertyKey; +import org.apache.helix.PropertyKey.Builder; import org.apache.helix.PropertyPathBuilder; -import org.apache.helix.PropertyType; import org.apache.helix.TestHelper; import org.apache.helix.ZNRecord; import org.apache.helix.ZkUnitTestBase; -import org.apache.helix.PropertyKey.Builder; import org.apache.helix.manager.zk.ZKHelixAdmin; import org.apache.helix.manager.zk.ZKHelixDataAccessor; import org.apache.helix.manager.zk.ZNRecordSerializer; import org.apache.helix.manager.zk.ZkBaseDataAccessor; import org.apache.helix.manager.zk.ZkClient; +import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty; import org.apache.helix.model.IdealState; import org.apache.helix.model.LiveInstance; -import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/tools/TestClusterStateVerifier.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestClusterStateVerifier.java b/helix-core/src/test/java/org/apache/helix/tools/TestClusterStateVerifier.java index 1256b4a..d09028d 100644 --- a/helix-core/src/test/java/org/apache/helix/tools/TestClusterStateVerifier.java +++ b/helix-core/src/test/java/org/apache/helix/tools/TestClusterStateVerifier.java @@ -19,8 +19,8 @@ package org.apache.helix.tools; * under the License. */ +import com.google.common.collect.Sets; import java.util.Arrays; - import org.apache.helix.HelixAdmin; import org.apache.helix.TestHelper; import org.apache.helix.ZkUnitTestBase; @@ -35,8 +35,6 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.common.collect.Sets; - @Deprecated public class TestClusterStateVerifier extends ZkUnitTestBase { final String[] RESOURCES = { http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/tools/TestClusterVerifier.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestClusterVerifier.java b/helix-core/src/test/java/org/apache/helix/tools/TestClusterVerifier.java index dc82f90..ca6b6b6 100644 --- a/helix-core/src/test/java/org/apache/helix/tools/TestClusterVerifier.java +++ b/helix-core/src/test/java/org/apache/helix/tools/TestClusterVerifier.java @@ -21,6 +21,7 @@ package org.apache.helix.tools; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import java.util.Arrays; import org.apache.helix.ConfigAccessor; import org.apache.helix.HelixAdmin; import org.apache.helix.TestHelper; @@ -35,13 +36,12 @@ import org.apache.helix.model.IdealState.RebalanceMode; import org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier; import org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier; import org.apache.helix.tools.ClusterVerifiers.StrictMatchExternalViewVerifier; +import org.apache.helix.tools.ClusterVerifiers.ZkHelixClusterVerifier; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.Arrays; - public class TestClusterVerifier extends ZkUnitTestBase { final String[] RESOURCES = { "resource_semi_MasterSlave", "resource_semi_OnlineOffline", @@ -177,14 +177,14 @@ public class TestClusterVerifier extends ZkUnitTestBase { _admin.enableCluster(_clusterName, false); _admin.enableInstance(_clusterName, "localhost_12918", true); - HelixClusterVerifier verifier = + ZkHelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient) .setResources(Sets.newHashSet(testDB)).build(); - Assert.assertTrue(verifier.verify()); + Assert.assertTrue(verifier.verifyByPolling()); verifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient) .setResources(Sets.newHashSet(testDB)).build(); - Assert.assertTrue(verifier.verify()); + Assert.assertTrue(verifier.verifyByPolling()); // But the full cluster verification should fail verifier = http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java index 842fcfa..07be097 100644 --- a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java +++ b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java @@ -21,10 +21,10 @@ package org.apache.helix.tools; import java.io.FileWriter; import java.io.PrintWriter; +import java.lang.reflect.Method; import java.util.Date; import java.util.HashSet; import java.util.Set; - import org.apache.helix.BaseDataAccessor; import org.apache.helix.HelixDataAccessor; import org.apache.helix.TestHelper; @@ -43,9 +43,25 @@ import org.apache.helix.tools.ClusterStateVerifier; import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier; import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier; import org.testng.Assert; +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; public class TestHelixAdminCli extends ZkTestBase { + private String clusterName = TestHelper.getTestClassName(); + String grandClusterName = clusterName + "_grand"; + + @AfterMethod + public void endTest(Method testMethod, ITestContext testContext) { + if (_gZkClient.exists("/" + clusterName)) { + _gSetupTool.deleteCluster(clusterName); + } + if (_gZkClient.exists("/" + grandClusterName)) { + _gSetupTool.deleteCluster(grandClusterName); + } + super.endTest(testMethod, testContext); + } + @Test public void testAddCluster() throws Exception { String command = "--zkSvr localhost:2183 -addCluster clusterTest"; @@ -90,18 +106,10 @@ public class TestHelixAdminCli extends ZkTestBase { Assert.assertFalse(_gZkClient.exists("/clusterTest")); Assert.assertFalse(_gZkClient.exists("/\\ClusterTest")); Assert.assertFalse(_gZkClient.exists("/clusterTest1")); - - // System.out.println("END test"); } @Test public void testAddResource() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - - System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); - String command = "-zkSvr localhost:2183 -addCluster " + clusterName; ClusterSetup.processCommandLineArgs(command.split("\\s+")); @@ -123,18 +131,10 @@ public class TestHelixAdminCli extends ZkTestBase { // drop resource now command = "-zkSvr localhost:2183 -dropResource " + clusterName + " db_11 "; ClusterSetup.processCommandLineArgs(command.split("\\s+")); - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @Test public void testAddInstance() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - - System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); - String command = "-zkSvr localhost:2183 -addCluster " + clusterName; ClusterSetup.processCommandLineArgs(command.split("\\s+")); @@ -181,18 +181,10 @@ public class TestHelixAdminCli extends ZkTestBase { } catch (Exception e) { // OK } - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @Test public void testRebalanceResource() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - - System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); - String command = "-zkSvr localhost:2183 -addCluster " + clusterName; ClusterSetup.processCommandLineArgs(command.split("\\s+")); @@ -220,19 +212,12 @@ public class TestHelixAdminCli extends ZkTestBase { // rebalance with key prefix command = "-zkSvr localhost:2183 -rebalance " + clusterName + " db_11 2 -key alias"; ClusterSetup.processCommandLineArgs(command.split("\\s+")); - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @Test public void testStartCluster() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - String grandClusterName = clusterName + "_grand"; final int n = 6; - System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); MockParticipantManager[] participants = new MockParticipantManager[n]; ClusterDistributedController[] controllers = new ClusterDistributedController[2]; setupCluster(clusterName, grandClusterName, n, participants, controllers); @@ -310,20 +295,12 @@ public class TestHelixAdminCli extends ZkTestBase { for (int i = 0; i < participants.length; i++) { participants[i].syncStop(); } - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @Test public void testDropAddResource() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - String grandClusterName = clusterName + "_grand"; final int n = 6; - System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); - MockParticipantManager[] participants = new MockParticipantManager[n]; ClusterDistributedController[] controllers = new ClusterDistributedController[2]; setupCluster(clusterName, grandClusterName, n, participants, controllers); @@ -375,15 +352,11 @@ public class TestHelixAdminCli extends ZkTestBase { for (int i = 0; i < participants.length; i++) { participants[i].syncStop(); } - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); - } private void setupCluster(String clusterName, String grandClusterName, final int n, MockParticipantManager[] participants, ClusterDistributedController[] controllers) - throws Exception, - InterruptedException { + throws Exception { // add cluster String command = "-zkSvr " + ZK_ADDR + " -addCluster " + clusterName; ClusterSetup.processCommandLineArgs(command.split("\\s+")); @@ -430,14 +403,8 @@ public class TestHelixAdminCli extends ZkTestBase { @Test public void testInstanceOperations() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - String grandClusterName = clusterName + "_grand"; final int n = 6; - System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); - MockParticipantManager[] participants = new MockParticipantManager[n]; ClusterDistributedController[] controllers = new ClusterDistributedController[2]; setupCluster(clusterName, grandClusterName, n, participants, controllers); @@ -503,16 +470,10 @@ public class TestHelixAdminCli extends ZkTestBase { for (int i = 0; i < participants.length; i++) { participants[i].syncStop(); } - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @Test public void testExpandCluster() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - String grandClusterName = clusterName + "_grand"; final int n = 6; System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); @@ -560,16 +521,10 @@ public class TestHelixAdminCli extends ZkTestBase { for (int i = 0; i < newParticipants.length; i++) { newParticipants[i].syncStop(); } - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @Test public void testDeactivateCluster() throws Exception { - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - String grandClusterName = clusterName + "_grand"; final int n = 6; System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); @@ -620,22 +575,13 @@ public class TestHelixAdminCli extends ZkTestBase { } command = "-zkSvr localhost:2183 -dropCluster " + grandClusterName; ClusterSetup.processCommandLineArgs(command.split("\\s+")); - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @Test public void testInstanceGroupTags() throws Exception { - - String className = TestHelper.getTestClassName(); - String methodName = TestHelper.getTestMethodName(); - String clusterName = className + "_" + methodName; - BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient); HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, baseAccessor); - System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); - String command = "-zkSvr " + ZK_ADDR + " -addCluster " + clusterName; ClusterSetup.processCommandLineArgs(command.split("\\s+")); @@ -729,7 +675,5 @@ public class TestHelixAdminCli extends ZkTestBase { // rebalance with key prefix command = "-zkSvr " + ZK_ADDR + " -rebalance " + clusterName + " db_11 2 -key alias"; ClusterSetup.processCommandLineArgs(command.split("\\s+")); - - System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } } http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/tools/TestZkCopy.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestZkCopy.java b/helix-core/src/test/java/org/apache/helix/tools/TestZkCopy.java index 94111eb..cff87a6 100644 --- a/helix-core/src/test/java/org/apache/helix/tools/TestZkCopy.java +++ b/helix-core/src/test/java/org/apache/helix/tools/TestZkCopy.java @@ -20,7 +20,6 @@ package org.apache.helix.tools; */ import java.util.Date; - import org.apache.helix.InstanceType; import org.apache.helix.TestHelper; import org.apache.helix.ZNRecord; @@ -66,6 +65,7 @@ public class TestZkCopy extends ZkUnitTestBase { } } + _gZkClient.deleteRecursively("/" + clusterName); System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); } @@ -110,6 +110,9 @@ public class TestZkCopy extends ZkUnitTestBase { .isInstanceSetup(_gZkClient, dstClusterName, instanceName, InstanceType.PARTICIPANT); Assert.assertTrue(ret); } + + TestHelper.dropCluster(srcClusterName, _gZkClient); + TestHelper.dropCluster(dstClusterName, _gZkClient); System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis())); } } http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/util/TestIdealStateAssignment.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/util/TestIdealStateAssignment.java b/helix-core/src/test/java/org/apache/helix/util/TestIdealStateAssignment.java index 8a8a54f..7d94b35 100644 --- a/helix-core/src/test/java/org/apache/helix/util/TestIdealStateAssignment.java +++ b/helix-core/src/test/java/org/apache/helix/util/TestIdealStateAssignment.java @@ -22,7 +22,6 @@ package org.apache.helix.util; import java.util.ArrayList; import java.util.List; import java.util.Map; - import org.apache.helix.model.ClusterConfig; import org.apache.helix.model.IdealState; import org.apache.helix.model.InstanceConfig; http://git-wip-us.apache.org/repos/asf/helix/blob/4609d944/helix-core/src/test/java/org/apache/helix/util/TestZKClientPool.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/util/TestZKClientPool.java b/helix-core/src/test/java/org/apache/helix/util/TestZKClientPool.java index 14ad709..222f7b4 100644 --- a/helix-core/src/test/java/org/apache/helix/util/TestZKClientPool.java +++ b/helix-core/src/test/java/org/apache/helix/util/TestZKClientPool.java @@ -20,13 +20,11 @@ package org.apache.helix.util; */ import java.util.Date; - import org.I0Itec.zkclient.ZkServer; import org.I0Itec.zkclient.exception.ZkNoNodeException; import org.apache.helix.TestHelper; import org.apache.helix.ZNRecord; import org.apache.helix.manager.zk.ZkClient; -import org.apache.helix.util.ZKClientPool; import org.testng.Assert; import org.testng.annotations.Test;
