This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch helix-cloud
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/helix-cloud by this push:
new 2104a89 Change the REST call for delete CloudConfig (#882)
2104a89 is described below
commit 2104a89a90fb26fed57afeff1fe3a27056f29b14
Author: Ali Reza Zamani Zadeh Najari <[email protected]>
AuthorDate: Fri Mar 13 13:18:07 2020 -0700
Change the REST call for delete CloudConfig (#882)
Change the delete CloudConfig
Use DELETE instead of POST for deletion of the CloudConfig in REST.
---
.../server/resources/helix/ClusterAccessor.java | 12 ++++++---
.../helix/rest/server/TestClusterAccessor.java | 31 +++++++++++++++-------
2 files changed, 30 insertions(+), 13 deletions(-)
diff --git
a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
index ae31cb5..4e6edaf 100644
---
a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
+++
b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
@@ -584,6 +584,14 @@ public class ClusterAccessor extends AbstractHelixResource
{
return notFound();
}
+ @DELETE
+ @Path("{clusterId}/cloudconfig")
+ public Response deleteCloudConfig(@PathParam("clusterId") String clusterId) {
+ HelixAdmin admin = getHelixAdmin();
+ admin.removeCloudConfig(clusterId);
+ return OK();
+ }
+
@POST
@Path("{clusterId}/cloudconfig")
public Response updateCloudConfig(@PathParam("clusterId") String clusterId,
@@ -617,10 +625,6 @@ public class ClusterAccessor extends AbstractHelixResource
{
}
try {
switch (command) {
- case delete: {
- admin.removeCloudConfig(clusterId);
- }
- break;
case update: {
try {
CloudConfig cloudConfig = new CloudConfig.Builder(record).build();
diff --git
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
index 21a2853..81fc708 100644
---
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
+++
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
@@ -790,19 +790,32 @@ public class TestClusterAccessor extends
AbstractTestClass {
@Test(dependsOnMethods = "testAddCloudConfig")
public void testDeleteCloudConfig() throws IOException {
System.out.println("Start test :" + TestHelper.getTestMethodName());
- _gSetupTool.addCluster("TestCloud", true);
- String urlBase = "clusters/TestCloud/cloudconfig/";
+ String className = TestHelper.getTestClassName();
+ String methodName = TestHelper.getTestMethodName();
+ String clusterName = className + "_" + methodName;
+
+ ZNRecord record = new ZNRecord("testZnode");
+
record.setBooleanField(CloudConfig.CloudConfigProperty.CLOUD_ENABLED.name(),
true);
+ record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_ID.name(),
"TestCloudID");
+
record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_PROVIDER.name(),
+ CloudProvider.AZURE.name());
- Map<String, String> map1 = new HashMap<>();
- map1.put("command", AbstractResource.Command.delete.name());
+ Map<String, String> map = new HashMap<>();
+ map.put("addCloudConfig", "true");
+ put("clusters/" + clusterName, map,
+ Entity.entity(OBJECT_MAPPER.writeValueAsString(record),
MediaType.APPLICATION_JSON_TYPE),
+ Response.Status.CREATED.getStatusCode());
+ // Read CloudConfig from Zookeeper and make sure it has been created
+ ConfigAccessor _configAccessor = new ConfigAccessor(ZK_ADDR);
+ CloudConfig cloudConfigFromZk =
_configAccessor.getCloudConfig(clusterName);
+ Assert.assertNotNull(cloudConfigFromZk);
+ String urlBase = "clusters/" + clusterName + "/cloudconfig/";
- ZNRecord record = new ZNRecord("TestCloud");
- post(urlBase, map1,
Entity.entity(OBJECT_MAPPER.writeValueAsString(record),
MediaType.APPLICATION_JSON_TYPE),
- Response.Status.OK.getStatusCode());
+ delete(urlBase, Response.Status.OK.getStatusCode());
// Read CloudConfig from Zookeeper and make sure it has been removed
- ConfigAccessor _configAccessor = new ConfigAccessor(ZK_ADDR);
- CloudConfig cloudConfigFromZk =
_configAccessor.getCloudConfig("TestCloud");
+ _configAccessor = new ConfigAccessor(ZK_ADDR);
+ cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
Assert.assertNull(cloudConfigFromZk);
System.out.println("End test :" + TestHelper.getTestMethodName());