pkuwm commented on a change in pull request #757: Add write REST endpoints to
helix rest for metadata store directory
URL: https://github.com/apache/helix/pull/757#discussion_r379149852
##########
File path:
helix-rest/src/test/java/org/apache/helix/rest/server/resources/zookeeper/TestMetadataStoreDirectoryAccessor.java
##########
@@ -167,9 +254,58 @@ public void testGetShardingKeysInRealm() throws
IOException {
Assert.assertEquals(queriedShardingKeys, expectedShardingKeys);
}
+ @Test
+ public void testAddShardingKey() {
+ Set<String> expectedShardingKeysSet = new HashSet<>(
+ _metadataStoreDirectory.getAllShardingKeysInRealm(TEST_NAMESPACE,
TEST_REALM_1));
+
+ Assert.assertFalse(expectedShardingKeysSet.contains(TEST_SHARDING_KEY),
+ "Realm does not have sharding key: " + TEST_SHARDING_KEY);
+
+ // Request that gets not found response.
+ put(NON_EXISTING_NAMESPACE_URI_PREFIX + TEST_REALM_1 + "/sharding-keys/" +
TEST_SHARDING_KEY,
+ null, Entity.entity("", MediaType.APPLICATION_JSON_TYPE),
+ Response.Status.NOT_FOUND.getStatusCode());
+
+ // Successful request.
+ put(TEST_NAMESPACE_URI_PREFIX + "/metadata-store-realms/" + TEST_REALM_1 +
"/sharding-keys/"
+ + TEST_SHARDING_KEY, null, Entity.entity("",
MediaType.APPLICATION_JSON_TYPE),
+ Response.Status.CREATED.getStatusCode());
+
+ Set<String> updatedShardingKeysSet = new HashSet<>(
+ _metadataStoreDirectory.getAllShardingKeysInRealm(TEST_NAMESPACE,
TEST_REALM_1));
+ expectedShardingKeysSet.add(TEST_SHARDING_KEY);
+
+// Assert.assertEquals(updatedShardingKeysSet, expectedShardingKeysSet);
+ }
+
+ @Test(dependsOnMethods = "testAddShardingKey")
+ public void testDeleteShardingKey() {
+ Set<String> expectedShardingKeysSet = new HashSet<>(
+ _metadataStoreDirectory.getAllShardingKeysInRealm(TEST_NAMESPACE,
TEST_REALM_1));
+
+// Assert.assertTrue(expectedShardingKeysSet.contains(TEST_SHARDING_KEY),
+// "Realm should have sharding key: " + TEST_SHARDING_KEY);
+
+ // Request that gets not found response.
+ delete(NON_EXISTING_NAMESPACE_URI_PREFIX + TEST_REALM_1 +
"/sharding-keys/" + TEST_SHARDING_KEY,
+ Response.Status.NOT_FOUND.getStatusCode());
+
+ // Successful request.
+ delete(TEST_NAMESPACE_URI_PREFIX + "/metadata-store-realms/" +
TEST_REALM_1 + "/sharding-keys/"
+ + TEST_SHARDING_KEY, Response.Status.OK.getStatusCode());
+
+ Set<String> updatedShardingKeysSet = new HashSet<>(
+ _metadataStoreDirectory.getAllShardingKeysInRealm(TEST_NAMESPACE,
TEST_REALM_1));
+ expectedShardingKeysSet.remove(TEST_SHARDING_KEY);
+
+// Assert.assertEquals(updatedShardingKeysSet, expectedShardingKeysSet);
+ }
+
@AfterClass
public void afterClass() {
+ _metadataStoreDirectory.close();
_zkList.forEach(zk -> ZK_SERVER_MAP.get(zk).getZkClient()
- .deleteRecursive(MetadataStoreRoutingConstants.ROUTING_DATA_PATH));
+ .deleteRecursively(MetadataStoreRoutingConstants.ROUTING_DATA_PATH));
Review comment:
`deleteRecursively` is a sync blocking call. Once `deleteRecursively`
completes, the path is deleted.
----------------------------------------------------------------
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]