helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject git commit: [HELIX-397] REST GET for resources should include tag information, fix CI issue
Date Thu, 06 Mar 2014 01:59:49 GMT
Repository: helix
Updated Branches:
  refs/heads/helix-0.6.2-release cba24a53b -> 304995e75


[HELIX-397] REST GET for resources should include tag information, fix CI issue


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/304995e7
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/304995e7
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/304995e7

Branch: refs/heads/helix-0.6.2-release
Commit: 304995e75a1f65810157455b9bc416fc40bf250d
Parents: cba24a5
Author: Kanak Biscuitwala <kanak@apache.org>
Authored: Wed Mar 5 17:59:34 2014 -0800
Committer: Kanak Biscuitwala <kanak@apache.org>
Committed: Wed Mar 5 17:59:34 2014 -0800

----------------------------------------------------------------------
 .../org/apache/helix/tools/AdminTestBase.java   |   7 +-
 .../tools/TestHelixAdminScenariosRest.java      | 103 ++++++++++++--
 .../webapp/TestClusterManagementWebapp.java     |  71 ++++------
 .../apache/helix/webapp/TestTagAwareness.java   | 141 -------------------
 4 files changed, 126 insertions(+), 196 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/304995e7/helix-admin-webapp/src/test/java/org/apache/helix/tools/AdminTestBase.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/tools/AdminTestBase.java b/helix-admin-webapp/src/test/java/org/apache/helix/tools/AdminTestBase.java
index 84ed72f..c9ebed0 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/tools/AdminTestBase.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/tools/AdminTestBase.java
@@ -25,10 +25,11 @@ import org.I0Itec.zkclient.ZkServer;
 import org.apache.helix.TestHelper;
 import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.manager.zk.ZkClient;
-import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.AdminTestHelper.AdminThread;
 import org.apache.helix.util.ZKClientPool;
 import org.apache.log4j.Logger;
+import org.restlet.Client;
+import org.restlet.data.Protocol;
 import org.testng.AssertJUnit;
 import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeSuite;
