Java Code Examples for org.apache.helix.ConfigAccessor#getCloudConfig()

The following examples show how to use org.apache.helix.ConfigAccessor#getCloudConfig() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterAccessor.java    From helix with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{clusterId}/cloudconfig")
public Response getCloudConfig(@PathParam("clusterId") String clusterId) {

  RealmAwareZkClient zkClient = getRealmAwareZkClient();
  if (!ZKUtil.isClusterSetup(clusterId, zkClient)) {
    return notFound();
  }

  ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
  CloudConfig cloudConfig = configAccessor.getCloudConfig(clusterId);

  if (cloudConfig != null) {
    return JSONRepresentation(cloudConfig.getRecord());
  }

  return notFound();
}
 
Example 2
Source File: TestClusterAccessor.java    From helix with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = "testAddClusterWithValidCustomizedCloudConfig")
public void testAddClusterWithCloudConfigDisabledCloud() throws Exception {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String clusterName = className + "_" + methodName;

  ZNRecord record = new ZNRecord("testZnode");
  record.setBooleanField(CloudConfig.CloudConfigProperty.CLOUD_ENABLED.name(), false);
  record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_ID.name(), "TestCloudID");
  record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_PROVIDER.name(),
      CloudProvider.AZURE.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 check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(ZK_ADDR);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertFalse(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestCloudID");
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.AZURE.name());
}
 
Example 3
Source File: TestZkHelixAdmin.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddCloudConfig() {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String clusterName = className + "_" + methodName;

  HelixAdmin admin = new ZKHelixAdmin(_gZkClient);
  admin.addCluster(clusterName, true);

  CloudConfig.Builder builder = new CloudConfig.Builder();
  builder.setCloudEnabled(true);
  builder.setCloudID("TestID");
  builder.addCloudInfoSource("TestURL");
  builder.setCloudProvider(CloudProvider.CUSTOMIZED);
  builder.setCloudInfoProcessorName("TestProcessor");
  CloudConfig cloudConfig = builder.build();

  admin.addCloudConfig(clusterName, cloudConfig);

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
  Assert.assertEquals(listUrlFromZk.get(0), "TestURL");
  Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessor");
}
 
Example 4
Source File: TestZkHelixAdmin.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test
public void testRemoveCloudConfig() throws Exception {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String clusterName = className + "_" + methodName;

  HelixAdmin admin = new ZKHelixAdmin(_gZkClient);
  admin.addCluster(clusterName, true);

  CloudConfig.Builder builder = new CloudConfig.Builder();
  builder.setCloudEnabled(true);
  builder.setCloudID("TestID");
  builder.addCloudInfoSource("TestURL");
  builder.setCloudProvider(CloudProvider.CUSTOMIZED);
  builder.setCloudInfoProcessorName("TestProcessor");
  CloudConfig cloudConfig = builder.build();

  admin.addCloudConfig(clusterName, cloudConfig);

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
  Assert.assertEquals(listUrlFromZk.get(0), "TestURL");
  Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessor");

  // Remove Cloud Config and make sure it has been removed from Zookeeper
  admin.removeCloudConfig(clusterName);
  cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertNull(cloudConfigFromZk);
}
 
Example 5
Source File: TestCloudConfig.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = HelixException.class)
public void testCloudConfigNonExistentCluster() {
  String className = getShortClassName();
  String clusterName = "CLUSTER_" + className;
  // Read CloudConfig from Zookeeper and get exception since cluster in not setup yet
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
}
 
Example 6
Source File: TestCloudConfig.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testCloudConfigNonExistentCluster")
public void testCloudConfigNull() {
  String className = getShortClassName();
  String clusterName = "CLUSTER_" + className;
  TestHelper.setupEmptyCluster(_gZkClient, clusterName);
  // Read CloudConfig from Zookeeper
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  // since CloudConfig is not written to ZooKeeper, the output should be null
  Assert.assertNull(cloudConfigFromZk);
}
 
