HDFS-10603. Fix flaky tests in org.apache.hadoop.hdfs.server.namenode.snapshot.TestOpenFilesWithSnapshot. Contributed by Yiqun Lin.
(cherry picked from commit fc570b55b9d1d1d57329eca223f443e2c86f34b7) (cherry picked from commit c92601e9814a041800e466fabdcc3c44309364c4)
This commit is contained in:
parent
cf79ac5fa9
commit
d8181a8cb8
@ -69,7 +69,7 @@ public void testUCFileDeleteWithSnapShot() throws Exception {
|
||||
// delete files separately
|
||||
fs.delete(new Path("/test/test/test2"), true);
|
||||
fs.delete(new Path("/test/test/test3"), true);
|
||||
cluster.restartNameNode();
|
||||
restartNameNode();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -79,7 +79,7 @@ public void testParentDirWithUCFileDeleteWithSnapShot() throws Exception {
|
||||
|
||||
// delete parent directory
|
||||
fs.delete(new Path("/test/test"), true);
|
||||
cluster.restartNameNode();
|
||||
restartNameNode();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -87,11 +87,7 @@ public void testWithCheckpoint() throws Exception {
|
||||
Path path = new Path("/test");
|
||||
doWriteAndAbort(fs, path);
|
||||
fs.delete(new Path("/test/test"), true);
|
||||
NameNode nameNode = cluster.getNameNode();
|
||||
NameNodeAdapter.enterSafeMode(nameNode, false);
|
||||
NameNodeAdapter.saveNamespace(nameNode);
|
||||
NameNodeAdapter.leaveSafeMode(nameNode);
|
||||
cluster.restartNameNode(true);
|
||||
restartNameNode();
|
||||
|
||||
// read snapshot file after restart
|
||||
String test2snapshotPath = Snapshot.getSnapshotPath(path.toString(),
|
||||
@ -108,11 +104,7 @@ public void testFilesDeletionWithCheckpoint() throws Exception {
|
||||
doWriteAndAbort(fs, path);
|
||||
fs.delete(new Path("/test/test/test2"), true);
|
||||
fs.delete(new Path("/test/test/test3"), true);
|
||||
NameNode nameNode = cluster.getNameNode();
|
||||
NameNodeAdapter.enterSafeMode(nameNode, false);
|
||||
NameNodeAdapter.saveNamespace(nameNode);
|
||||
NameNodeAdapter.leaveSafeMode(nameNode);
|
||||
cluster.restartNameNode(true);
|
||||
restartNameNode();
|
||||
|
||||
// read snapshot file after restart
|
||||
String test2snapshotPath = Snapshot.getSnapshotPath(path.toString(),
|
||||
@ -203,6 +195,11 @@ public void testOpenFilesWithRename() throws Exception {
|
||||
|
||||
fs.rename(new Path("/test/test"), new Path("/test/test-renamed"));
|
||||
fs.delete(new Path("/test/test-renamed"), true);
|
||||
restartNameNode();
|
||||
}
|
||||
|
||||
private void restartNameNode() throws Exception {
|
||||
cluster.triggerBlockReports();
|
||||
NameNode nameNode = cluster.getNameNode();
|
||||
NameNodeAdapter.enterSafeMode(nameNode, false);
|
||||
NameNodeAdapter.saveNamespace(nameNode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user