zhangmeng916 commented on a change in pull request #647: Add java API to create
cluster with CloudConfig
URL: https://github.com/apache/helix/pull/647#discussion_r356314556
##########
File path:
helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
##########
@@ -436,4 +441,82 @@ public void testDisableResource() throws Exception {
System.out.println("END " + clusterName + " at " + new
Date(System.currentTimeMillis()));
}
+
+ @Test(expectedExceptions = HelixException.class)
+ public void testAddClusterWithInvalidCloudConfig() throws Exception {
+ String className = TestHelper.getTestClassName();
+ String methodName = TestHelper.getTestMethodName();
+ String clusterName = className + "_" + methodName;
+
+ System.setProperty(SystemPropertyKeys.CLOUD_INFO_SOURCE, "TestURL");
+ System.setProperty(SystemPropertyKeys.CLOUD_INFO_PROCESSOR_NAME,
"TestProcessorName");
+ System.setProperty(SystemPropertyKeys.CLOUD_PROVIDER,
CloudProvider.CUSTOMIZED.name());
+
+ // Since CloudID is missing, this add cluster call will throw an exception
+ _clusterSetup.addCluster(clusterName, false,true);
+ System.clearProperty(SystemPropertyKeys.CLOUD_ID);
+ System.clearProperty(SystemPropertyKeys.CLOUD_PROVIDER);
+ System.clearProperty(SystemPropertyKeys.CLOUD_INFO_SOURCE);
+ System.clearProperty(SystemPropertyKeys.CLOUD_INFO_PROCESSOR_NAME);
+ }
+
+ @Test(dependsOnMethods = "testAddClusterWithInvalidCloudConfig")
+ public void testAddClusterWithValidCloudConfig() throws Exception {
+ String className = TestHelper.getTestClassName();
+ String methodName = TestHelper.getTestMethodName();
+ String clusterName = className + "_" + methodName;
+
+ System.setProperty(SystemPropertyKeys.CLOUD_ID, "TestID");
+ System.setProperty(SystemPropertyKeys.CLOUD_INFO_SOURCE, "TestURL");
+ System.setProperty(SystemPropertyKeys.CLOUD_PROVIDER,
CloudProvider.CUSTOMIZED.name());
+ System.setProperty(SystemPropertyKeys.CLOUD_INFO_PROCESSOR_NAME,
"TestProcessor");
+
+ _clusterSetup.addCluster(clusterName, false,true);
+
+ // 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(),
"TestProcessor");
+ Assert.assertEquals(cloudConfigFromZk.getCloudProvider(),
CloudProvider.CUSTOMIZED.name());
+ System.clearProperty(SystemPropertyKeys.CLOUD_ID);
+ System.clearProperty(SystemPropertyKeys.CLOUD_PROVIDER);
+ System.clearProperty(SystemPropertyKeys.CLOUD_INFO_SOURCE);
+ System.clearProperty(SystemPropertyKeys.CLOUD_INFO_PROCESSOR_NAME);
+ }
+
+
+ @Test(dependsOnMethods = "testAddClusterWithValidCloudConfig")
+ public void testAddClusterAzureProvider() throws Exception {
+ String className = TestHelper.getTestClassName();
+ String methodName = TestHelper.getTestMethodName();
+ String clusterName = className + "_" + methodName;
+
+ System.setProperty(SystemPropertyKeys.CLOUD_ID, "TestID");
+ System.setProperty(SystemPropertyKeys.CLOUD_INFO_SOURCE, "TestURL");
Review comment:
This test case cannot test the real scenario for Azure. Let's assume that
only "provider", "ID", and "enabled" are input, the other two are not. We
cannot expect our customer to know the other two.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]