Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A9A2D188B9 for ; Tue, 26 Jan 2016 01:13:34 +0000 (UTC) Received: (qmail 81215 invoked by uid 500); 26 Jan 2016 01:13:29 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 81141 invoked by uid 500); 26 Jan 2016 01:13:29 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 81128 invoked by uid 99); 26 Jan 2016 01:13:29 -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; Tue, 26 Jan 2016 01:13:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 58651DFF96; Tue, 26 Jan 2016 01:13:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jitendra@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-9672. o.a.h.hdfs.TestLeaseRecovery2 fails intermittently. Contributed by Mingliang Liu. Date: Tue, 26 Jan 2016 01:13:29 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/branch-2.8 3efc72ccd -> f1f61eac1 HDFS-9672. o.a.h.hdfs.TestLeaseRecovery2 fails intermittently. Contributed by Mingliang Liu. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f1f61eac Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f1f61eac Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f1f61eac Branch: refs/heads/branch-2.8 Commit: f1f61eac15f9a4dcf80131d4bb54aabc42ea254b Parents: 3efc72c Author: Jitendra Pandey Authored: Mon Jan 25 15:42:25 2016 -0800 Committer: Jitendra Pandey Committed: Mon Jan 25 17:06:23 2016 -0800 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../apache/hadoop/hdfs/TestLeaseRecovery2.java | 48 ++++++++++++++------ 2 files changed, 37 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/f1f61eac/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 94eed3e..e66ec7d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1733,6 +1733,9 @@ Release 2.7.3 - UNRELEASED HDFS-9625. set replication for empty file failed when set storage policy (DENG FEI via vinayakumarb) + HDFS-9672. o.a.h.hdfs.TestLeaseRecovery2 fails intermittently (Mingliang Liu + via jitendra) + Release 2.7.2 - 2016-01-25 INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/f1f61eac/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java index 13e8644..e8cd476 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java @@ -21,11 +21,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.spy; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import com.google.common.base.Supplier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -42,6 +45,7 @@ import org.apache.hadoop.hdfs.protocol.LocatedBlocks; import org.apache.hadoop.hdfs.server.common.HdfsServerConstants; import org.apache.hadoop.hdfs.server.datanode.DataNode; import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils; +import org.apache.hadoop.hdfs.server.namenode.FSEditLog; import org.apache.hadoop.hdfs.server.namenode.FSNamesystem; import org.apache.hadoop.hdfs.server.namenode.LeaseManager; import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter; @@ -49,10 +53,11 @@ import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.test.GenericTestUtils; import org.apache.log4j.Level; -import org.junit.AfterClass; +import org.junit.After; import org.junit.Assert; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; public class TestLeaseRecovery2 { @@ -85,12 +90,15 @@ public class TestLeaseRecovery2 { * * @throws IOException */ - @BeforeClass - public static void startUp() throws IOException { + @Before + public void startUp() throws IOException { conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_SIZE); conf.setInt(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1); - cluster = new MiniDFSCluster.Builder(conf).numDataNodes(5).build(); + cluster = new MiniDFSCluster.Builder(conf) + .numDataNodes(5) + .checkExitOnShutdown(false) + .build(); cluster.waitActive(); dfs = cluster.getFileSystem(); } @@ -99,8 +107,8 @@ public class TestLeaseRecovery2 { * stop the cluster * @throws IOException */ - @AfterClass - public static void tearDown() throws IOException { + @After + public void tearDown() throws IOException { if (cluster != null) { IOUtils.closeStream(dfs); cluster.shutdown(); @@ -419,17 +427,17 @@ public class TestLeaseRecovery2 { * * @throws Exception */ - @Test + @Test(timeout = 30000) public void testHardLeaseRecoveryAfterNameNodeRestart() throws Exception { hardLeaseRecoveryRestartHelper(false, -1); } - @Test + @Test(timeout = 30000) public void testHardLeaseRecoveryAfterNameNodeRestart2() throws Exception { hardLeaseRecoveryRestartHelper(false, 1535); } - @Test + @Test(timeout = 30000) public void testHardLeaseRecoveryWithRenameAfterNameNodeRestart() throws Exception { hardLeaseRecoveryRestartHelper(true, -1); @@ -489,10 +497,22 @@ public class TestLeaseRecovery2 { cluster.setLeasePeriod(LONG_LEASE_PERIOD, SHORT_LEASE_PERIOD); // Make sure lease recovery begins. - Thread.sleep(HdfsServerConstants.NAMENODE_LEASE_RECHECK_INTERVAL * 2); - - checkLease(fileStr, size); - + final String path = fileStr; + GenericTestUtils.waitFor(new Supplier() { + @Override + public Boolean get() { + return HdfsServerConstants.NAMENODE_LEASE_HOLDER.equals( + NameNodeAdapter.getLeaseHolderForPath(cluster.getNameNode(), path)); + } + }, (int)SHORT_LEASE_PERIOD, (int)SHORT_LEASE_PERIOD * 10); + + // Normally, the in-progress edit log would be finalized by + // FSEditLog#endCurrentLogSegment. For testing purposes, we + // disable that here. + FSEditLog spyLog = spy(cluster.getNameNode().getFSImage().getEditLog()); + doNothing().when(spyLog).endCurrentLogSegment(Mockito.anyBoolean()); + DFSTestUtil.setEditLogForTesting(cluster.getNamesystem(), spyLog); + cluster.restartNameNode(false); checkLease(fileStr, size);