mgao0 commented on a change in pull request #849: Add REST APIs for get, set,
update RestConfig
URL: https://github.com/apache/helix/pull/849#discussion_r390600758
##########
File path:
helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
##########
@@ -576,6 +577,70 @@ public void testEnableWagedRebalanceForAllResources() {
}
}
+ @Test
+ public void testCreateClusterRESTConfig() throws IOException {
+ System.out.println("Start test :" + TestHelper.getTestMethodName());
+ String cluster = _clusters.iterator().next();
+ RESTConfig restConfigRest = new RESTConfig(cluster);
+ restConfigRest.set(RESTConfig.SimpleFields.CUSTOMIZED_HEALTH_URL,
"http://*:00");
+ put("clusters/" + cluster + "/restconfig", null, Entity
+ .entity(OBJECT_MAPPER.writeValueAsString(restConfigRest.getRecord()),
+ MediaType.APPLICATION_JSON_TYPE),
Response.Status.OK.getStatusCode());
+ RESTConfig restConfigZK = _configAccessor.getRESTConfig(cluster);
+ Assert.assertEquals(restConfigZK, restConfigRest,
+ "rest config from response: " + restConfigRest + " vs rest config
actually: "
+ + restConfigZK);
+ System.out.println("End test :" + TestHelper.getTestMethodName());
+ }
+
+ @Test(dependsOnMethods = "testCreateClusterRESTConfig")
+ public void testUpdateClusterRESTConfig() throws IOException {
+ System.out.println("Start test :" + TestHelper.getTestMethodName());
+ String cluster = _clusters.iterator().next();
+ RESTConfig restConfigRest = new RESTConfig(cluster);
+ // Update an entry
+ restConfigRest.set(RESTConfig.SimpleFields.CUSTOMIZED_HEALTH_URL,
"http://*:01");
+ Entity entity =
Entity.entity(OBJECT_MAPPER.writeValueAsString(restConfigRest.getRecord()),
+ MediaType.APPLICATION_JSON_TYPE);
+ post("clusters/" + cluster + "/restconfig", ImmutableMap.of("command",
Command.update.name()),
+ entity, Response.Status.OK.getStatusCode());
+ RESTConfig restConfigZK = _configAccessor.getRESTConfig(cluster);
+ Assert.assertEquals(restConfigZK, restConfigRest,
+ "rest config from response: " + restConfigRest + " vs rest config
actually: "
+ + restConfigZK);
+
+ // Delete an entry
+ restConfigRest.set(RESTConfig.SimpleFields.CUSTOMIZED_HEALTH_URL, null);
+ entity =
Entity.entity(OBJECT_MAPPER.writeValueAsString(restConfigRest.getRecord()),
+ MediaType.APPLICATION_JSON_TYPE);
+ post("clusters/" + cluster + "/restconfig", ImmutableMap.of("command",
Command.delete.name()),
+ entity, Response.Status.OK.getStatusCode());
+ restConfigZK = _configAccessor.getRESTConfig(cluster);
+ Assert.assertEquals(restConfigZK, new RESTConfig(cluster),
+ "rest config from response: " + new RESTConfig(cluster) + " vs rest
config actually: "
+ + restConfigZK);
+ System.out.println("End test :" + TestHelper.getTestMethodName());
Review comment:
Added one more test after the first draft. Moving it down.
----------------------------------------------------------------
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]