HDFS-14054. TestLeaseRecovery2: testHardLeaseRecoveryAfterNameNodeRestart2 and testHardLeaseRecoveryWithRenameAfterNameNodeRestart are flaky. Contributed by Zsolt Venczel.

(cherry picked from commit 993c2140ccfb4c6dfd09c0c686b85a4b58cb39a2)
This commit is contained in:
Inigo Goiri 2018-11-15 09:29:14 -08:00
parent 75516620c8
commit b411fcee86

View File

@ -497,6 +497,13 @@ public void hardLeaseRecoveryRestartHelper(boolean doRename, int size)
// set the hard limit to be 1 second // set the hard limit to be 1 second
cluster.setLeasePeriod(LONG_LEASE_PERIOD, SHORT_LEASE_PERIOD); cluster.setLeasePeriod(LONG_LEASE_PERIOD, SHORT_LEASE_PERIOD);
// 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);
// Make sure lease recovery begins. // Make sure lease recovery begins.
final String path = fileStr; final String path = fileStr;
GenericTestUtils.waitFor(new Supplier<Boolean>() { GenericTestUtils.waitFor(new Supplier<Boolean>() {
@ -504,16 +511,10 @@ public void hardLeaseRecoveryRestartHelper(boolean doRename, int size)
public Boolean get() { public Boolean get() {
String holder = String holder =
NameNodeAdapter.getLeaseHolderForPath(cluster.getNameNode(), path); NameNodeAdapter.getLeaseHolderForPath(cluster.getNameNode(), path);
return holder.startsWith(HdfsServerConstants.NAMENODE_LEASE_HOLDER); return holder!=null && holder
.startsWith(HdfsServerConstants.NAMENODE_LEASE_HOLDER);
} }
}, (int)SHORT_LEASE_PERIOD, (int)SHORT_LEASE_PERIOD * 10); }, (int)SHORT_LEASE_PERIOD, (int)SHORT_LEASE_PERIOD * 20);
// 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); cluster.restartNameNode(false);