From 3e50f478b9f40fccd7b22f8fbd95d2bfda7867d2 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 21 Oct 2015 14:55:23 -0700 Subject: [PATCH] HDFS-9225. Fix intermittent test failure of TestBlockManager.testBlocksAreNotUnderreplicatedInSingleRack. Contributed by Masatake Iwasaki. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 4 ++++ .../hdfs/server/blockmanagement/TestBlockManager.java | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index cf4abd40de..83418f857c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1549,6 +1549,10 @@ Release 2.8.0 - UNRELEASED HDFS-8647. Abstract BlockManager's rack policy into BlockPlacementPolicy. (Brahma Reddy Battula via mingma) + HDFS-9225. Fix intermittent test failure of + TestBlockManager.testBlocksAreNotUnderreplicatedInSingleRack. + (Masatake Iwasaki via wang) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java index 5692152358..16d482ecec 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java @@ -100,6 +100,7 @@ public void setupMockCluster() throws IOException { fsn = Mockito.mock(FSNamesystem.class); Mockito.doReturn(true).when(fsn).hasWriteLock(); Mockito.doReturn(true).when(fsn).hasReadLock(); + Mockito.doReturn(true).when(fsn).isRunning(); bm = new BlockManager(fsn, conf); final String[] racks = { "/rackA", @@ -373,9 +374,8 @@ private void doTestSingleRackClusterIsSufficientlyReplicated(int testIndex, List origNodes) throws Exception { assertEquals(0, bm.numOfUnderReplicatedBlocks()); - addBlockOnNodes(testIndex, origNodes); - bm.processMisReplicatedBlocks(); - assertEquals(0, bm.numOfUnderReplicatedBlocks()); + BlockInfo block = addBlockOnNodes(testIndex, origNodes); + assertFalse(bm.isNeededReplication(block, bm.countLiveNodes(block))); }