HDFS-13592. TestNameNodePrunesMissingStorages#testNameNodePrunesUnreportedStorages does not shut down cluster properly. Contributed by Anbang Hu.

This commit is contained in:
Inigo Goiri 2018-05-18 09:36:58 -07:00
parent 6e996867f6
commit 57b893de3d
1 changed files with 53 additions and 44 deletions

View File

@ -383,6 +383,8 @@ public class TestNameNodePrunesMissingStorages {
.Builder(conf).numDataNodes(1)
.storagesPerDatanode(2)
.build();
try {
cluster.waitActive();
// Create two files to ensure each storage has a block
DFSTestUtil.createFile(cluster.getFileSystem(), new Path("file1"),
102400, 102400, 102400, (short)1,
@ -392,7 +394,8 @@ public class TestNameNodePrunesMissingStorages {
0x1BAD5EED);
// Get the datanode storages and data directories
DataNode dn = cluster.getDataNodes().get(0);
BlockManager bm = cluster.getNameNode().getNamesystem().getBlockManager();
BlockManager bm =
cluster.getNameNode().getNamesystem().getBlockManager();
DatanodeDescriptor dnDescriptor = bm.getDatanodeManager().
getDatanode(cluster.getDataNodes().get(0).getDatanodeUuid());
DatanodeStorageInfo[] dnStoragesInfosBeforeRestart =
@ -421,7 +424,8 @@ public class TestNameNodePrunesMissingStorages {
}
}
assertEquals(1, numFailedStoragesWithBlocks);
// Heartbeat manager removes the blocks associated with this failed storage
// Heartbeat manager removes the blocks associated with this failed
// storage
bm.getDatanodeManager().getHeartbeatManager().heartbeatCheck();
assertTrue(!failedStorageInfo.areBlocksOnFailedStorage());
// pruneStorageMap removes the unreported storage
@ -429,5 +433,10 @@ public class TestNameNodePrunesMissingStorages {
// Assert that the unreported storage is pruned
assertEquals(DataNode.getStorageLocations(dn.getConf()).size(),
dnDescriptor.getStorageInfos().length);
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
}