You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by zz...@apache.org on 2014/07/22 20:40:24 UTC
[6/9] [HELIX-475] Remove code duplication for Zk tests
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
index 8135191..0d7d33c 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
@@ -23,20 +23,18 @@ import java.util.Date;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.controller.HelixControllerMain;
import org.apache.helix.integration.manager.ClusterDistributedController;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.model.LiveInstance;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestDistributedCMMain extends ZkIntegrationTestBase {
+public class TestDistributedCMMain extends ZkTestBase {
@Test
public void testDistributedCMMain() throws Exception {
@@ -54,7 +52,7 @@ public class TestDistributedCMMain extends ZkIntegrationTestBase {
String clusterName = clusterNamePrefix + "0_" + i;
String participantName = "localhost" + i;
String resourceName = "TestDB" + i;
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
participantName, // participant name prefix
resourceName, // resource name prefix
1, // resources
@@ -66,7 +64,7 @@ public class TestDistributedCMMain extends ZkIntegrationTestBase {
// setup controller cluster
final String controllerClusterName = "CONTROLLER_" + clusterNamePrefix;
- TestHelper.setupCluster("CONTROLLER_" + clusterNamePrefix, ZK_ADDR, 0, // controller
+ TestHelper.setupCluster("CONTROLLER_" + clusterNamePrefix, _zkaddr, 0, // controller
// port
"controller", // participant name prefix
clusterNamePrefix, // resource name prefix
@@ -80,13 +78,13 @@ public class TestDistributedCMMain extends ZkIntegrationTestBase {
ClusterDistributedController[] controllers = new ClusterDistributedController[n + n];
for (int i = 0; i < n; i++) {
controllers[i] =
- new ClusterDistributedController(ZK_ADDR, controllerClusterName, "controller_" + i);
+ new ClusterDistributedController(_zkaddr, controllerClusterName, "controller_" + i);
controllers[i].syncStart();
}
boolean result =
ClusterStateVerifier.verifyByZkCallback(
- new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, controllerClusterName),
+ new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr, controllerClusterName),
30000);
Assert.assertTrue(result, "Controller cluster NOT in ideal state");
@@ -95,44 +93,42 @@ public class TestDistributedCMMain extends ZkIntegrationTestBase {
final String firstClusterName = clusterNamePrefix + "0_0";
for (int i = 0; i < n; i++) {
String instanceName = "localhost0_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, firstClusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, firstClusterName, instanceName);
participants[i].syncStart();
}
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
firstClusterName));
Assert.assertTrue(result, "first cluster NOT in ideal state");
// add more controllers to controller cluster
- ClusterSetup setupTool = new ClusterSetup(ZK_ADDR);
for (int i = 0; i < n; i++) {
String controller = "controller_" + (n + i);
- setupTool.addInstanceToCluster(controllerClusterName, controller);
+ _setupTool.addInstanceToCluster(controllerClusterName, controller);
}
- setupTool.rebalanceStorageCluster(controllerClusterName, clusterNamePrefix + "0", 6);
+ _setupTool.rebalanceStorageCluster(controllerClusterName, clusterNamePrefix + "0", 6);
for (int i = n; i < 2 * n; i++) {
controllers[i] =
- new ClusterDistributedController(ZK_ADDR, controllerClusterName, "controller_" + i);
+ new ClusterDistributedController(_zkaddr, controllerClusterName, "controller_" + i);
controllers[i].syncStart();
}
// verify controller cluster
result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
controllerClusterName));
Assert.assertTrue(result, "Controller cluster NOT in ideal state");
// verify first cluster
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
firstClusterName));
Assert.assertTrue(result, "first cluster NOT in ideal state");
// stop controller_0-5
- ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
- ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(controllerClusterName, baseAccessor);
+ ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(controllerClusterName, _baseAccessor);
Builder keyBuilder = accessor.keyBuilder();
for (int i = 0; i < n; i++) {
LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
@@ -142,12 +138,12 @@ public class TestDistributedCMMain extends ZkIntegrationTestBase {
result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
controllerClusterName));
Assert.assertTrue(result, "Controller cluster NOT in ideal state");
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
firstClusterName));
Assert.assertTrue(result, "first cluster NOT in ideal state");
}
@@ -158,7 +154,7 @@ public class TestDistributedCMMain extends ZkIntegrationTestBase {
for (int i = 0; i < 5; i++) {
result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
controllerClusterName));
controllers[i].syncStop();
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
index f3def23..cf7884a 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
@@ -23,19 +23,17 @@ import java.util.Date;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.controller.HelixControllerMain;
import org.apache.helix.integration.manager.ClusterDistributedController;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.model.LiveInstance;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestDistributedClusterController extends ZkIntegrationTestBase {
+public class TestDistributedClusterController extends ZkTestBase {
@Test
public void testDistributedClusterController() throws Exception {
@@ -53,7 +51,7 @@ public class TestDistributedClusterController extends ZkIntegrationTestBase {
String clusterName = clusterNamePrefix + "0_" + i;
String participantName = "localhost" + i;
String resourceName = "TestDB" + i;
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
participantName, // participant name prefix
resourceName, // resource name prefix
1, // resources
@@ -65,7 +63,7 @@ public class TestDistributedClusterController extends ZkIntegrationTestBase {
// setup controller cluster
final String controllerClusterName = "CONTROLLER_" + clusterNamePrefix;
- TestHelper.setupCluster("CONTROLLER_" + clusterNamePrefix, ZK_ADDR, 0, // controller
+ TestHelper.setupCluster("CONTROLLER_" + clusterNamePrefix, _zkaddr, 0, // controller
// port
"controller", // participant name prefix
clusterNamePrefix, // resource name prefix
@@ -79,13 +77,13 @@ public class TestDistributedClusterController extends ZkIntegrationTestBase {
ClusterDistributedController[] controllers = new ClusterDistributedController[n];
for (int i = 0; i < n; i++) {
controllers[i] =
- new ClusterDistributedController(ZK_ADDR, controllerClusterName, "controller_" + i);
+ new ClusterDistributedController(_zkaddr, controllerClusterName, "controller_" + i);
controllers[i].syncStart();
}
boolean result =
ClusterStateVerifier.verifyByZkCallback(
- new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, controllerClusterName),
+ new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr, controllerClusterName),
30000);
Assert.assertTrue(result, "Controller cluster NOT in ideal state");
@@ -94,18 +92,17 @@ public class TestDistributedClusterController extends ZkIntegrationTestBase {
final String firstClusterName = clusterNamePrefix + "0_0";
for (int i = 0; i < n; i++) {
String instanceName = "localhost0_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, firstClusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, firstClusterName, instanceName);
participants[i].syncStart();
}
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
firstClusterName));
Assert.assertTrue(result, "first cluster NOT in ideal state");
// stop current leader in controller cluster
- ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
- ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(controllerClusterName, baseAccessor);
+ ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(controllerClusterName, _baseAccessor);
Builder keyBuilder = accessor.keyBuilder();
LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
String leaderName = leader.getId();
@@ -117,12 +114,12 @@ public class TestDistributedClusterController extends ZkIntegrationTestBase {
final String secondClusterName = clusterNamePrefix + "0_1";
for (int i = 0; i < n; i++) {
String instanceName = "localhost1_" + (12918 + i);
- participants2[i] = new MockParticipantManager(ZK_ADDR, secondClusterName, instanceName);
+ participants2[i] = new MockParticipantManager(_zkaddr, secondClusterName, instanceName);
participants2[i].syncStart();
}
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
secondClusterName));
Assert.assertTrue(result, "second cluster NOT in ideal state");
@@ -132,7 +129,7 @@ public class TestDistributedClusterController extends ZkIntegrationTestBase {
for (int i = 0; i < 5; i++) {
result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
controllerClusterName));
controllers[i].syncStop();
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java b/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
index 2f2431b..9660f10 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
@@ -52,7 +52,6 @@ import org.testng.Assert;
public class TestDriver {
private static Logger LOG = Logger.getLogger(TestDriver.class);
- private static final String ZK_ADDR = ZkIntegrationTestBase.ZK_ADDR;
// private static final String CLUSTER_PREFIX = "TestDriver";
private static final String STATE_MODEL = "MasterSlave";
@@ -164,13 +163,13 @@ public class TestDriver {
* @param uniqueTestName
* @param instanceId
*/
- public static void startDummyParticipant(String uniqClusterName, int instanceId) throws Exception {
- startDummyParticipants(uniqClusterName, new int[] {
+ public static void startDummyParticipant(String zkAddr, String uniqClusterName, int instanceId) throws Exception {
+ startDummyParticipants(zkAddr, uniqClusterName, new int[] {
instanceId
});
}
- public static void startDummyParticipants(String uniqClusterName, int[] instanceIds)
+ public static void startDummyParticipants(String zkAddr, String uniqClusterName, int[] instanceIds)
throws Exception {
if (!_testInfoMap.containsKey(uniqClusterName)) {
String errMsg = "test cluster hasn't been setup:" + uniqClusterName;
@@ -189,7 +188,7 @@ public class TestDriver {
} else {
// StartCMResult result = TestHelper.startDummyProcess(ZK_ADDR, clusterName, instanceName);
MockParticipantManager participant =
- new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ new MockParticipantManager(zkAddr, clusterName, instanceName);
participant.syncStart();
testInfo._managers.put(instanceName, participant);
// testInfo._instanceStarted.countDown();
@@ -197,13 +196,13 @@ public class TestDriver {
}
}
- public static void startController(String uniqClusterName) throws Exception {
- startController(uniqClusterName, new int[] {
+ public static void startController(String zkAddr, String uniqClusterName) throws Exception {
+ startController(zkAddr, uniqClusterName, new int[] {
0
});
}
- public static void startController(String uniqClusterName, int[] nodeIds) throws Exception {
+ public static void startController(String zkAddr, String uniqClusterName, int[] nodeIds) throws Exception {
if (!_testInfoMap.containsKey(uniqClusterName)) {
String errMsg = "test cluster hasn't been setup:" + uniqClusterName;
throw new IllegalArgumentException(errMsg);
@@ -218,14 +217,14 @@ public class TestDriver {
LOG.warn("Controller:" + controllerName + " has already started; skip starting it");
} else {
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, controllerName);
+ new ClusterControllerManager(zkAddr, clusterName, controllerName);
controller.syncStart();
testInfo._managers.put(controllerName, controller);
}
}
}
- public static void verifyCluster(String uniqClusterName, long beginTime, long timeout)
+ public static void verifyCluster(String zkAddr, String uniqClusterName, long beginTime, long timeout)
throws Exception {
Thread.sleep(beginTime);
@@ -239,7 +238,7 @@ public class TestDriver {
boolean result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, clusterName), timeout);
+ zkAddr, clusterName), timeout);
Assert.assertTrue(result);
}
@@ -302,7 +301,7 @@ public class TestDriver {
}
}
- public static void setIdealState(String uniqClusterName, long beginTime, int percentage)
+ public static void setIdealState(String zkAddr, String uniqClusterName, long beginTime, int percentage)
throws Exception {
if (!_testInfoMap.containsKey(uniqClusterName)) {
String errMsg = "test cluster hasn't been setup:" + uniqClusterName;
@@ -361,7 +360,7 @@ public class TestDriver {
commandList.add(command);
}
- TestExecutor.executeTestAsync(commandList, ZK_ADDR);
+ TestExecutor.executeTestAsync(commandList, zkAddr);
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
index 8919634..ac20652 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
@@ -29,11 +29,9 @@ import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.PropertyKey;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
import org.apache.helix.HelixDefinedState;
import org.apache.helix.manager.zk.ZKHelixAdmin;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.mock.participant.ErrTransition;
@@ -42,13 +40,14 @@ import org.apache.helix.model.ExternalView;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
import org.apache.helix.model.builder.CustomModeISBuilder;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestDrop extends ZkIntegrationTestBase {
+public class TestDrop extends ZkTestBase {
/**
* Assert externalView and currentState for each participant are empty
@@ -56,8 +55,9 @@ public class TestDrop extends ZkIntegrationTestBase {
* @param db
* @param participants
*/
- private void assertEmptyCSandEV(String clusterName, String db, MockParticipantManager[] participants) {
- HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+ private void assertEmptyCSandEV(String clusterName, String db,
+ MockParticipantManager[] participants) {
+ HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
Assert.assertNull(accessor.getProperty(keyBuilder.externalView(db)));
@@ -79,7 +79,7 @@ public class TestDrop extends ZkIntegrationTestBase {
MockParticipantManager[] participants = new MockParticipantManager[n];
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -90,30 +90,30 @@ public class TestDrop extends ZkIntegrationTestBase {
// start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller");
controller.syncStart();
// start participants
for (int i = 0; i < n; i++) {
String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
}
boolean result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// Drop TestDB0
- HelixAdmin admin = new ZKHelixAdmin(_gZkClient);
+ HelixAdmin admin = new ZKHelixAdmin(_zkclient);
admin.dropResource(clusterName, "TestDB0");
result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
@@ -134,7 +134,7 @@ public class TestDrop extends ZkIntegrationTestBase {
MockParticipantManager[] participants = new MockParticipantManager[n];
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -145,7 +145,7 @@ public class TestDrop extends ZkIntegrationTestBase {
// start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
// start participants
@@ -157,10 +157,10 @@ public class TestDrop extends ZkIntegrationTestBase {
String instanceName = "localhost_" + (12918 + i);
if (i == 0) {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].setTransition(new ErrTransition(errTransitions));
} else {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
}
participants[i].syncStart();
}
@@ -170,18 +170,18 @@ public class TestDrop extends ZkIntegrationTestBase {
errStateMap.get("TestDB0").put("TestDB0_4", "localhost_12918");
errStateMap.get("TestDB0").put("TestDB0_8", "localhost_12918");
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName, errStateMap));
Assert.assertTrue(result);
// drop resource containing error partitions should drop the partition successfully
ClusterSetup.processCommandLineArgs(new String[] {
- "--zkSvr", ZK_ADDR, "--dropResource", clusterName, "TestDB0"
+ "--zkSvr", _zkaddr, "--dropResource", clusterName, "TestDB0"
});
// make sure TestDB0_4 and TestDB0_8 partitions are dropped
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
@@ -208,7 +208,7 @@ public class TestDrop extends ZkIntegrationTestBase {
MockParticipantManager[] participants = new MockParticipantManager[n];
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -219,7 +219,7 @@ public class TestDrop extends ZkIntegrationTestBase {
// start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
// start participants
@@ -231,10 +231,10 @@ public class TestDrop extends ZkIntegrationTestBase {
String instanceName = "localhost_" + (12918 + i);
if (i == 0) {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].setTransition(new ErrTransition(errTransitions));
} else {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
}
participants[i].syncStart();
}
@@ -243,24 +243,23 @@ public class TestDrop extends ZkIntegrationTestBase {
errStateMap.put("TestDB0", new HashMap<String, String>());
errStateMap.get("TestDB0").put("TestDB0_4", "localhost_12918");
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName, errStateMap));
Assert.assertTrue(result);
// drop resource containing error partitions should invoke error->dropped transition
// if error happens during error->dropped transition, partition should be disabled
ClusterSetup.processCommandLineArgs(new String[] {
- "--zkSvr", ZK_ADDR, "--dropResource", clusterName, "TestDB0"
+ "--zkSvr", _zkaddr, "--dropResource", clusterName, "TestDB0"
});
// make sure TestDB0_4 stay in ERROR state and is disabled
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName, errStateMap));
Assert.assertTrue(result);
- ZKHelixDataAccessor accessor =
- new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+ ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig("localhost_12918"));
List<String> disabledPartitions = config.getDisabledPartitions();
@@ -280,8 +279,9 @@ public class TestDrop extends ZkIntegrationTestBase {
Assert.assertEquals(stateMap.get("localhost_12918"), HelixDefinedState.ERROR.name());
// localhost_12918 should have TestDB0_4 in ERROR state
- CurrentState cs = accessor.getProperty(keyBuilder.currentState(participants[0].getInstanceName(),
- participants[0].getSessionId(), "TestDB0"));
+ CurrentState cs =
+ accessor.getProperty(keyBuilder.currentState(participants[0].getInstanceName(),
+ participants[0].getSessionId(), "TestDB0"));
Map<String, String> partitionStateMap = cs.getPartitionStateMap();
Assert.assertEquals(partitionStateMap.size(), 1);
Assert.assertEquals(partitionStateMap.keySet().iterator().next(), "TestDB0_4");
@@ -291,7 +291,8 @@ public class TestDrop extends ZkIntegrationTestBase {
for (int i = 1; i < n; i++) {
String instanceName = participants[i].getInstanceName();
String sessionId = participants[i].getSessionId();
- Assert.assertNull(accessor.getProperty(keyBuilder.currentState(instanceName, sessionId, "TestDB0")));
+ Assert.assertNull(accessor.getProperty(keyBuilder.currentState(instanceName, sessionId,
+ "TestDB0")));
}
// clean up
@@ -315,7 +316,7 @@ public class TestDrop extends ZkIntegrationTestBase {
MockParticipantManager[] participants = new MockParticipantManager[n];
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -334,14 +335,13 @@ public class TestDrop extends ZkIntegrationTestBase {
isBuilder.assignInstanceAndState("TestDB0_1", "localhost_12919", "MASTER");
isBuilder.assignInstanceAndState("TestDB0_1", "localhost_12918", "SLAVE");
- HelixDataAccessor accessor =
- new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+ HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
accessor.setProperty(keyBuilder.idealStates("TestDB0"), isBuilder.build());
// start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
// start participants
@@ -352,10 +352,10 @@ public class TestDrop extends ZkIntegrationTestBase {
String instanceName = "localhost_" + (12918 + i);
if (i == 0) {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].setTransition(new ErrTransition(errTransitions));
} else {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
}
participants[i].syncStart();
}
@@ -364,18 +364,18 @@ public class TestDrop extends ZkIntegrationTestBase {
errStateMap.put("TestDB0", new HashMap<String, String>());
errStateMap.get("TestDB0").put("TestDB0_0", "localhost_12918");
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName, errStateMap));
Assert.assertTrue(result);
// drop resource containing error partitions should drop the partition successfully
ClusterSetup.processCommandLineArgs(new String[] {
- "--zkSvr", ZK_ADDR, "--dropResource", clusterName, "TestDB0"
+ "--zkSvr", _zkaddr, "--dropResource", clusterName, "TestDB0"
});
// make sure TestDB0_0 partition is dropped
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result, "Should be empty exeternal-view");
@@ -402,7 +402,7 @@ public class TestDrop extends ZkIntegrationTestBase {
MockParticipantManager[] participants = new MockParticipantManager[n];
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -413,41 +413,41 @@ public class TestDrop extends ZkIntegrationTestBase {
// start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
// start participants
for (int i = 0; i < n; i++) {
String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
}
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// add schemata resource group
String command =
- "--zkSvr " + ZK_ADDR + " --addResource " + clusterName
+ "--zkSvr " + _zkaddr + " --addResource " + clusterName
+ " schemata 1 STORAGE_DEFAULT_SM_SCHEMATA";
ClusterSetup.processCommandLineArgs(command.split("\\s+"));
- command = "--zkSvr " + ZK_ADDR + " --rebalance " + clusterName + " schemata " + n;
+ command = "--zkSvr " + _zkaddr + " --rebalance " + clusterName + " schemata " + n;
ClusterSetup.processCommandLineArgs(command.split("\\s+"));
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// drop schemata resource group
// System.out.println("Dropping schemata resource group...");
- command = "--zkSvr " + ZK_ADDR + " --dropResource " + clusterName + " schemata";
+ command = "--zkSvr " + _zkaddr + " --dropResource " + clusterName + " schemata";
ClusterSetup.processCommandLineArgs(command.split("\\s+"));
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
@@ -474,7 +474,7 @@ public class TestDrop extends ZkIntegrationTestBase {
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -483,12 +483,11 @@ public class TestDrop extends ZkIntegrationTestBase {
2, // replicas
"MasterSlave", true); // do rebalance
- ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
- ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, baseAccessor);
+ ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
// start participants
@@ -496,13 +495,13 @@ public class TestDrop extends ZkIntegrationTestBase {
for (int i = 0; i < n; i++) {
String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
}
boolean result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
@@ -515,7 +514,7 @@ public class TestDrop extends ZkIntegrationTestBase {
result =
ClusterStateVerifier
- .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestDropResource.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDropResource.java b/helix-core/src/test/java/org/apache/helix/integration/TestDropResource.java
index 047ea75..d4faf84 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDropResource.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDropResource.java
@@ -35,15 +35,15 @@ public class TestDropResource extends ZkStandAloneCMTestBase {
boolean result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, CLUSTER_NAME));
+ _zkaddr, CLUSTER_NAME));
Assert.assertTrue(result);
- String command = "-zkSvr " + ZK_ADDR + " -dropResource " + CLUSTER_NAME + " " + "MyDB";
+ String command = "-zkSvr " + _zkaddr + " -dropResource " + CLUSTER_NAME + " " + "MyDB";
ClusterSetup.processCommandLineArgs(command.split(" "));
TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, CLUSTER_NAME, "MyDB",
TestHelper.<String> setOf("localhost_12918", "localhost_12919", "localhost_12920",
- "localhost_12921", "localhost_12922"), ZK_ADDR);
+ "localhost_12921", "localhost_12922"), _zkaddr);
}
@Test()
@@ -54,7 +54,7 @@ public class TestDropResource extends ZkStandAloneCMTestBase {
boolean verifyResult =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, CLUSTER_NAME));
+ _zkaddr, CLUSTER_NAME));
Assert.assertTrue(verifyResult);
String hostToKill = "localhost_12920";
@@ -62,18 +62,18 @@ public class TestDropResource extends ZkStandAloneCMTestBase {
_participants[2].syncStop();
Thread.sleep(1000);
- String command = "-zkSvr " + ZK_ADDR + " -dropResource " + CLUSTER_NAME + " " + "MyDB2";
+ String command = "-zkSvr " + _zkaddr + " -dropResource " + CLUSTER_NAME + " " + "MyDB2";
ClusterSetup.processCommandLineArgs(command.split(" "));
TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, CLUSTER_NAME, "MyDB2",
TestHelper.<String> setOf("localhost_12918", "localhost_12919",
- /* "localhost_12920", */"localhost_12921", "localhost_12922"), ZK_ADDR);
+ /* "localhost_12920", */"localhost_12921", "localhost_12922"), _zkaddr);
- _participants[2] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, hostToKill);
+ _participants[2] = new MockParticipantManager(_zkaddr, CLUSTER_NAME, hostToKill);
_participants[2].syncStart();
TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, CLUSTER_NAME, "MyDB2",
TestHelper.<String> setOf("localhost_12918", "localhost_12919", "localhost_12920",
- "localhost_12921", "localhost_12922"), ZK_ADDR);
+ "localhost_12921", "localhost_12922"), _zkaddr);
}
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestEnablePartitionDuringDisable.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestEnablePartitionDuringDisable.java b/helix-core/src/test/java/org/apache/helix/integration/TestEnablePartitionDuringDisable.java
index 0291844..83e3001 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestEnablePartitionDuringDisable.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestEnablePartitionDuringDisable.java
@@ -30,6 +30,7 @@ import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.mock.participant.MockTransition;
import org.apache.helix.model.Message;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
@@ -37,7 +38,7 @@ import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestEnablePartitionDuringDisable extends ZkIntegrationTestBase {
+public class TestEnablePartitionDuringDisable extends ZkTestBase {
private static Logger LOG = Logger.getLogger(TestEnablePartitionDuringDisable.class);
static {
@@ -63,7 +64,7 @@ public class TestEnablePartitionDuringDisable extends ZkIntegrationTestBase {
try {
String command =
- "--zkSvr " + ZK_ADDR + " --enablePartition true " + clusterName
+ "--zkSvr " + _zkaddr + " --enablePartition true " + clusterName
+ " localhost_12919 TestDB0 TestDB0_0";
ClusterSetup.processCommandLineArgs(command.split("\\s+"));
@@ -89,7 +90,7 @@ public class TestEnablePartitionDuringDisable extends ZkIntegrationTestBase {
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -99,7 +100,7 @@ public class TestEnablePartitionDuringDisable extends ZkIntegrationTestBase {
"MasterSlave", true); // do rebalance
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
// start participants
@@ -109,22 +110,22 @@ public class TestEnablePartitionDuringDisable extends ZkIntegrationTestBase {
String instanceName = "localhost_" + (12918 + i);
if (instanceName.equals("localhost_12919")) {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].setTransition(transition);
} else {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
}
participants[i].syncStart();
}
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// disable partitions
String command =
- "--zkSvr " + ZK_ADDR + " --enablePartition false " + clusterName
+ "--zkSvr " + _zkaddr + " --enablePartition false " + clusterName
+ " localhost_12919 TestDB0 TestDB0_0";
ClusterSetup.processCommandLineArgs(command.split("\\s+"));
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java b/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java
index 9b340e3..4119fc6 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java
@@ -21,31 +21,28 @@ package org.apache.helix.integration;
import java.util.Date;
-import org.apache.helix.BaseDataAccessor;
import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixManager;
import org.apache.helix.InstanceType;
import org.apache.helix.PropertyKey;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.api.id.StateModelDefId;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.manager.zk.ZKHelixAdmin;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZKHelixManager;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.ExternalView;
import org.apache.helix.model.IdealState.RebalanceMode;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.helix.tools.ClusterStateVerifier.ZkVerifier;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestEntropyFreeNodeBounce extends ZkUnitTestBase {
+public class TestEntropyFreeNodeBounce extends ZkTestBase {
@Test
public void testBounceAll() throws Exception {
// pick numbers that don't divide evenly
@@ -62,7 +59,7 @@ public class TestEntropyFreeNodeBounce extends ZkUnitTestBase {
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
// Set up cluster
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -82,13 +79,12 @@ public class TestEntropyFreeNodeBounce extends ZkUnitTestBase {
// Start the controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller");
controller.syncStart();
// get an admin and accessor
- HelixAdmin helixAdmin = new ZKHelixAdmin(_gZkClient);
- BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
- HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, baseAccessor);
+ HelixAdmin helixAdmin = new ZKHelixAdmin(_zkclient);
+ HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
// do the test
@@ -96,7 +92,7 @@ public class TestEntropyFreeNodeBounce extends ZkUnitTestBase {
Thread.sleep(1000);
// ensure that the external view coalesces
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
ExternalView stableExternalView =
@@ -129,7 +125,7 @@ public class TestEntropyFreeNodeBounce extends ZkUnitTestBase {
private HelixManager createParticipant(String clusterName, String instanceName) {
HelixManager participant =
- new ZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, ZK_ADDR);
+ new ZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, _zkaddr);
participant.getStateMachineEngine().registerStateModelFactory(
StateModelDefId.from("OnlineOffline"), new TestHelixConnection.MockStateModelFactory());
return participant;
@@ -138,16 +134,14 @@ public class TestEntropyFreeNodeBounce extends ZkUnitTestBase {
/**
* Simple verifier: just check that the external view matches a reference
*/
- private static class MatchingExternalViewVerifier implements ZkVerifier {
+ private static class MatchingExternalViewVerifier extends ZkVerifier {
private final HelixDataAccessor _accessor;
private final ExternalView _reference;
- private final String _clusterName;
public MatchingExternalViewVerifier(ExternalView reference, String clusterName) {
- BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
- _accessor = new ZKHelixDataAccessor(clusterName, baseAccessor);
+ super(clusterName, _zkclient);
+ _accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
_reference = reference;
- _clusterName = clusterName;
}
@Override
@@ -156,16 +150,5 @@ public class TestEntropyFreeNodeBounce extends ZkUnitTestBase {
_accessor.getProperty(_accessor.keyBuilder().externalView(_reference.getResourceName()));
return _reference.equals(externalView);
}
-
- @Override
- public ZkClient getZkClient() {
- return _gZkClient;
- }
-
- @Override
- public String getClusterName() {
- return _clusterName;
- }
-
}
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java b/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
index 71c4339..edc2965 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
@@ -30,24 +30,26 @@ import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKHelixAdmin;
import org.apache.helix.mock.participant.ErrTransition;
+import org.apache.helix.testutil.TestUtil;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterStateVerifier;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestErrorPartition extends ZkIntegrationTestBase {
+public class TestErrorPartition extends ZkTestBase {
@Test()
public void testErrorPartition() throws Exception {
- String clusterName = getShortClassName();
+ String clusterName = TestUtil.getTestName();
MockParticipantManager[] participants = new MockParticipantManager[5];
System.out.println("START testErrorPartition() at " + new Date(System.currentTimeMillis()));
- ZKHelixAdmin tool = new ZKHelixAdmin(_gZkClient);
+ ZKHelixAdmin tool = new ZKHelixAdmin(_zkclient);
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, "localhost", "TestDB", 1, 10, 5, 3,
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, "localhost", "TestDB", 1, 10, 5, 3,
"MasterSlave", true);
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
for (int i = 0; i < 5; i++) {
@@ -59,10 +61,10 @@ public class TestErrorPartition extends ZkIntegrationTestBase {
put("SLAVE-MASTER", TestHelper.setOf("TestDB0_4"));
}
};
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].setTransition(new ErrTransition(errPartitions));
} else {
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
}
participants[i].syncStart();
}
@@ -72,7 +74,7 @@ public class TestErrorPartition extends ZkIntegrationTestBase {
errStates.get("TestDB0").put("TestDB0_4", "localhost_12918");
boolean result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, clusterName, errStates));
+ _zkaddr, clusterName, errStates));
Assert.assertTrue(result);
Map<String, Set<String>> errorStateMap = new HashMap<String, Set<String>>() {
@@ -82,7 +84,7 @@ public class TestErrorPartition extends ZkIntegrationTestBase {
};
// verify "TestDB0_0", "localhost_12918" is in ERROR state
- TestHelper.verifyState(clusterName, ZK_ADDR, errorStateMap, "ERROR");
+ TestHelper.verifyState(clusterName, _zkaddr, errorStateMap, "ERROR");
// disable a partition on a node with error state
tool.enablePartition(false, clusterName, "localhost_12918", "TestDB0",
@@ -90,17 +92,17 @@ public class TestErrorPartition extends ZkIntegrationTestBase {
result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, clusterName, errStates));
+ _zkaddr, clusterName, errStates));
Assert.assertTrue(result);
- TestHelper.verifyState(clusterName, ZK_ADDR, errorStateMap, "ERROR");
+ TestHelper.verifyState(clusterName, _zkaddr, errorStateMap, "ERROR");
// disable a node with error state
tool.enableInstance(clusterName, "localhost_12918", false);
result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, clusterName, errStates));
+ _zkaddr, clusterName, errStates));
Assert.assertTrue(result);
// make sure after restart stale ERROR state is gone
@@ -111,14 +113,14 @@ public class TestErrorPartition extends ZkIntegrationTestBase {
participants[0].syncStop();
result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, clusterName));
+ _zkaddr, clusterName));
Assert.assertTrue(result);
- participants[0] = new MockParticipantManager(ZK_ADDR, clusterName, "localhost_12918");
+ participants[0] = new MockParticipantManager(_zkaddr, clusterName, "localhost_12918");
new Thread(participants[0]).start();
result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, clusterName));
+ _zkaddr, clusterName));
Assert.assertTrue(result);
// clean up
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestExpandCluster.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestExpandCluster.java b/helix-core/src/test/java/org/apache/helix/integration/TestExpandCluster.java
index 8268679..a398543 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestExpandCluster.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestExpandCluster.java
@@ -49,7 +49,7 @@ public class TestExpandCluster extends ZkStandAloneCMTestBase {
_setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, DB3);
for (int i = 0; i < 5; i++) {
- String storageNodeName = PARTICIPANT_PREFIX + "_" + (27960 + i);
+ String storageNodeName = "localhost_" + (27960 + i);
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
}
String command = "-zkSvr localhost:2183 -expandCluster " + CLUSTER_NAME;
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestExternalViewUpdates.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestExternalViewUpdates.java b/helix-core/src/test/java/org/apache/helix/integration/TestExternalViewUpdates.java
index 3e31f17..835f81e 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestExternalViewUpdates.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestExternalViewUpdates.java
@@ -25,10 +25,10 @@ import java.util.List;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
+import org.apache.helix.testutil.TestUtil;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
@@ -36,15 +36,15 @@ import org.apache.zookeeper.data.Stat;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestExternalViewUpdates extends ZkIntegrationTestBase {
+public class TestExternalViewUpdates extends ZkTestBase {
@Test
public void testExternalViewUpdates() throws Exception {
System.out.println("START testExternalViewUpdates at " + new Date(System.currentTimeMillis()));
- String clusterName = getShortClassName();
+ String clusterName = TestUtil.getTestName();
MockParticipantManager[] participants = new MockParticipantManager[5];
int resourceNb = 10;
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
resourceNb, // resources
@@ -54,32 +54,31 @@ public class TestExternalViewUpdates extends ZkIntegrationTestBase {
"MasterSlave", true); // do rebalance
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
// start participants
for (int i = 0; i < 5; i++) {
String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
}
boolean result =
ClusterStateVerifier
- .verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, clusterName));
+ .verifyByZkCallback(new MasterNbInExtViewVerifier(_zkaddr, clusterName));
Assert.assertTrue(result);
result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// need to verify that each ExternalView's version number is 2
Builder keyBuilder = new Builder(clusterName);
- ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
String parentPath = keyBuilder.externalViews().getPath();
- List<String> childNames = accessor.getChildNames(parentPath, 0);
+ List<String> childNames = _baseAccessor.getChildNames(parentPath, 0);
List<String> paths = new ArrayList<String>();
for (String name : childNames) {
@@ -88,7 +87,7 @@ public class TestExternalViewUpdates extends ZkIntegrationTestBase {
// Stat[] stats = accessor.getStats(paths);
for (String path : paths) {
- Stat stat = accessor.getStat(path, 0);
+ Stat stat = _baseAccessor.getStat(path, 0);
Assert.assertTrue(stat.getVersion() <= 2, "ExternalView should be updated at most 2 times");
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestFullAutoNodeTagging.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestFullAutoNodeTagging.java b/helix-core/src/test/java/org/apache/helix/integration/TestFullAutoNodeTagging.java
index 021f63a..6704fa9 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestFullAutoNodeTagging.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestFullAutoNodeTagging.java
@@ -23,27 +23,23 @@ import java.util.Date;
import java.util.Map;
import java.util.Set;
-import org.apache.helix.BaseDataAccessor;
import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.PropertyKey;
import org.apache.helix.TestHelper;
import org.apache.helix.TestHelper.Verifier;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKHelixAdmin;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.ExternalView;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.IdealState.RebalanceMode;
+import org.apache.helix.testutil.HelixTestUtil;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.helix.tools.ClusterStateVerifier.ZkVerifier;
-import org.apache.helix.util.ZKClientPool;
import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -55,7 +51,7 @@ import com.google.common.collect.Sets;
/**
* Test that node tagging behaves correctly in FULL_AUTO mode
*/
-public class TestFullAutoNodeTagging extends ZkUnitTestBase {
+public class TestFullAutoNodeTagging extends ZkTestBase {
private static final Logger LOG = Logger.getLogger(TestFullAutoNodeTagging.class);
@Test
@@ -72,7 +68,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
// Set up cluster
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestResource", // resource name prefix
1, // resources
@@ -83,14 +79,13 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
true); // do rebalance
// Tag the resource
- final HelixAdmin helixAdmin = new ZKHelixAdmin(_gZkClient);
+ final HelixAdmin helixAdmin = new ZKHelixAdmin(_zkclient);
IdealState idealState = helixAdmin.getResourceIdealState(clusterName, RESOURCE_NAME);
idealState.setInstanceGroupTag(TAG);
helixAdmin.setResourceIdealState(clusterName, RESOURCE_NAME, idealState);
// Get a data accessor
- final HelixDataAccessor accessor =
- new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+ final HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
final PropertyKey.Builder keyBuilder = accessor.keyBuilder();
// Tag the participants
@@ -101,7 +96,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
// Start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller");
controller.syncStart();
// Start participants
@@ -109,7 +104,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
for (int i = 0; i < NUM_PARTICIPANTS; i++) {
final String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
}
@@ -120,8 +115,8 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
@Override
public boolean verify() throws Exception {
ExternalView externalView =
- pollForProperty(ExternalView.class, accessor, keyBuilder.externalView(RESOURCE_NAME),
- true);
+ HelixTestUtil.pollForProperty(ExternalView.class, accessor,
+ keyBuilder.externalView(RESOURCE_NAME), true);
if (externalView == null) {
return false;
}
@@ -181,7 +176,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
// Set up cluster
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -192,14 +187,14 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
true); // do rebalance
// tag the resource
- HelixAdmin helixAdmin = new ZKHelixAdmin(ZK_ADDR);
+ HelixAdmin helixAdmin = new ZKHelixAdmin(_zkaddr);
IdealState idealState = helixAdmin.getResourceIdealState(clusterName, RESOURCE_NAME);
idealState.setInstanceGroupTag(TAG);
helixAdmin.setResourceIdealState(clusterName, RESOURCE_NAME, idealState);
// start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller");
controller.syncStart();
// start participants
@@ -207,13 +202,14 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
for (int i = 0; i < NUM_PARTICIPANTS; i++) {
final String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
}
Thread.sleep(1000);
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new EmptyZkVerifier(clusterName, RESOURCE_NAME));
+ ClusterStateVerifier.verifyByZkCallback(new HelixTestUtil.EmptyZkVerifier(clusterName,
+ RESOURCE_NAME, _zkclient));
Assert.assertTrue(result, "External view and current state must be empty");
// cleanup
@@ -248,7 +244,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
// Set up cluster
- TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
"localhost", // participant name prefix
"TestDB", // resource name prefix
1, // resources
@@ -259,7 +255,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
true); // do rebalance
// tag the resource and participants
- HelixAdmin helixAdmin = new ZKHelixAdmin(ZK_ADDR);
+ HelixAdmin helixAdmin = new ZKHelixAdmin(_zkaddr);
for (String taggedNode : TAGGED_NODES) {
helixAdmin.addInstanceTag(clusterName, taggedNode, TAG);
}
@@ -269,7 +265,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
// start controller
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller");
controller.syncStart();
// start participants
@@ -277,7 +273,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
for (int i = 0; i < NUM_PARTICIPANTS; i++) {
final String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
// ensure that everything is valid if this is a tagged node that is starting
@@ -285,7 +281,7 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
// make sure that the best possible matches the external view
Thread.sleep(500);
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
@@ -319,12 +315,10 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
/**
* Checker for basic validity of the external view given node tagging requirements
*/
- private static class TaggedZkVerifier implements ZkVerifier {
- private final String _clusterName;
+ private static class TaggedZkVerifier extends ZkVerifier {
private final String _resourceName;
private final String[] _taggedNodes;
private final boolean _isEmptyAllowed;
- private final ZkClient _zkClient;
/**
* Create a verifier for a specific cluster and resource
@@ -335,17 +329,15 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
*/
public TaggedZkVerifier(String clusterName, String resourceName, String[] taggedNodes,
boolean isEmptyAllowed) {
- _clusterName = clusterName;
+ super(clusterName, _zkclient);
_resourceName = resourceName;
_taggedNodes = taggedNodes;
_isEmptyAllowed = isEmptyAllowed;
- _zkClient = ZKClientPool.getZkClient(ZK_ADDR);
}
@Override
public boolean verify() {
- BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_zkClient);
- HelixDataAccessor accessor = new ZKHelixDataAccessor(_clusterName, baseAccessor);
+ HelixDataAccessor accessor = new ZKHelixDataAccessor(getClusterName(), _baseAccessor);
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
ExternalView externalView = accessor.getProperty(keyBuilder.externalView(_resourceName));
@@ -466,15 +458,5 @@ public class TestFullAutoNodeTagging extends ZkUnitTestBase {
}
return total / countMap.size();
}
-
- @Override
- public ZkClient getZkClient() {
- return _zkClient;
- }
-
- @Override
- public String getClusterName() {
- return _clusterName;
- }
}
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java b/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java
index d0c9bb8..6aac417 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java
@@ -30,7 +30,6 @@ import org.apache.helix.HelixParticipant;
import org.apache.helix.NotificationContext;
import org.apache.helix.PropertyKey;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.api.State;
import org.apache.helix.api.accessor.ClusterAccessor;
import org.apache.helix.api.config.ClusterConfig;
@@ -52,11 +51,12 @@ import org.apache.helix.participant.statemachine.HelixStateModelFactory;
import org.apache.helix.participant.statemachine.StateModel;
import org.apache.helix.participant.statemachine.StateModelInfo;
import org.apache.helix.participant.statemachine.Transition;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestHelixConnection extends ZkUnitTestBase {
+public class TestHelixConnection extends ZkTestBase {
private static final Logger LOG = Logger.getLogger(TestHelixConnection.class.getName());
@StateModelInfo(initialState = "OFFLINE", states = {
@@ -96,7 +96,6 @@ public class TestHelixConnection extends ZkUnitTestBase {
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
- String zkAddr = ZK_ADDR;
ClusterId clusterId = ClusterId.from(clusterName);
ControllerId controllerId = ControllerId.from("controller");
final ParticipantId participantId = ParticipantId.from("participant1");
@@ -109,7 +108,7 @@ public class TestHelixConnection extends ZkUnitTestBase {
StateModelDefId stateModelDefId = StateModelDefId.from("MasterSlave");
// create connection
- HelixConnection connection = new ZkHelixConnection(zkAddr);
+ HelixConnection connection = new ZkHelixConnection(_zkaddr);
connection.connect();
// setup cluster
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java b/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
index 9423326..2d95811 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
@@ -27,23 +27,22 @@ import org.apache.helix.HelixManager;
import org.apache.helix.NotificationContext;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.participant.CustomCodeCallbackHandler;
import org.apache.helix.participant.HelixCustomCodeRunner;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;
-public class TestHelixCustomCodeRunner extends ZkIntegrationTestBase {
+public class TestHelixCustomCodeRunner extends ZkTestBase {
private static Logger LOG = Logger.getLogger(TestHelixCustomCodeRunner.class);
- private final String _clusterName = "CLUSTER_" + getShortClassName();
+ private final String _clusterName = "TestHelixCustomCodeRunner";
private final int _nodeNb = 5;
private final int _startPort = 12918;
private final MockCallback _callback = new MockCallback();
@@ -67,7 +66,7 @@ public class TestHelixCustomCodeRunner extends ZkIntegrationTestBase {
Thread.sleep(2000);
}
- HelixCustomCodeRunner customCodeRunner = new HelixCustomCodeRunner(manager, ZK_ADDR);
+ HelixCustomCodeRunner customCodeRunner = new HelixCustomCodeRunner(manager, _zkaddr);
customCodeRunner.invoke(_callback).on(ChangeType.LIVE_INSTANCE)
.usingLeaderStandbyModel("TestParticLeader").start();
} catch (Exception e) {
@@ -79,7 +78,7 @@ public class TestHelixCustomCodeRunner extends ZkIntegrationTestBase {
public void testCustomCodeRunner() throws Exception {
System.out.println("START " + _clusterName + " at " + new Date(System.currentTimeMillis()));
- TestHelper.setupCluster(_clusterName, ZK_ADDR, _startPort, "localhost", // participant name
+ TestHelper.setupCluster(_clusterName, _zkaddr, _startPort, "localhost", // participant name
// prefix
"TestDB", // resource name prefix
1, // resourceNb
@@ -89,21 +88,21 @@ public class TestHelixCustomCodeRunner extends ZkIntegrationTestBase {
"MasterSlave", true);
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, _clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, _clusterName, "controller_0");
controller.syncStart();
MockParticipantManager[] participants = new MockParticipantManager[5];
for (int i = 0; i < _nodeNb; i++) {
String instanceName = "localhost_" + (_startPort + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, _clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, _clusterName, instanceName);
registerCustomCodeRunner(participants[i]);
participants[i].syncStart();
}
boolean result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
- ZK_ADDR, _clusterName));
+ _zkaddr, _clusterName));
Assert.assertTrue(result);
Thread.sleep(1000); // wait for the INIT type callback to finish
@@ -112,7 +111,7 @@ public class TestHelixCustomCodeRunner extends ZkIntegrationTestBase {
// add a new live instance
HelixDataAccessor accessor =
- new ZKHelixDataAccessor(_clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+ new ZKHelixDataAccessor(_clusterName, _baseAccessor);
Builder keyBuilder = accessor.keyBuilder();
LiveInstance newLiveIns = new LiveInstance("newLiveInstance");
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestHelixInstanceTag.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestHelixInstanceTag.java b/helix-core/src/test/java/org/apache/helix/integration/TestHelixInstanceTag.java
index 1f906d0..b3aa647 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestHelixInstanceTag.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestHelixInstanceTag.java
@@ -49,7 +49,7 @@ public class TestHelixInstanceTag extends ZkStandAloneCMTestBase {
boolean result =
ClusterStateVerifier
- .verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
CLUSTER_NAME)));
Assert.assertTrue(result, "Cluster verification fails");
@@ -78,7 +78,7 @@ public class TestHelixInstanceTag extends ZkStandAloneCMTestBase {
result =
ClusterStateVerifier
- .verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+ .verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr,
CLUSTER_NAME)));
Assert.assertTrue(result, "Cluster verification fails");
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestHelixUsingDifferentParams.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestHelixUsingDifferentParams.java b/helix-core/src/test/java/org/apache/helix/integration/TestHelixUsingDifferentParams.java
index c414c1b..9e74978 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestHelixUsingDifferentParams.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestHelixUsingDifferentParams.java
@@ -21,15 +21,18 @@ package org.apache.helix.integration;
import java.util.Date;
+import org.apache.helix.testutil.TestUtil;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.log4j.Logger;
import org.testng.annotations.Test;
-public class TestHelixUsingDifferentParams extends ZkIntegrationTestBase {
+public class TestHelixUsingDifferentParams extends ZkTestBase {
private static Logger LOG = Logger.getLogger(TestHelixUsingDifferentParams.class);
@Test()
public void testCMUsingDifferentParams() throws Exception {
- System.out.println("START " + getShortClassName() + " at "
+ String testName = TestUtil.getTestName();
+ System.out.println("START " + testName + " at "
+ new Date(System.currentTimeMillis()));
int numResourceArray[] = new int[] {
@@ -56,15 +59,15 @@ public class TestHelixUsingDifferentParams extends ZkIntegrationTestBase {
System.out.println("START " + uniqClusterName + " at "
+ new Date(System.currentTimeMillis()));
- TestDriver.setupCluster(uniqClusterName, ZK_ADDR, numResources,
+ TestDriver.setupCluster(uniqClusterName, _zkaddr, numResources,
numPartitionsPerResource, numInstance, replica);
for (int i = 0; i < numInstance; i++) {
- TestDriver.startDummyParticipant(uniqClusterName, i);
+ TestDriver.startDummyParticipant(_zkaddr, uniqClusterName, i);
}
- TestDriver.startController(uniqClusterName);
- TestDriver.verifyCluster(uniqClusterName, 1000, 50 * 1000);
+ TestDriver.startController(_zkaddr, uniqClusterName);
+ TestDriver.verifyCluster(_zkaddr, uniqClusterName, 1000, 50 * 1000);
TestDriver.stopCluster(uniqClusterName);
System.out.println("END " + uniqClusterName + " at "
@@ -75,6 +78,6 @@ public class TestHelixUsingDifferentParams extends ZkIntegrationTestBase {
}
System.out
- .println("END " + getShortClassName() + " at " + new Date(System.currentTimeMillis()));
+ .println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
}
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestInstanceAutoJoin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestInstanceAutoJoin.java b/helix-core/src/test/java/org/apache/helix/integration/TestInstanceAutoJoin.java
index 2761634..c6d963d 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestInstanceAutoJoin.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestInstanceAutoJoin.java
@@ -42,9 +42,9 @@ public class TestInstanceAutoJoin extends ZkStandAloneCMTestBase {
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db2, 1);
String instance2 = "localhost_279699";
- // StartCMResult result = TestHelper.startDummyProcess(ZK_ADDR, CLUSTER_NAME, instance2);
+ // StartCMResult result = TestHelper.startDummyProcess(zkaddr, CLUSTER_NAME, instance2);
MockParticipantManager newParticipant =
- new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instance2);
+ new MockParticipantManager(_zkaddr, CLUSTER_NAME, instance2);
newParticipant.syncStart();
Thread.sleep(500);
@@ -56,7 +56,7 @@ public class TestInstanceAutoJoin extends ZkStandAloneCMTestBase {
manager.getConfigAccessor().set(scope, ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN, "true");
- newParticipant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instance2);
+ newParticipant = new MockParticipantManager(_zkaddr, CLUSTER_NAME, instance2);
newParticipant.syncStart();
Thread.sleep(500);
http://git-wip-us.apache.org/repos/asf/helix/blob/410815d0/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java b/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
index f2bf7f6..1f1af0e 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
@@ -27,7 +27,6 @@ import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.api.id.StateModelDefId;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
@@ -37,18 +36,18 @@ import org.apache.helix.model.IdealState;
import org.apache.helix.model.IdealState.RebalanceMode;
import org.apache.helix.model.InstanceConfig;
import org.apache.helix.model.StateModelDefinition;
+import org.apache.helix.testutil.ZkTestBase;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.helix.tools.StateModelConfigGenerator;
import org.testng.Assert;
-import org.testng.annotations.Test;
// Helix-50: integration test for generate message based on state priority
-public class TestInvalidAutoIdealState extends ZkUnitTestBase {
+public class TestInvalidAutoIdealState extends ZkTestBase {
// TODO Disable this test, need refactor it for testing message generation based on state priority
// @Test
void testInvalidReplica2() throws Exception {
- HelixAdmin admin = new ZKHelixAdmin(ZK_ADDR);
+ HelixAdmin admin = new ZKHelixAdmin(_zkaddr);
// create cluster
String className = TestHelper.getTestClassName();
@@ -96,16 +95,16 @@ public class TestInvalidAutoIdealState extends ZkUnitTestBase {
for (int i = 0; i < n; i++) {
String instanceName = "localhost_" + (12918 + i);
- participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+ participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
participants[i].syncStart();
}
ClusterControllerManager controller =
- new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
+ new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
controller.syncStart();
boolean result =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+ ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);