|
20 | 20 | import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.createFile; |
21 | 21 | import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.verifyFileExists; |
22 | 22 | import static org.junit.Assert.assertEquals; |
| 23 | +import static org.junit.Assert.assertFalse; |
23 | 24 | import static org.junit.Assert.assertTrue; |
24 | 25 | import static org.junit.Assert.fail; |
25 | 26 | import static org.mockito.Matchers.any; |
|
38 | 39 | import java.util.Set; |
39 | 40 | import java.util.TreeSet; |
40 | 41 |
|
| 42 | +import org.apache.hadoop.fs.FSDataOutputStream; |
41 | 43 | import org.apache.hadoop.fs.FileStatus; |
42 | 44 | import org.apache.hadoop.fs.FileSystem; |
43 | 45 | import org.apache.hadoop.fs.Path; |
|
55 | 57 | import org.apache.hadoop.hdfs.server.namenode.FSNamesystem; |
56 | 58 | import org.apache.hadoop.hdfs.server.namenode.NameNode; |
57 | 59 | import org.apache.hadoop.hdfs.server.namenode.ha.HAContext; |
| 60 | +import org.apache.hadoop.io.IOUtils; |
58 | 61 | import org.apache.hadoop.ipc.RemoteException; |
59 | 62 | import org.apache.hadoop.ipc.StandbyException; |
60 | 63 | import org.apache.hadoop.test.GenericTestUtils; |
@@ -230,6 +233,28 @@ public void testProxyRenameFiles() throws IOException, InterruptedException { |
230 | 233 | testRename2(getRouterContext(), filename1, renamedFile, false); |
231 | 234 | } |
232 | 235 |
|
| 236 | + /** |
| 237 | + * Test recoverLease when the result is false. |
| 238 | + */ |
| 239 | + @Test |
| 240 | + public void testRecoverLease() throws Exception { |
| 241 | + Path testPath = new Path("/recovery/test_recovery_lease"); |
| 242 | + DistributedFileSystem routerFs = |
| 243 | + (DistributedFileSystem) getRouterFileSystem(); |
| 244 | + FSDataOutputStream fsDataOutputStream = null; |
| 245 | + try { |
| 246 | + fsDataOutputStream = routerFs.create(testPath); |
| 247 | + fsDataOutputStream.write("hello world".getBytes()); |
| 248 | + fsDataOutputStream.hflush(); |
| 249 | + |
| 250 | + boolean result = routerFs.recoverLease(testPath); |
| 251 | + assertFalse(result); |
| 252 | + } finally { |
| 253 | + IOUtils.closeStream(fsDataOutputStream); |
| 254 | + routerFs.delete(testPath, true); |
| 255 | + } |
| 256 | + } |
| 257 | + |
233 | 258 | @Test |
234 | 259 | public void testGetContentSummaryEc() throws Exception { |
235 | 260 | DistributedFileSystem routerDFS = |
|
0 commit comments