HDFS-10990. TestPendingInvalidateBlock should wait for IBRs. Contributed by Yiqun Lin.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fdce5150 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fdce5150 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fdce5150 Branch: refs/heads/HDFS-10285 Commit: fdce515091f0a61ffd6c9ae464a68447dedf1124 Parents: 008122b Author: Andrew Wang <w...@apache.org> Authored: Thu Oct 13 11:41:37 2016 -0700 Committer: Andrew Wang <w...@apache.org> Committed: Thu Oct 13 11:41:37 2016 -0700 ---------------------------------------------------------------------- .../blockmanagement/TestPendingInvalidateBlock.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/fdce5150/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java index 696b2aa..19f3178 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java @@ -86,6 +86,8 @@ public class TestPendingInvalidateBlock { public void testPendingDeletion() throws Exception { final Path foo = new Path("/foo"); DFSTestUtil.createFile(dfs, foo, BLOCKSIZE, REPLICATION, 0); + DFSTestUtil.waitForReplication(dfs, foo, REPLICATION, 10000); + // restart NN cluster.restartNameNode(true); InvalidateBlocks invalidateBlocks = @@ -98,6 +100,7 @@ public class TestPendingInvalidateBlock { "invalidateBlocks", mockIb); dfs.delete(foo, true); + waitForNumPendingDeletionBlocks(REPLICATION); Assert.assertEquals(0, cluster.getNamesystem().getBlocksTotal()); Assert.assertEquals(REPLICATION, cluster.getNamesystem() .getPendingDeletionBlocks()); @@ -105,7 +108,7 @@ public class TestPendingInvalidateBlock { dfs.getPendingDeletionBlocksCount()); Mockito.doReturn(0L).when(mockIb).getInvalidationDelay(); - waitForBlocksToDelete(); + waitForNumPendingDeletionBlocks(0); Assert.assertEquals(0, cluster.getNamesystem().getBlocksTotal()); Assert.assertEquals(0, cluster.getNamesystem().getPendingDeletionBlocks()); Assert.assertEquals(0, dfs.getPendingDeletionBlocksCount()); @@ -182,7 +185,7 @@ public class TestPendingInvalidateBlock { Assert.assertEquals(4, cluster.getNamesystem().getPendingDeletionBlocks()); cluster.restartNameNode(true); - waitForBlocksToDelete(); + waitForNumPendingDeletionBlocks(0); Assert.assertEquals(3, cluster.getNamesystem().getBlocksTotal()); Assert.assertEquals(0, cluster.getNamesystem().getPendingDeletionBlocks()); } @@ -199,7 +202,8 @@ public class TestPendingInvalidateBlock { return cluster.getNamesystem().getUnderReplicatedBlocks(); } - private void waitForBlocksToDelete() throws Exception { + private void waitForNumPendingDeletionBlocks(int numBlocks) + throws Exception { GenericTestUtils.waitFor(new Supplier<Boolean>() { @Override @@ -207,7 +211,8 @@ public class TestPendingInvalidateBlock { try { cluster.triggerBlockReports(); - if (cluster.getNamesystem().getPendingDeletionBlocks() == 0) { + if (cluster.getNamesystem().getPendingDeletionBlocks() + == numBlocks) { return true; } } catch (Exception e) { --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org