@@ -41,6 +42,7 @@ public class AdminTestBase {
   protected static ZkServer _zkServer;
   protected static ZkClient _gZkClient;
   protected static ClusterSetup _gSetupTool;
+  protected static Client _gClient;
 
   static AdminThread _adminThread;
 
@@ -63,6 +65,9 @@ public class AdminTestBase {
     _adminThread = new AdminThread(ZK_ADDR, ADMIN_PORT);
     _adminThread.start();
 
+    // create a client
+    _gClient = new Client(Protocol.HTTP);
+
     // wait for the web service to start
     Thread.sleep(100);
   }

http://git-wip-us.apache.org/repos/asf/helix/blob/304995e7/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
index 6a0e331..0680764 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
@@ -25,8 +25,10 @@ import java.io.PrintWriter;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.integration.manager.ClusterControllerManager;
@@ -34,25 +36,26 @@ import org.apache.helix.integration.manager.ClusterDistributedController;
 import org.apache.helix.integration.manager.MockParticipantManager;
 import org.apache.helix.manager.zk.ZKUtil;
 import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
 import org.apache.helix.model.IdealState.IdealStateProperty;
+import org.apache.helix.model.InstanceConfig;
 import org.apache.helix.model.LiveInstance;
 import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
 import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
 import org.apache.helix.webapp.RestAdminApplication;
 import org.apache.helix.webapp.resources.ClusterRepresentationUtil;
+import org.apache.helix.webapp.resources.InstancesResource.ListInstancesWrapper;
 import org.apache.helix.webapp.resources.JsonParameters;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
-import org.restlet.Client;
 import org.restlet.Component;
 import org.restlet.Request;
 import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Method;
-import org.restlet.data.Protocol;
 import org.restlet.data.Reference;
 import org.restlet.data.Status;
 import org.restlet.representation.Representation;
@@ -95,8 +98,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "="
             + ClusterRepresentationUtil.ObjectToJson(jsonParameters), MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
     result.write(sw);
@@ -118,8 +120,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
       entity = entity + "&" + (key + "=" + extraForm.get(key));
     }
     request.setEntity(entity, MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
     result.write(sw);
@@ -132,8 +133,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
   void deleteUrl(String url, boolean hasException) throws IOException {
     Reference resourceRef = new Reference(url);
     Request request = new Request(Method.DELETE, resourceRef);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
     result.write(sw);
@@ -143,8 +143,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
   String getUrl(String url) throws IOException {
     Reference resourceRef = new Reference(url);
     Request request = new Request(Method.GET, resourceRef);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
     result.write(sw);
@@ -1026,4 +1025,88 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     response = assertSuccessPostOperation(instanceUrl, removeInstanceTagCmd(_tag1), false);
     Assert.assertFalse(response.contains(_tag1));
   }
+
+  @Test
+  public void testGetResources() throws IOException {
+    final String clusterName = "TestTagAwareness_testGetResources";
+    final String TAG = "tag";
+    final String URL_BASE =
+        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/resourceGroups";
+
+    _gSetupTool.addCluster(clusterName, true);
+    HelixAdmin admin = _gSetupTool.getClusterManagementTool();
+
+    // Add a tagged resource
+    IdealState taggedResource = new IdealState("taggedResource");
+    taggedResource.setInstanceGroupTag(TAG);
+    taggedResource.setStateModelDefRef("OnlineOffline");
+    admin.addResource(clusterName, taggedResource.getId(), taggedResource);
+
+    // Add an untagged resource
+    IdealState untaggedResource = new IdealState("untaggedResource");
+    untaggedResource.setStateModelDefRef("OnlineOffline");
+    admin.addResource(clusterName, untaggedResource.getId(), untaggedResource);
+
+    // Now make a REST call for all resources
+    Reference resourceRef = new Reference(URL_BASE);
+    Request request = new Request(Method.GET, resourceRef);
+    Response response = _gClient.handle(request);
+    ZNRecord responseRecord =
+        ClusterRepresentationUtil.JsonToObject(ZNRecord.class, response.getEntityAsText());
+
+    // Ensure that the tagged resource has information and the untagged one doesn't
+    Assert.assertNotNull(responseRecord.getMapField("ResourceTags"));
+    Assert
+        .assertEquals(TAG, responseRecord.getMapField("ResourceTags").get(taggedResource.getId()));
+    Assert.assertFalse(responseRecord.getMapField("ResourceTags").containsKey(
+        untaggedResource.getId()));
+  }
+
+  @Test
+  public void testGetInstances() throws IOException {
+    final String clusterName = "TestTagAwareness_testGetResources";
+    final String[] TAGS = {
+        "tag1", "tag2"
+    };
+    final String URL_BASE =
+        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/instances";
+
+    _gSetupTool.addCluster(clusterName, true);
+    HelixAdmin admin = _gSetupTool.getClusterManagementTool();
+
+    // Add 4 participants, each with differint tag characteristics
+    InstanceConfig instance1 = new InstanceConfig("localhost_1");
+    instance1.addTag(TAGS[0]);
+    admin.addInstance(clusterName, instance1);
+    InstanceConfig instance2 = new InstanceConfig("localhost_2");
+    instance2.addTag(TAGS[1]);
+    admin.addInstance(clusterName, instance2);
+    InstanceConfig instance3 = new InstanceConfig("localhost_3");
+    instance3.addTag(TAGS[0]);
+    instance3.addTag(TAGS[1]);
+    admin.addInstance(clusterName, instance3);
+    InstanceConfig instance4 = new InstanceConfig("localhost_4");
+    admin.addInstance(clusterName, instance4);
+
+    // Now make a REST call for all resources
+    Reference resourceRef = new Reference(URL_BASE);
+    Request request = new Request(Method.GET, resourceRef);
+    Response response = _gClient.handle(request);
+    ListInstancesWrapper responseWrapper =
+        ClusterRepresentationUtil.JsonToObject(ListInstancesWrapper.class,
+            response.getEntityAsText());
+    Map<String, List<String>> tagInfo = responseWrapper.tagInfo;
+
+    // Ensure tag ownership is reported correctly
+    Assert.assertTrue(tagInfo.containsKey(TAGS[0]));
+    Assert.assertTrue(tagInfo.containsKey(TAGS[1]));
+    Assert.assertTrue(tagInfo.get(TAGS[0]).contains("localhost_1"));
+    Assert.assertFalse(tagInfo.get(TAGS[0]).contains("localhost_2"));
+    Assert.assertTrue(tagInfo.get(TAGS[0]).contains("localhost_3"));
+    Assert.assertFalse(tagInfo.get(TAGS[0]).contains("localhost_4"));
+    Assert.assertFalse(tagInfo.get(TAGS[1]).contains("localhost_1"));
+    Assert.assertTrue(tagInfo.get(TAGS[1]).contains("localhost_2"));
+    Assert.assertTrue(tagInfo.get(TAGS[1]).contains("localhost_3"));
+    Assert.assertFalse(tagInfo.get(TAGS[1]).contains("localhost_4"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/304995e7/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
index 3eee0a1..1fba6df 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
@@ -44,7 +44,6 @@ import org.restlet.Request;
 import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Method;
-import org.restlet.data.Protocol;
 import org.restlet.data.Reference;
 import org.restlet.representation.Representation;
 import org.testng.Assert;
@@ -85,8 +84,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
             + "/StateModelDefs/MasterSlave";
     Reference resourceRef = new Reference(httpUrlBase);
     Request request = new Request(Method.GET, resourceRef);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
     result.write(sw);
@@ -107,8 +105,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap)
             + "&" + JsonParameters.NEW_STATE_MODEL_DEF + "="
             + ClusterRepresentationUtil.ZNRecordToJson(r), MediaType.APPLICATION_ALL);
-    client = new Client(Protocol.HTTP);
-    response = client.handle(request);
+    response = _gClient.handle(request);
 
     result = response.getEntity();
     sw = new StringWriter();
@@ -133,8 +130,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
         MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
 
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
@@ -165,8 +161,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
         MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
 
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
@@ -185,8 +180,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
 
     request = new Request(Method.GET, resourceRef);
 
-    client = new Client(Protocol.HTTP);
-    response = client.handle(request);
+    response = _gClient.handle(request);
 
     result = response.getEntity();
     sw = new StringWriter();
@@ -210,8 +204,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
         MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
 
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
@@ -252,8 +245,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
         MediaType.APPLICATION_ALL);
-    client = new Client(Protocol.HTTP);
-    response = client.handle(request);
+    response = _gClient.handle(request);
 
     result = response.getEntity();
     sw = new StringWriter();
@@ -295,8 +287,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
         MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
 
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
@@ -316,8 +307,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     resourceRef = new Reference(httpUrlBase);
     request = new Request(Method.GET, resourceRef);
 
-    client = new Client(Protocol.HTTP);
-    response = client.handle(request);
+    response = _gClient.handle(request);
 
     result = response.getEntity();
     sw = new StringWriter();
@@ -341,8 +331,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
         MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
 
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
@@ -362,8 +351,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
         MediaType.APPLICATION_ALL);
-    client = new Client(Protocol.HTTP);
-    response = client.handle(request);
+    response = _gClient.handle(request);
 
     result = response.getEntity();
     sw = new StringWriter();
@@ -385,8 +373,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     Reference resourceRef = new Reference(httpUrlBase);
     Request request = new Request(Method.GET, resourceRef);
 
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
 
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
@@ -410,8 +397,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap)
             + "&" + JsonParameters.NEW_IDEAL_STATE + "="
             + ClusterRepresentationUtil.ZNRecordToJson(r), MediaType.APPLICATION_ALL);
