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/8a9f6635 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8a9f6635 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8a9f6635 Branch: refs/heads/HDFS-10285 Commit: 8a9f6635a33e9648e9396e9ec5571fa34aa0c773 Parents: dbe663d Author: Kihwal Lee <kih...@apache.org> Authored: Fri Oct 14 11:38:48 2016 -0500 Committer: Kihwal Lee <kih...@apache.org> Committed: Fri Oct 14 11:38:48 2016 -0500 ---------------------------------------------------------------------- .../blockmanagement/TestPendingInvalidateBlock.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/8a9f6635/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..d856065 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(final 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