Example 7
Source File: TestCloudConfig.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testCloudConfigNull")
public void testCloudConfig() throws Exception {
  String className = getShortClassName();
  String clusterName = "CLUSTER_" + className;
  TestHelper.setupEmptyCluster(_gZkClient, clusterName);

  // Create dummy CloudConfig object
  CloudConfig.Builder cloudConfigBuilder = new CloudConfig.Builder();
  cloudConfigBuilder.setCloudEnabled(true);
  cloudConfigBuilder.setCloudProvider(CloudProvider.AZURE);
  cloudConfigBuilder.setCloudID("TestID");
  List<String> infoURL = new ArrayList<String>();
  infoURL.add("TestURL");
  cloudConfigBuilder.setCloudInfoSources(infoURL);
  cloudConfigBuilder.setCloudInfoProcessorName("TestProcessor");

  CloudConfig cloudConfig = cloudConfigBuilder.build();

  // Write the CloudConfig to Zookeeper
  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_gZkClient));
  Builder keyBuilder = accessor.keyBuilder();
  accessor.setProperty(keyBuilder.cloudConfig(), cloudConfig);

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.AZURE.name());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");

  Assert.assertEquals(cloudConfigFromZk.getCloudInfoSources().size(), 1);
  Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessor");
}
 
Example 8
Source File: TestClusterSetup.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testAddClusterWithInvalidCloudConfig")
public void testAddClusterWithValidCloudConfig() throws Exception {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String clusterName = className + "_" + methodName;

  CloudConfig.Builder cloudConfigInitBuilder = new CloudConfig.Builder();
  cloudConfigInitBuilder.setCloudEnabled(true);
  cloudConfigInitBuilder.setCloudID("TestID");
  List<String> sourceList = new ArrayList<String>();
  sourceList.add("TestURL");
  cloudConfigInitBuilder.setCloudInfoSources(sourceList);
  cloudConfigInitBuilder.setCloudInfoProcessorName("TestProcessorName");
  cloudConfigInitBuilder.setCloudProvider(CloudProvider.CUSTOMIZED);

  CloudConfig cloudConfigInit = cloudConfigInitBuilder.build();

  _clusterSetup.addCluster(clusterName, false, cloudConfigInit);

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
  Assert.assertEquals(listUrlFromZk.get(0), "TestURL");
  Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessorName");
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
}
 
Example 9
Source File: TestClusterSetup.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testAddClusterWithValidCloudConfig")
public void testAddClusterAzureProvider() throws Exception {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String clusterName = className + "_" + methodName;

  CloudConfig.Builder cloudConfigInitBuilder = new CloudConfig.Builder();
  cloudConfigInitBuilder.setCloudEnabled(true);
  cloudConfigInitBuilder.setCloudID("TestID");
  cloudConfigInitBuilder.setCloudProvider(CloudProvider.AZURE);

  CloudConfig cloudConfigInit = cloudConfigInitBuilder.build();

  _clusterSetup.addCluster(clusterName, false, cloudConfigInit);

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(ZK_ADDR);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();

  // Since it is Azure, topology information should have been populated.
  ClusterConfig clusterConfig = _configAccessor.getClusterConfig(clusterName);
  Assert.assertEquals(clusterConfig.getTopology(), AzureConstants.AZURE_TOPOLOGY);
  Assert.assertEquals(clusterConfig.getFaultZoneType(), AzureConstants.AZURE_FAULT_ZONE_TYPE);
  Assert.assertTrue(clusterConfig.isTopologyAwareEnabled());

  // Since provider is not customized, CloudInfoSources and CloudInfoProcessorName will be null.
  Assert.assertNull(listUrlFromZk);
  Assert.assertNull(cloudConfigFromZk.getCloudInfoProcessorName());
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.AZURE.name());
}
 
Example 10
Source File: TestClusterAccessor.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testActivateSuperCluster")
public void testAddClusterWithCloudConfig() throws Exception {
  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> 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 check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(ZK_ADDR);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestCloudID");
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.AZURE.name());

  ClusterConfig clusterConfigFromZk = _configAccessor.getClusterConfig(clusterName);
  Assert.assertEquals(clusterConfigFromZk.getTopology(), AzureConstants.AZURE_TOPOLOGY);
  Assert.assertEquals(clusterConfigFromZk.getFaultZoneType(), AzureConstants.AZURE_FAULT_ZONE_TYPE);
  Assert.assertTrue(clusterConfigFromZk.isTopologyAwareEnabled());
}
 
