Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9F5A5200BC1 for ; Wed, 16 Nov 2016 22:06:14 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9E266160B08; Wed, 16 Nov 2016 21:06:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E9908160B02 for ; Wed, 16 Nov 2016 22:06:13 +0100 (CET) Received: (qmail 22028 invoked by uid 500); 16 Nov 2016 21:06:13 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 22019 invoked by uid 99); 16 Nov 2016 21:06:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2016 21:06:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DE7DAE0209; Wed, 16 Nov 2016 21:06:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: liuml07@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-11105. TestRBWBlockInvalidation#testRWRInvalidation fails intermittently. Contributed by Yiqun Lin Date: Wed, 16 Nov 2016 21:06:12 +0000 (UTC) archived-at: Wed, 16 Nov 2016 21:06:14 -0000 Repository: hadoop Updated Branches: refs/heads/trunk b8690a9d2 -> c90891e7b HDFS-11105. TestRBWBlockInvalidation#testRWRInvalidation fails intermittently. 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/c90891e7 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c90891e7 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c90891e7 Branch: refs/heads/trunk Commit: c90891e7b3afaa66dbca967b83a9997e80e893d8 Parents: b8690a9 Author: Mingliang Liu Authored: Wed Nov 16 13:02:10 2016 -0800 Committer: Mingliang Liu Committed: Wed Nov 16 13:02:10 2016 -0800 ---------------------------------------------------------------------- .../TestRBWBlockInvalidation.java | 45 +++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/c90891e7/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestRBWBlockInvalidation.java ---------------------------------------------------------------------- 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 9816af8..cb2ee9c 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 @@ -41,8 +41,10 @@ import org.apache.hadoop.hdfs.server.namenode.FSNamesystem; import org.apache.hadoop.hdfs.server.namenode.ha.HATestUtil; import org.apache.hadoop.hdfs.server.namenode.ha.TestDNFencing.RandomDeleterPolicy; import org.apache.hadoop.io.IOUtils; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Test; +import com.google.common.base.Supplier; import com.google.common.collect.Lists; /** @@ -141,7 +143,7 @@ public class TestRBWBlockInvalidation { * were RWR replicas with out-of-date genstamps, the NN could accidentally * delete good replicas instead of the bad replicas. */ - @Test(timeout=60000) + @Test(timeout=120000) public void testRWRInvalidation() throws Exception { Configuration conf = new HdfsConfiguration(); @@ -156,10 +158,11 @@ public class TestRBWBlockInvalidation { // Speed up the test a bit with faster heartbeats. conf.setInt(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1); + int numFiles = 10; // Test with a bunch of separate files, since otherwise the test may // fail just due to "good luck", even if a bug is present. List testPaths = Lists.newArrayList(); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < numFiles; i++) { testPaths.add(new Path("/test" + i)); } @@ -176,8 +179,11 @@ public class TestRBWBlockInvalidation { out.writeBytes("old gs data\n"); out.hflush(); } - - + + for (Path path : testPaths) { + DFSTestUtil.waitReplication(cluster.getFileSystem(), path, (short)2); + } + // Shutdown one of the nodes in the pipeline DataNodeProperties oldGenstampNode = cluster.stopDataNode(0); @@ -195,7 +201,11 @@ public class TestRBWBlockInvalidation { cluster.getFileSystem().setReplication(path, (short)1); out.close(); } - + + for (Path path : testPaths) { + DFSTestUtil.waitReplication(cluster.getFileSystem(), path, (short)1); + } + // Upon restart, there will be two replicas, one with an old genstamp // and one current copy. This test wants to ensure that the old genstamp // copy is the one that is deleted. @@ -218,7 +228,8 @@ public class TestRBWBlockInvalidation { cluster.triggerHeartbeats(); HATestUtil.waitForDNDeletions(cluster); cluster.triggerDeletionReports(); - + + waitForNumTotalBlocks(cluster, numFiles); // Make sure we can still read the blocks. for (Path path : testPaths) { String ret = DFSTestUtil.readFile(cluster.getFileSystem(), path); @@ -232,4 +243,26 @@ public class TestRBWBlockInvalidation { } } + + private void waitForNumTotalBlocks(final MiniDFSCluster cluster, + final int numTotalBlocks) throws Exception { + GenericTestUtils.waitFor(new Supplier() { + + @Override + public Boolean get() { + try { + cluster.triggerBlockReports(); + + // Wait total blocks + if (cluster.getNamesystem().getBlocksTotal() == numTotalBlocks) { + return true; + } + } catch (Exception ignored) { + // Ignore the exception + } + + return false; + } + }, 1000, 60000); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org