You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2022/02/16 00:33:14 UTC
[GitHub] [helix] qqu0127 commented on a change in pull request #1958: Add rest endpoint for virtual topology group
qqu0127 commented on a change in pull request #1958:
URL: https://github.com/apache/helix/pull/1958#discussion_r807433781
##########
File path: helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
##########
@@ -223,6 +222,108 @@ public void testGetClusterTopologyAndFaultZoneMap() throws IOException {
"/instance:TestCluster_1localhost_12927"))));
}
+ @Test(dataProvider = "prepareVirtualTopologyTests", dependsOnMethods = "testGetClusters")
+ public void testAddVirtualTopologyGroup(String requestParam, int numGroups,
+ Map<String, String> instanceToGroup) throws IOException {
+ post("clusters/" + VG_CLUSTER,
+ ImmutableMap.of("command", "addVirtualTopologyGroup"),
+ Entity.entity(requestParam, MediaType.APPLICATION_JSON_TYPE),
+ Response.Status.OK.getStatusCode());
+ Map<String, Object> topology = getMapResponseFromRest(String.format("clusters/%s/topology", VG_CLUSTER));
+ Assert.assertTrue(topology.containsKey("zones"));
+ Assert.assertEquals(((List) topology.get("zones")).size(), numGroups);
+
+ ClusterConfig clusterConfig = getClusterConfigFromRest(VG_CLUSTER);
+ String expectedTopology = "/" + VirtualTopologyGroupConstants.VIRTUAL_FAULT_ZONE_TYPE + "/hostname";
+ Assert.assertEquals(clusterConfig.getTopology(), expectedTopology);
+ Assert.assertEquals(clusterConfig.getFaultZoneType(), VirtualTopologyGroupConstants.VIRTUAL_FAULT_ZONE_TYPE);
+
+ HelixDataAccessor helixDataAccessor = new ZKHelixDataAccessor(VG_CLUSTER, _baseAccessor);
+ for (Map.Entry<String, String> entry : instanceToGroup.entrySet()) {
+ InstanceConfig instanceConfig =
+ helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().instanceConfig(entry.getKey()));
+ String expectedGroup = entry.getValue();
+ Assert.assertEquals(instanceConfig.getDomainAsMap().get(VirtualTopologyGroupConstants.VIRTUAL_FAULT_ZONE_TYPE),
+ expectedGroup);
+ }
+ }
+
+ @Test(dependsOnMethods = "testGetClusters")
+ public void testVirtualTopologyGroupMaintenanceMode() throws JsonProcessingException {
+ setupClusterForVirtualTopology(VG_CLUSTER);
+ String requestParam = "{\"virtualTopologyGroupNumber\":\"7\",\"virtualTopologyGroupName\":\"vgTest\","
+ + "\"autoMaintenanceModeDisabled\":\"true\"}";
+ // expect failure as cluster is not in maintenance mode while autoMaintenanceModeDisabled=true
+ post("clusters/" + VG_CLUSTER,
+ ImmutableMap.of("command", "addVirtualTopologyGroup"),
+ Entity.entity(requestParam, MediaType.APPLICATION_JSON_TYPE),
+ Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
+ // enable maintenance mode and expect success
+ post("clusters/" + VG_CLUSTER,
+ ImmutableMap.of("command", "enableMaintenanceMode"),
+ Entity.entity("virtual group", MediaType.APPLICATION_JSON_TYPE),
+ Response.Status.OK.getStatusCode());
+ post("clusters/" + VG_CLUSTER,
+ ImmutableMap.of("command", "addVirtualTopologyGroup"),
+ Entity.entity(requestParam, MediaType.APPLICATION_JSON_TYPE),
+ Response.Status.OK.getStatusCode());
+
+ Assert.assertTrue(isMaintenanceModeEnabled(VG_CLUSTER));
+ }
+
+ private boolean isMaintenanceModeEnabled(String clusterName) throws JsonProcessingException {
+ String body =
+ get("clusters/" + clusterName + "/maintenance", null, Response.Status.OK.getStatusCode(), true);
+ return OBJECT_MAPPER.readTree(body).get(ClusterAccessor.ClusterProperties.maintenance.name()).booleanValue();
+ }
+
+ @DataProvider
+ public Object[][] prepareVirtualTopologyTests() {
Review comment:
The test cases are ordered in a way to test 7 -> 9 -> 7, we are covering it already with the 9 -> 7 jump.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org