|
@@ -26,6 +26,7 @@ import org.apache.hadoop.fs.FileStatus;
|
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.FileSystemTestHelper;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
+import org.apache.hadoop.fs.RemoteIterator;
|
|
|
import org.apache.hadoop.fs.http.server.HttpFSServerWebApp;
|
|
|
import org.apache.hadoop.fs.permission.AclEntry;
|
|
|
import org.apache.hadoop.fs.permission.AclStatus;
|
|
@@ -44,6 +45,7 @@ import org.apache.hadoop.test.TestHdfsHelper;
|
|
|
import org.apache.hadoop.test.TestJetty;
|
|
|
import org.apache.hadoop.test.TestJettyHelper;
|
|
|
import org.junit.Assert;
|
|
|
+import org.junit.Assume;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.junit.runners.Parameterized;
|
|
@@ -62,6 +64,7 @@ import java.io.Writer;
|
|
|
import java.net.URI;
|
|
|
import java.net.URL;
|
|
|
import java.security.PrivilegedExceptionAction;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
@@ -136,14 +139,19 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
|
|
|
return "webhdfs";
|
|
|
}
|
|
|
|
|
|
- protected FileSystem getHttpFSFileSystem() throws Exception {
|
|
|
- Configuration conf = new Configuration();
|
|
|
+ protected FileSystem getHttpFSFileSystem(Configuration conf) throws
|
|
|
+ Exception {
|
|
|
conf.set("fs.webhdfs.impl", getFileSystemClass().getName());
|
|
|
URI uri = new URI(getScheme() + "://" +
|
|
|
TestJettyHelper.getJettyURL().toURI().getAuthority());
|
|
|
return FileSystem.get(uri, conf);
|
|
|
}
|
|
|
|
|
|
+ protected FileSystem getHttpFSFileSystem() throws Exception {
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ return getHttpFSFileSystem(conf);
|
|
|
+ }
|
|
|
+
|
|
|
protected void testGet() throws Exception {
|
|
|
FileSystem fs = getHttpFSFileSystem();
|
|
|
Assert.assertNotNull(fs);
|
|
@@ -355,6 +363,51 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
|
|
|
assertEquals(stati[0].getPath().getName(), path.getName());
|
|
|
}
|
|
|
|
|
|
+ private static void assertSameListing(FileSystem expected, FileSystem
|
|
|
+ actual, Path p) throws IOException {
|
|
|
+ // Consume all the entries from both iterators
|
|
|
+ RemoteIterator<FileStatus> exIt = expected.listStatusIterator(p);
|
|
|
+ List<FileStatus> exStatuses = new ArrayList<>();
|
|
|
+ while (exIt.hasNext()) {
|
|
|
+ exStatuses.add(exIt.next());
|
|
|
+ }
|
|
|
+ RemoteIterator<FileStatus> acIt = actual.listStatusIterator(p);
|
|
|
+ List<FileStatus> acStatuses = new ArrayList<>();
|
|
|
+ while (acIt.hasNext()) {
|
|
|
+ acStatuses.add(acIt.next());
|
|
|
+ }
|
|
|
+ assertEquals(exStatuses.size(), acStatuses.size());
|
|
|
+ for (int i = 0; i < exStatuses.size(); i++) {
|
|
|
+ FileStatus expectedStatus = exStatuses.get(i);
|
|
|
+ FileStatus actualStatus = acStatuses.get(i);
|
|
|
+ // Path URIs are fully qualified, so compare just the path component
|
|
|
+ assertEquals(expectedStatus.getPath().toUri().getPath(),
|
|
|
+ actualStatus.getPath().toUri().getPath());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void testListStatusBatch() throws Exception {
|
|
|
+ // LocalFileSystem writes checksum files next to the data files, which
|
|
|
+ // show up when listing via LFS. This makes the listings not compare
|
|
|
+ // properly.
|
|
|
+ Assume.assumeFalse(isLocalFS());
|
|
|
+
|
|
|
+ FileSystem proxyFs = FileSystem.get(getProxiedFSConf());
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ conf.setInt(DFSConfigKeys.DFS_LIST_LIMIT, 2);
|
|
|
+ FileSystem httpFs = getHttpFSFileSystem(conf);
|
|
|
+
|
|
|
+ // Test an empty directory
|
|
|
+ Path dir = new Path(getProxiedFSTestDir(), "dir");
|
|
|
+ proxyFs.mkdirs(dir);
|
|
|
+ assertSameListing(proxyFs, httpFs, dir);
|
|
|
+ // Create and test in a loop
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ proxyFs.create(new Path(dir, "file" + i)).close();
|
|
|
+ assertSameListing(proxyFs, httpFs, dir);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void testWorkingdirectory() throws Exception {
|
|
|
FileSystem fs = FileSystem.get(getProxiedFSConf());
|
|
|
Path workingDir = fs.getWorkingDirectory();
|
|
@@ -863,7 +916,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
|
|
|
GET, OPEN, CREATE, APPEND, TRUNCATE, CONCAT, RENAME, DELETE, LIST_STATUS,
|
|
|
WORKING_DIRECTORY, MKDIRS, SET_TIMES, SET_PERMISSION, SET_OWNER,
|
|
|
SET_REPLICATION, CHECKSUM, CONTENT_SUMMARY, FILEACLS, DIRACLS, SET_XATTR,
|
|
|
- GET_XATTRS, REMOVE_XATTR, LIST_XATTRS, ENCRYPTION
|
|
|
+ GET_XATTRS, REMOVE_XATTR, LIST_XATTRS, ENCRYPTION, LIST_STATUS_BATCH
|
|
|
}
|
|
|
|
|
|
private void operation(Operation op) throws Exception {
|
|
@@ -940,6 +993,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
|
|
|
case ENCRYPTION:
|
|
|
testEncryption();
|
|
|
break;
|
|
|
+ case LIST_STATUS_BATCH:
|
|
|
+ testListStatusBatch();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|