|
@@ -159,89 +159,4 @@ public class TestStorageContainerManager {
|
|
|
Assert.assertTrue(e instanceof IOException);
|
|
|
Assert.assertEquals(expectedErrorMessage, e.getMessage());
|
|
|
}
|
|
|
-
|
|
|
- // TODO : Disabling this test after verifying that failure is due
|
|
|
- // Not Implemented exception. Will turn on this test in next patch
|
|
|
- //@Test
|
|
|
- public void testLocationsForSingleKey() throws Exception {
|
|
|
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1)
|
|
|
- .setHandlerType(OzoneConsts.OZONE_HANDLER_DISTRIBUTED).build();
|
|
|
- storageContainerLocationClient =
|
|
|
- cluster.createStorageContainerLocationClient();
|
|
|
- Set<LocatedContainer> containers =
|
|
|
- storageContainerLocationClient.getStorageContainerLocations(
|
|
|
- new LinkedHashSet<>(Arrays.asList("/key1")));
|
|
|
- assertNotNull(containers);
|
|
|
- assertEquals(1, containers.size());
|
|
|
- assertLocatedContainer(containers, "/key1", 1);
|
|
|
- }
|
|
|
-
|
|
|
- // TODO : Disabling this test after verifying that failure is due
|
|
|
- // Not Implemented exception. Will turn on this test in next patch
|
|
|
- //@Test
|
|
|
- public void testLocationsForMultipleKeys() throws Exception {
|
|
|
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1)
|
|
|
- .setHandlerType(OzoneConsts.OZONE_HANDLER_DISTRIBUTED).build();
|
|
|
- storageContainerLocationClient =
|
|
|
- cluster.createStorageContainerLocationClient();
|
|
|
- Set<LocatedContainer> containers =
|
|
|
- storageContainerLocationClient.getStorageContainerLocations(
|
|
|
- new LinkedHashSet<>(Arrays.asList("/key1", "/key2", "/key3")));
|
|
|
- assertNotNull(containers);
|
|
|
- assertEquals(3, containers.size());
|
|
|
- assertLocatedContainer(containers, "/key1", 1);
|
|
|
- assertLocatedContainer(containers, "/key2", 1);
|
|
|
- assertLocatedContainer(containers, "/key3", 1);
|
|
|
- }
|
|
|
- // TODO : Disabling this test after verifying that failure is due
|
|
|
- // Not Implemented exception. Will turn on this test in next patch
|
|
|
- //@Test
|
|
|
- public void testNoDataNodes() throws Exception {
|
|
|
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(0)
|
|
|
- .setHandlerType(OzoneConsts.OZONE_HANDLER_DISTRIBUTED)
|
|
|
- .doNotwaitTobeOutofChillMode()
|
|
|
- .build();
|
|
|
- storageContainerLocationClient =
|
|
|
- cluster.createStorageContainerLocationClient();
|
|
|
- exception.expect(IOException.class);
|
|
|
- exception.expectMessage("locations not found");
|
|
|
- storageContainerLocationClient.getStorageContainerLocations(
|
|
|
- new LinkedHashSet<>(Arrays.asList("/key1")));
|
|
|
- }
|
|
|
-
|
|
|
- // TODO : Disabling this test after verifying that failure is due
|
|
|
- // Not Implemented exception. Will turn on this test in next patch
|
|
|
- //@Test
|
|
|
- public void testMultipleDataNodes() throws Exception {
|
|
|
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(3)
|
|
|
- .setHandlerType(OzoneConsts.OZONE_HANDLER_DISTRIBUTED).build();
|
|
|
- storageContainerLocationClient =
|
|
|
- cluster.createStorageContainerLocationClient();
|
|
|
- Set<LocatedContainer> containers =
|
|
|
- storageContainerLocationClient.getStorageContainerLocations(
|
|
|
- new LinkedHashSet<>(Arrays.asList("/key1")));
|
|
|
- assertNotNull(containers);
|
|
|
- assertEquals(1, containers.size());
|
|
|
- assertLocatedContainer(containers, "/key1", 3);
|
|
|
- }
|
|
|
-
|
|
|
- private static void assertLocatedContainer(Set<LocatedContainer> containers,
|
|
|
- String key, int expectedNumLocations) {
|
|
|
- LocatedContainer container = null;
|
|
|
- for (LocatedContainer curContainer: containers) {
|
|
|
- if (key.equals(curContainer.getKey())) {
|
|
|
- container = curContainer;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- assertNotNull("Container for key " + key + " not found.", container);
|
|
|
- assertEquals(key, container.getKey());
|
|
|
- assertNotNull(container.getMatchedKeyPrefix());
|
|
|
- assertFalse(container.getMatchedKeyPrefix().isEmpty());
|
|
|
- assertNotNull(container.getContainerName());
|
|
|
- assertFalse(container.getContainerName().isEmpty());
|
|
|
- assertNotNull(container.getLocations());
|
|
|
- assertEquals(expectedNumLocations, container.getLocations().size());
|
|
|
- assertNotNull(container.getLeader());
|
|
|
- }
|
|
|
}
|