You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by vi...@apache.org on 2013/07/22 19:47:51 UTC
[2/2] git commit: HELIX-140: In ClusterSetup the removeConfig is
wrong wired to getConfig
HELIX-140: In ClusterSetup the removeConfig is wrong wired to getConfig
Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/ba1628e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/ba1628e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/ba1628e7
Branch: refs/heads/helix_api_refactoring
Commit: ba1628e76e43555c376ebef2293c88131a4f8c85
Parents: 6bb6e2c
Author: zzhang <zz...@apache.org>
Authored: Wed Jul 17 17:09:21 2013 -0700
Committer: zzhang <zz...@apache.org>
Committed: Wed Jul 17 17:09:21 2013 -0700
----------------------------------------------------------------------
.../org/apache/helix/tools/ClusterSetup.java | 2 +-
.../apache/helix/tools/TestClusterSetup.java | 26 +++++++++++++-------
2 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ba1628e7/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java b/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
index d031a6a..4260e87 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
@@ -1071,7 +1071,7 @@ public class ClusterSetup
OptionBuilder.hasArgs(3)
.isRequired(false)
.withArgName("ConfigScope(e.g. RESOURCE) ConfigScopeArgs(e.g. myCluster,testDB) Keys(e.g. k1,k2)")
- .withLongOpt(getConfig)
+ .withLongOpt(removeConfig)
.withDescription("Remove configs")
.create();
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ba1628e7/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 b720912..e703ad9 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
@@ -368,7 +368,7 @@ public class TestClusterSetup extends ZkUnitTestBase
}
@Test()
- public void testSetGetConfig() throws Exception
+ public void testSetGetRemoveParticipantConfig() throws Exception
{
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
@@ -377,22 +377,30 @@ public class TestClusterSetup extends ZkUnitTestBase
System.out.println("START " + clusterName + " at "
+ new Date(System.currentTimeMillis()));
- // basic
_clusterSetup.addCluster(clusterName, true);
_clusterSetup.addInstanceToCluster(clusterName, "localhost_0");
+
+ // test set/get/remove instance configs
String scopeArgs = clusterName + ",localhost_0";
String keyValueMap = "key1=value1,key2=value2";
String keys = "key1,key2";
- _clusterSetup.setConfig(ConfigScopeProperty.PARTICIPANT, scopeArgs, keyValueMap);
- String valuesStr = _clusterSetup.getConfig(ConfigScopeProperty.PARTICIPANT, scopeArgs, keys);
+ ClusterSetup.processCommandLineArgs(new String[]{"--zkSvr", ZK_ADDR, "--setConfig", ConfigScopeProperty.PARTICIPANT.toString(),
+ scopeArgs, keyValueMap});
// getConfig returns json-formatted key-value pairs
- ZNRecord record = new ZNRecord(ConfigScopeProperty.PARTICIPANT.toString());
- // record.setMapField(scopesStr,HelixUtil.parseCsvFormatedKeyValuePairs(propertiesStr));
- record.getSimpleFields().putAll(HelixUtil.parseCsvFormatedKeyValuePairs(keyValueMap));
+ String valuesStr = _clusterSetup.getConfig(ConfigScopeProperty.PARTICIPANT, scopeArgs, keys);
ZNRecordSerializer serializer = new ZNRecordSerializer();
- Assert.assertEquals(valuesStr, new String(serializer.serialize(record)));
-
+ ZNRecord record = (ZNRecord) serializer.deserialize(valuesStr.getBytes());
+ Assert.assertEquals(record.getSimpleField("key1"), "value1");
+ Assert.assertEquals(record.getSimpleField("key2"), "value2");
+
+ ClusterSetup.processCommandLineArgs(new String[]{"--zkSvr", ZK_ADDR, "--removeConfig", ConfigScopeProperty.PARTICIPANT.toString(),
+ scopeArgs, keys});
+ valuesStr = _clusterSetup.getConfig(ConfigScopeProperty.PARTICIPANT, scopeArgs, keys);
+ record = (ZNRecord) serializer.deserialize(valuesStr.getBytes());
+ Assert.assertNull(record.getSimpleField("key1"));
+ Assert.assertNull(record.getSimpleField("key2"));
+
System.out.println("END " + clusterName + " at "
+ new Date(System.currentTimeMillis()));
}