From 0b977049cf0d83e419bee9ad826af7c6f0b86c36 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Wed, 9 Apr 2014 17:01:08 +0000 Subject: [PATCH] HDFS-6204. Fix TestRBWBlockInvalidation: change the last sleep to a loop. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1586039 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../TestRBWBlockInvalidation.java | 17 ++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 3d2675c1e9..40b4c70750 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -350,6 +350,9 @@ Release 2.4.1 - UNRELEASED HDFS-6206. Fix NullPointerException in DFSUtil.substituteForWildcardAddress. (szetszwo) + HDFS-6204. Fix TestRBWBlockInvalidation: change the last sleep to a loop. + (szetszwo) + Release 2.4.0 - 2014-04-07 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestRBWBlockInvalidation.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestRBWBlockInvalidation.java index d33efeeb8e..728934d65d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestRBWBlockInvalidation.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestRBWBlockInvalidation.java @@ -126,16 +126,15 @@ public void testBlockInvalidationWhenRBWReplicaMissedInDN() } Thread.sleep(100); } - assertEquals("There should be two live replicas", 2, - liveReplicas); + assertEquals("There should be two live replicas", 2, liveReplicas); - // sleep for 2 seconds, so that by this time datanode reports the corrupt - // block after a live replica of block got replicated. - Thread.sleep(2000); - - // Check that there is no corrupt block in the corruptReplicasMap. - assertEquals("There should not be any replica in the corruptReplicasMap", - 0, countReplicas(namesystem, blk).corruptReplicas()); + while (true) { + Thread.sleep(100); + if (countReplicas(namesystem, blk).corruptReplicas() == 0) { + LOG.info("Corrupt Replicas becomes 0"); + break; + } + } } finally { if (out != null) { out.close();