Example 11
Source File: TestClusterAccessor.java    From helix with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testAddClusterWithInvalidCustomizedCloudConfig")
public void testAddClusterWithValidCustomizedCloudConfig() throws Exception {
  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.CUSTOMIZED.name());
  List<String> sourceList = new ArrayList<String>();
  sourceList.add("TestURL");
  record.setListField(CloudConfig.CloudConfigProperty.CLOUD_INFO_SOURCE.name(), sourceList);
  record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_INFO_PROCESSOR_NAME.name(),
      "TestProcessorName");

  Map<String, String> map = new HashMap<>();
  map.put("addCloudConfig", "true");

  // Cloud Provider is customized. CLOUD_INFO_PROCESSOR_NAME and CLOUD_INFO_SOURCE fields are
  // required.
  put("clusters/" + clusterName, map,
      Entity.entity(OBJECT_MAPPER.writeValueAsString(record), MediaType.APPLICATION_JSON_TYPE),
      Response.Status.CREATED.getStatusCode());

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(ZK_ADDR);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestCloudID");
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
  Assert.assertEquals(listUrlFromZk.get(0), "TestURL");
  Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessorName");
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
}
 
Example 12
Source File: TestCloudConfig.java    From helix with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = "testCloudConfig")
public void testCloudConfigBuilder() {
  String className = getShortClassName();
  String clusterName = "CLUSTER_" + className;
  TestHelper.setupEmptyCluster(_gZkClient, clusterName);
  CloudConfig.Builder builder = new CloudConfig.Builder();
  builder.setCloudEnabled(true);
  builder.setCloudProvider(CloudProvider.CUSTOMIZED);
  builder.setCloudID("TestID");
  builder.addCloudInfoSource("TestURL0");
  builder.addCloudInfoSource("TestURL1");
  builder.setCloudInfoProcessorName("TestProcessor");

  // Check builder getter methods
  Assert.assertTrue(builder.getCloudEnabled());
  Assert.assertEquals(builder.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
  Assert.assertEquals(builder.getCloudID(), "TestID");
  List<String> listUrlFromBuilder = builder.getCloudInfoSources();
  Assert.assertEquals(listUrlFromBuilder.size(), 2);
  Assert.assertEquals(listUrlFromBuilder.get(0), "TestURL0");
  Assert.assertEquals(listUrlFromBuilder.get(1), "TestURL1");
  Assert.assertEquals(builder.getCloudInfoProcessorName(), "TestProcessor");

  CloudConfig cloudConfig = builder.build();

  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_gZkClient));
  Builder keyBuilder = accessor.keyBuilder();
  accessor.setProperty(keyBuilder.cloudConfig(), cloudConfig);

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
  Assert.assertEquals(listUrlFromZk.get(0), "TestURL0");
  Assert.assertEquals(listUrlFromZk.get(1), "TestURL1");
  Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessor");
}
 
