Remove cloud config check in VirtualTopologyGroupService (#2190) master
authorQi (Quincy) Qu <qqu@linkedin.com>
Mon, 15 Aug 2022 16:59:03 +0000 (09:59 -0700)
committerGitHub <noreply@github.com>
Mon, 15 Aug 2022 16:59:03 +0000 (09:59 -0700)
Remove the dependency on CloudConfig for setting virtual topology group.

helix-rest/src/main/java/org/apache/helix/rest/server/service/VirtualTopologyGroupService.java
helix-rest/src/test/java/org/apache/helix/rest/server/service/TestVirtualTopologyGroupService.java

index 997b88035f330c6506f39e275409149920662467..2fd5f2824742bcd982e290312004564b8d24270c 100644 (file)
@@ -89,11 +89,6 @@ public class VirtualTopologyGroupService {
    */
   public void addVirtualTopologyGroup(String clusterName, Map<String, String> customFields) {
     // validation
-    CloudConfig cloudConfig = _configAccessor.getCloudConfig(clusterName);
-    if (cloudConfig == null || !cloudConfig.isCloudEnabled()) {
-      throw new HelixException(
-          "Cloud is not enabled, addVirtualTopologyGroup is not allowed to run in non-cloud environment.");
-    }
     ClusterConfig clusterConfig = _configAccessor.getClusterConfig(clusterName);
     Preconditions.checkState(clusterConfig.isTopologyAwareEnabled(),
         "Topology-aware rebalance is not enabled in cluster " + clusterName);
index ab1c53fa44252efca4763ab544b49389b8a8ff5b..3ffc29c74c1676e231e42948c52c0fedc5050dbb 100644 (file)
@@ -83,13 +83,6 @@ public class TestVirtualTopologyGroupService {
     clusterConfig.setTopologyAwareEnabled(true);
     when(_configAccessor.getClusterConfig(TEST_CLUSTER0)).thenReturn(clusterConfig);
 
-    CloudConfig.Builder cloudConfigBuilder = new CloudConfig.Builder();
-    cloudConfigBuilder.setCloudEnabled(true);
-    cloudConfigBuilder.setCloudProvider(CloudProvider.AZURE);
-    cloudConfigBuilder.setCloudID("TestID");
-    CloudConfig cloudConfig = cloudConfigBuilder.build();
-    when(_configAccessor.getCloudConfig(TEST_CLUSTER0)).thenReturn(cloudConfig);
-
     _helixAdmin = mock(HelixAdmin.class);
     when(_helixAdmin.isInMaintenanceMode(anyString())).thenReturn(true);
 
@@ -101,10 +94,10 @@ public class TestVirtualTopologyGroupService {
     _service = new VirtualTopologyGroupService(_helixAdmin, clusterService, _configAccessor, _dataAccessor);
   }
 
-  @Test(expectedExceptions = HelixException.class, expectedExceptionsMessageRegExp = "Cloud is not enabled.*")
-  public void testClusterCloudConfigSetup() {
-    ClusterConfig clusterConfig1 = new ClusterConfig(TEST_CLUSTER1);
-    when(_configAccessor.getClusterConfig(TEST_CLUSTER1)).thenReturn(clusterConfig1);
+  @Test(expectedExceptions = IllegalStateException.class,
+      expectedExceptionsMessageRegExp = "Topology-aware rebalance is not enabled.*")
+  public void testTopologyAwareEnabledSetup() {
+    when(_configAccessor.getClusterConfig(TEST_CLUSTER1)).thenReturn(new ClusterConfig(TEST_CLUSTER1));
     _service.addVirtualTopologyGroup(TEST_CLUSTER1, ImmutableMap.of(GROUP_NAME, "test-group", GROUP_NUMBER, "2"));
   }