|
@@ -88,6 +88,7 @@ import org.apache.hadoop.fs.permission.AclEntryScope;
|
|
|
import org.apache.hadoop.fs.permission.AclEntryType;
|
|
|
import org.apache.hadoop.fs.permission.FsAction;
|
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
|
+import org.apache.hadoop.fs.FsStatus;
|
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
|
import org.apache.hadoop.hdfs.DFSTestUtil;
|
|
|
import org.apache.hadoop.hdfs.DFSUtil;
|
|
@@ -2255,6 +2256,41 @@ public class TestWebHDFS {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testFsStatus() throws Exception {
|
|
|
+ final Configuration conf = WebHdfsTestUtil.createConf();
|
|
|
+ try {
|
|
|
+ cluster = new MiniDFSCluster.Builder(conf).build();
|
|
|
+ cluster.waitActive();
|
|
|
+
|
|
|
+ final WebHdfsFileSystem webHdfs =
|
|
|
+ WebHdfsTestUtil.getWebHdfsFileSystem(conf,
|
|
|
+ WebHdfsConstants.WEBHDFS_SCHEME);
|
|
|
+
|
|
|
+ final DistributedFileSystem dfs = cluster.getFileSystem();
|
|
|
+
|
|
|
+ final String path = "/foo";
|
|
|
+ try (OutputStream os = webHdfs.create(new Path(path))) {
|
|
|
+ os.write(new byte[1024]);
|
|
|
+ }
|
|
|
+
|
|
|
+ FsStatus webHdfsFsStatus = webHdfs.getStatus(new Path("/"));
|
|
|
+ Assert.assertNotNull(webHdfsFsStatus);
|
|
|
+
|
|
|
+ FsStatus dfsFsStatus = dfs.getStatus(new Path("/"));
|
|
|
+ Assert.assertNotNull(dfsFsStatus);
|
|
|
+
|
|
|
+ //Validate used free and capacity are the same as DistributedFileSystem
|
|
|
+ Assert.assertEquals(webHdfsFsStatus.getUsed(), dfsFsStatus.getUsed());
|
|
|
+ Assert.assertEquals(webHdfsFsStatus.getRemaining(),
|
|
|
+ dfsFsStatus.getRemaining());
|
|
|
+ Assert.assertEquals(webHdfsFsStatus.getCapacity(),
|
|
|
+ dfsFsStatus.getCapacity());
|
|
|
+ } finally {
|
|
|
+ cluster.shutdown();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Get FileStatus JSONObject from ListStatus response.
|
|
|
*/
|