Example 13
Source File: TestCloudConfig.java    From helix with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = "testCloudConfigBuilder")
public void testCloudConfigBuilderAzureProvider() {
  String className = getShortClassName();
  String clusterName = "CLUSTER_" + className;
  TestHelper.setupEmptyCluster(_gZkClient, clusterName);
  CloudConfig.Builder builder = new CloudConfig.Builder();
  builder.setCloudEnabled(true);
  builder.setCloudProvider(CloudProvider.AZURE);
  builder.setCloudID("TestID");

  // Check builder getter methods
  Assert.assertTrue(builder.getCloudEnabled());
  Assert.assertEquals(builder.getCloudProvider(), CloudProvider.AZURE.name());

  CloudConfig cloudConfig = builder.build();

  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_gZkClient));
  Builder keyBuilder = accessor.keyBuilder();
  accessor.setProperty(keyBuilder.cloudConfig(), cloudConfig);

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.AZURE.name());

  // Since user does not set the CloudInfoProcessorName, this field will be null.
  Assert.assertNull(cloudConfigFromZk.getCloudInfoProcessorName());

  // Checking the set method in CloudConfig
  cloudConfig.setCloudEnabled(false);
  accessor.setProperty(keyBuilder.cloudConfig(), cloudConfig);
  cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertFalse(cloudConfigFromZk.isCloudEnabled());

  cloudConfig.setCloudEnabled(true);
  cloudConfig.setCloudID("TestID2");
  List<String> sourceList = new ArrayList<String>();
  sourceList.add("TestURL0");
  sourceList.add("TestURL1");
  cloudConfig.setCloudInfoSource(sourceList);
  accessor.setProperty(keyBuilder.cloudConfig(), cloudConfig);

  cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.AZURE.name());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID2");
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
  Assert.assertEquals(listUrlFromZk.get(0), "TestURL0");
  Assert.assertEquals(listUrlFromZk.get(1), "TestURL1");
}
 
Example 14
Source File: TestClusterAccessor.java    From helix with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = "testAddCloudConfigNonExistedCluster")
public void testAddCloudConfig() throws Exception {
  System.out.println("Start test :" + TestHelper.getTestMethodName());
  _gSetupTool.addCluster("TestCloud", true);
  String urlBase = "clusters/TestCloud/cloudconfig/";

  ZNRecord record = new ZNRecord("TestCloud");
  record.setBooleanField(CloudConfig.CloudConfigProperty.CLOUD_ENABLED.name(), true);
  record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_PROVIDER.name(),
      CloudProvider.CUSTOMIZED.name());
  record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_ID.name(), "TestCloudID");
  List<String> testList = new ArrayList<String>();
  testList.add("TestURL");
  record.setListField(CloudConfig.CloudConfigProperty.CLOUD_INFO_SOURCE.name(), testList);

  // Bad request since Processor has not been defined.
  put(urlBase, null,
      Entity.entity(OBJECT_MAPPER.writeValueAsString(record), MediaType.APPLICATION_JSON_TYPE),
      Response.Status.BAD_REQUEST.getStatusCode());

  record.setSimpleField(CloudConfig.CloudConfigProperty.CLOUD_INFO_PROCESSOR_NAME.name(),
      "TestProcessorName");

  // Now response should be OK since all fields are set
  put(urlBase, null,
      Entity.entity(OBJECT_MAPPER.writeValueAsString(record), MediaType.APPLICATION_JSON_TYPE),
      Response.Status.OK.getStatusCode());

  // Read CloudConfig from Zookeeper and check the content
  ConfigAccessor _configAccessor = new ConfigAccessor(ZK_ADDR);
  CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig("TestCloud");
  Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
  Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestCloudID");
  List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
  Assert.assertEquals(listUrlFromZk.get(0), "TestURL");
  Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessorName");
  Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.CUSTOMIZED.name());

  // Now test the getCloudConfig method.
  String body = get(urlBase, null, Response.Status.OK.getStatusCode(), true);

  ZNRecord recordFromRest = new ObjectMapper().reader(ZNRecord.class).readValue(body);
  CloudConfig cloudConfigRest = new CloudConfig.Builder(recordFromRest).build();
  CloudConfig cloudConfigZk = _configAccessor.getCloudConfig("TestCloud");

  // Check that the CloudConfig from Zk and REST get method are equal
  Assert.assertEquals(cloudConfigRest, cloudConfigZk);

  // Check the fields individually
  Assert.assertTrue(cloudConfigRest.isCloudEnabled());
  Assert.assertEquals(cloudConfigRest.getCloudID(), "TestCloudID");
  Assert.assertEquals(cloudConfigRest.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
  List<String> listUrlFromRest = cloudConfigRest.getCloudInfoSources();
  Assert.assertEquals(listUrlFromRest.get(0), "TestURL");
  Assert.assertEquals(cloudConfigRest.getCloudInfoProcessorName(), "TestProcessorName");

  System.out.println("End test :" + TestHelper.getTestMethodName());
}