HDFS-13542. TestBlockManager#testNeededReplicationWhileAppending fails due to improper cluster shutdown in TestBlockManager#testBlockManagerMachinesArray on Windows. Contributed by Anbang Hu.

This commit is contained in:
Inigo Goiri 2018-05-11 09:47:57 -07:00
parent a922b9c82c
commit d50c4d71dc
1 changed files with 84 additions and 69 deletions

View File

@ -452,8 +452,8 @@ public class TestBlockManager {
String src = "/test-file";
Path file = new Path(src);
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
cluster.waitActive();
try {
cluster.waitActive();
BlockManager bm = cluster.getNamesystem().getBlockManager();
FileSystem fs = cluster.getFileSystem();
NamenodeProtocols namenode = cluster.getNameNodeRpc();
@ -492,9 +492,11 @@ public class TestBlockManager {
IOUtils.closeStream(out);
}
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
/**
* Tell the block manager that replication is completed for the given
@ -1043,9 +1045,11 @@ public class TestBlockManager {
assertTrue(fs.exists(file1));
fs.delete(file1, true);
assertTrue(!fs.exists(file1));
if (cluster != null) {
cluster.shutdown();
}
}
}
@Test
public void testUseDelHint() {
@ -1143,9 +1147,11 @@ public class TestBlockManager {
assertEquals(0, bm.getBlockOpQueueLength());
assertTrue(doneLatch.await(1, TimeUnit.SECONDS));
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
// spam the block manager with IBRs to verify queuing is occurring.
@Test
@ -1218,15 +1224,18 @@ public class TestBlockManager {
long batched = MetricsAsserts.getLongCounter("BlockOpsBatched", rb);
assertTrue(batched > 0);
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
@Test(timeout = 60000)
public void testBlockManagerMachinesArray() throws Exception {
final Configuration conf = new HdfsConfiguration();
final MiniDFSCluster cluster =
new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
try {
cluster.waitActive();
BlockManager blockManager = cluster.getNamesystem().getBlockManager();
FileSystem fs = cluster.getFileSystem();
@ -1243,7 +1252,8 @@ public class TestBlockManager {
File storageDir = cluster.getInstanceStorageDir(0, 0);
File dataDir = MiniDFSCluster.getFinalizedDir(storageDir, bpid);
assertTrue("Data directory does not exist", dataDir.exists());
BlockInfo blockInfo = blockManager.blocksMap.getBlocks().iterator().next();
BlockInfo blockInfo =
blockManager.blocksMap.getBlocks().iterator().next();
ExtendedBlock blk = new ExtendedBlock(bpid, blockInfo.getBlockId(),
blockInfo.getNumBytes(), blockInfo.getGenerationStamp());
DatanodeDescriptor failedStorageDataNode =
@ -1297,6 +1307,11 @@ public class TestBlockManager {
"replicas and failed storages",
locatedBlocks.getLocatedBlocks().size() == 1);
ns.readUnlock();
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
@Test