Skip to content
Permalink
Browse files
Remove cloud config check in VirtualTopologyGroupService (#2190)
Remove the dependency on CloudConfig for setting virtual topology group.
  • Loading branch information
qqu0127 committed Aug 15, 2022
1 parent 3ea5d4a commit d896d2e690582d464da872706d5e7eb092d34f22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
@@ -89,11 +89,6 @@ public VirtualTopologyGroupService(HelixAdmin helixAdmin, ClusterService cluster
*/
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);
@@ -83,13 +83,6 @@ public void prepare() {
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 void prepare() {
_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"));
}

0 comments on commit d896d2e

Please sign in to comment.