-    client = new Client(Protocol.HTTP);
-    response = client.handle(request);
+    response = _gClient.handle(request);
 
     result = response.getEntity();
     sw = new StringWriter();
@@ -431,16 +417,15 @@ public class TestClusterManagementWebapp extends AdminTestBase {
   // verify get/post configs in different scopes
   void verifyConfigAccessor() throws Exception {
     ObjectMapper mapper = new ObjectMapper();
-    Client client = new Client(Protocol.HTTP);
 
     // set/get cluster scope configs
     String url =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/cluster/"
             + clusterName;
 
-    postConfig(client, url, mapper, ClusterSetup.setConfig, "key1=value1,key2=value2");
+    postConfig(_gClient, url, mapper, ClusterSetup.setConfig, "key1=value1,key2=value2");
 
-    ZNRecord record = get(client, url, mapper);
+    ZNRecord record = get(_gClient, url, mapper);
     Assert.assertEquals(record.getSimpleFields().size(), 2);
     Assert.assertEquals(record.getSimpleField("key1"), "value1");
     Assert.assertEquals(record.getSimpleField("key2"), "value2");
@@ -451,9 +436,9 @@ public class TestClusterManagementWebapp extends AdminTestBase {
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/participant/"
             + participantName;
 
-    postConfig(client, url, mapper, ClusterSetup.setConfig, "key3=value3,key4=value4");
+    postConfig(_gClient, url, mapper, ClusterSetup.setConfig, "key3=value3,key4=value4");
 
-    record = get(client, url, mapper);
+    record = get(_gClient, url, mapper);
     Assert.assertTrue(record.getSimpleFields().size() >= 2, "Should at least contains
2 keys");
     Assert.assertEquals(record.getSimpleField("key3"), "value3");
     Assert.assertEquals(record.getSimpleField("key4"), "value4");
@@ -463,9 +448,9 @@ public class TestClusterManagementWebapp extends AdminTestBase {
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName
             + "/configs/resource/testResource";
 
-    postConfig(client, url, mapper, ClusterSetup.setConfig, "key5=value5,key6=value6");
+    postConfig(_gClient, url, mapper, ClusterSetup.setConfig, "key5=value5,key6=value6");
 
-    record = get(client, url, mapper);
+    record = get(_gClient, url, mapper);
     Assert.assertEquals(record.getSimpleFields().size(), 2);
     Assert.assertEquals(record.getSimpleField("key5"), "value5");
     Assert.assertEquals(record.getSimpleField("key6"), "value6");
@@ -475,16 +460,16 @@ public class TestClusterManagementWebapp extends AdminTestBase {
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName
             + "/configs/partition/testResource/testPartition";
 
-    postConfig(client, url, mapper, ClusterSetup.setConfig, "key7=value7,key8=value8");
+    postConfig(_gClient, url, mapper, ClusterSetup.setConfig, "key7=value7,key8=value8");
 
-    record = get(client, url, mapper);
+    record = get(_gClient, url, mapper);
     Assert.assertEquals(record.getSimpleFields().size(), 2);
     Assert.assertEquals(record.getSimpleField("key7"), "value7");
     Assert.assertEquals(record.getSimpleField("key8"), "value8");
 
     // list keys
     url = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs";
-    record = get(client, url, mapper);
+    record = get(_gClient, url, mapper);
     Assert.assertEquals(record.getListFields().size(), 1);
     Assert.assertTrue(record.getListFields().containsKey("scopes"));
     Assert.assertTrue(contains(record.getListField("scopes"), "CLUSTER", "PARTICIPANT", "RESOURCE",
@@ -498,12 +483,12 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     // record);
 
     url = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/participant";
-    record = get(client, url, mapper);
+    record = get(_gClient, url, mapper);
     Assert.assertTrue(record.getListFields().containsKey("PARTICIPANT"));
     Assert.assertTrue(contains(record.getListField("PARTICIPANT"), participantName));
 
     url = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/resource";
-    record = get(client, url, mapper);
+    record = get(_gClient, url, mapper);
     Assert.assertEquals(record.getListFields().size(), 1);
     Assert.assertTrue(record.getListFields().containsKey("RESOURCE"));
     Assert.assertTrue(contains(record.getListField("RESOURCE"), "testResource"));
@@ -511,7 +496,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     url =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName
             + "/configs/partition/testResource";
-    record = get(client, url, mapper);
+    record = get(_gClient, url, mapper);
     Assert.assertEquals(record.getListFields().size(), 1);
     Assert.assertTrue(record.getListFields().containsKey("PARTITION"));
     Assert.assertTrue(contains(record.getListField("PARTITION"), "testPartition"));
@@ -569,8 +554,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paramMap),
         MediaType.APPLICATION_ALL);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
+    Response response = _gClient.handle(request);
 
     Representation result = response.getEntity();
     StringWriter sw = new StringWriter();
@@ -591,8 +575,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
     request.setEntity(
         JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paramMap),
         MediaType.APPLICATION_ALL);
-    client = new Client(Protocol.HTTP);
-    response = client.handle(request);
+    response = _gClient.handle(request);
 
     result = response.getEntity();
     sw = new StringWriter();

http://git-wip-us.apache.org/repos/asf/helix/blob/304995e7/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestTagAwareness.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestTagAwareness.java
b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestTagAwareness.java
deleted file mode 100644
index f8bb6cd..0000000
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestTagAwareness.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package org.apache.helix.webapp;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.helix.HelixAdmin;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.model.IdealState;
-import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.tools.AdminTestBase;
-import org.apache.helix.webapp.resources.ClusterRepresentationUtil;
-import org.apache.helix.webapp.resources.InstancesResource.ListInstancesWrapper;
-import org.junit.Assert;
-import org.restlet.Client;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.data.Method;
-import org.restlet.data.Protocol;
-import org.restlet.data.Reference;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Ensure that REST calls for participants and resources return information about tags
- */
-public class TestTagAwareness extends AdminTestBase {
-  private String _clusterName;
-  private HelixAdmin _admin;
-
-  @BeforeClass
-  public void beforeClass() {
-    _clusterName = TestTagAwareness.class.getCanonicalName() + "_cluster";
-    _gSetupTool.addCluster(_clusterName, true);
-    _admin = _gSetupTool.getClusterManagementTool();
-  }
-
-  @Test
-  public void testGetResources() throws IOException {
-    final String TAG = "tag";
-    final String URL_BASE =
-        "http://localhost:" + ADMIN_PORT + "/clusters/" + _clusterName + "/resourceGroups";
-
-    // Add a tagged resource
-    IdealState taggedResource = new IdealState("taggedResource");
-    taggedResource.setInstanceGroupTag(TAG);
-    taggedResource.setStateModelDefRef("OnlineOffline");
-    _admin.addResource(_clusterName, taggedResource.getId(), taggedResource);
-
-    // Add an untagged resource
-    IdealState untaggedResource = new IdealState("untaggedResource");
-    untaggedResource.setStateModelDefRef("OnlineOffline");
-    _admin.addResource(_clusterName, untaggedResource.getId(), untaggedResource);
-
-    // Now make a REST call for all resources
-    Reference resourceRef = new Reference(URL_BASE);
-    Request request = new Request(Method.GET, resourceRef);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
-    ZNRecord responseRecord =
-        ClusterRepresentationUtil.JsonToObject(ZNRecord.class, response.getEntityAsText());
-
-    // Ensure that the tagged resource has information and the untagged one doesn't
-    Assert.assertNotNull(responseRecord.getMapField("ResourceTags"));
-    Assert
-        .assertEquals(TAG, responseRecord.getMapField("ResourceTags").get(taggedResource.getId()));
-    Assert.assertFalse(responseRecord.getMapField("ResourceTags").containsKey(
-        untaggedResource.getId()));
-  }
-
-  @Test
-  public void testGetInstances() throws IOException {
-    final String[] TAGS = {
-        "tag1", "tag2"
-    };
-    final String URL_BASE =
-        "http://localhost:" + ADMIN_PORT + "/clusters/" + _clusterName + "/instances";
-
-    // Add 4 participants, each with differint tag characteristics
-    InstanceConfig instance1 = new InstanceConfig("localhost_1");
-    instance1.addTag(TAGS[0]);
-    _admin.addInstance(_clusterName, instance1);
-    InstanceConfig instance2 = new InstanceConfig("localhost_2");
-    instance2.addTag(TAGS[1]);
-    _admin.addInstance(_clusterName, instance2);
-    InstanceConfig instance3 = new InstanceConfig("localhost_3");
-    instance3.addTag(TAGS[0]);
-    instance3.addTag(TAGS[1]);
-    _admin.addInstance(_clusterName, instance3);
-    InstanceConfig instance4 = new InstanceConfig("localhost_4");
-    _admin.addInstance(_clusterName, instance4);
-
-    // Now make a REST call for all resources
-    Reference resourceRef = new Reference(URL_BASE);
-    Request request = new Request(Method.GET, resourceRef);
-    Client client = new Client(Protocol.HTTP);
-    Response response = client.handle(request);
-    ListInstancesWrapper responseWrapper =
-        ClusterRepresentationUtil.JsonToObject(ListInstancesWrapper.class,
-            response.getEntityAsText());
-    Map<String, List<String>> tagInfo = responseWrapper.tagInfo;
-
-    // Ensure tag ownership is reported correctly
-    Assert.assertTrue(tagInfo.containsKey(TAGS[0]));
-    Assert.assertTrue(tagInfo.containsKey(TAGS[1]));
-    Assert.assertTrue(tagInfo.get(TAGS[0]).contains("localhost_1"));
-    Assert.assertFalse(tagInfo.get(TAGS[0]).contains("localhost_2"));
-    Assert.assertTrue(tagInfo.get(TAGS[0]).contains("localhost_3"));
-    Assert.assertFalse(tagInfo.get(TAGS[0]).contains("localhost_4"));
-    Assert.assertFalse(tagInfo.get(TAGS[1]).contains("localhost_1"));
-    Assert.assertTrue(tagInfo.get(TAGS[1]).contains("localhost_2"));
-    Assert.assertTrue(tagInfo.get(TAGS[1]).contains("localhost_3"));
-    Assert.assertFalse(tagInfo.get(TAGS[1]).contains("localhost_4"));
-  }
-
-  @AfterClass
-  public void afterClass() {
-    _admin.dropCluster(_clusterName);
-  }
-
-}


Mime
View raw message