Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,14 @@ public Response getCloudConfig(@PathParam("clusterId") String clusterId) {
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,
Expand Down Expand Up @@ -617,10 +625,6 @@ record = toZNRecord(content);
}
try {
switch (command) {
case delete: {
admin.removeCloudConfig(clusterId);
}
break;
case update: {
try {
CloudConfig cloudConfig = new CloudConfig.Builder(record).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,19 +790,32 @@ public void testAddCloudConfig() throws Exception {
@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());
Expand Down