From 993c2140ccfb4c6dfd09c0c686b85a4b58cb39a2 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Thu, 15 Nov 2018 09:29:14 -0800 Subject: [PATCH] HDFS-14054. TestLeaseRecovery2: testHardLeaseRecoveryAfterNameNodeRestart2 and testHardLeaseRecoveryWithRenameAfterNameNodeRestart are flaky. Contributed by Zsolt Venczel. --- .../hadoop/hdfs/TestLeaseRecovery2.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) 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 5f16a99253..bcd3cdc085 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 @@ -562,17 +562,6 @@ public void hardLeaseRecoveryRestartHelper(boolean doRename, int size) // set the hard limit to be 1 second cluster.setLeasePeriod(LONG_LEASE_PERIOD, SHORT_LEASE_PERIOD); - - // Make sure lease recovery begins. - final String path = fileStr; - GenericTestUtils.waitFor(new Supplier() { - @Override - public Boolean get() { - String holder = - NameNodeAdapter.getLeaseHolderForPath(cluster.getNameNode(), path); - return holder.startsWith(HdfsServerConstants.NAMENODE_LEASE_HOLDER); - } - }, (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 @@ -581,6 +570,18 @@ public Boolean get() { doNothing().when(spyLog).endCurrentLogSegment(Mockito.anyBoolean()); DFSTestUtil.setEditLogForTesting(cluster.getNamesystem(), spyLog); + // Make sure lease recovery begins. + final String path = fileStr; + GenericTestUtils.waitFor(new Supplier() { + @Override + public Boolean get() { + String holder = + NameNodeAdapter.getLeaseHolderForPath(cluster.getNameNode(), path); + return holder!=null && holder + .startsWith(HdfsServerConstants.NAMENODE_LEASE_HOLDER); + } + }, (int)SHORT_LEASE_PERIOD, (int)SHORT_LEASE_PERIOD * 20); + cluster.restartNameNode(false); checkLease(fileStr, size);