|
51 | 51 | import org.apache.hadoop.conf.Configuration; |
52 | 52 | import org.apache.hadoop.fs.FileStatus; |
53 | 53 | import org.apache.hadoop.fs.FileSystem; |
| 54 | +import org.apache.hadoop.fs.LocatedFileStatus; |
54 | 55 | import org.apache.hadoop.fs.Path; |
| 56 | +import org.apache.hadoop.fs.RemoteIterator; |
55 | 57 | import org.apache.hadoop.fs.permission.FsPermission; |
56 | 58 | import org.apache.hadoop.hive.common.type.Timestamp; |
57 | 59 | import org.apache.hadoop.hive.conf.HiveConf; |
@@ -836,6 +838,38 @@ public void testSetPermissionsOnExistingDir() throws IOException { |
836 | 838 | Assert.assertEquals((short) 0777, fs.getFileStatus(path).getPermission().toShort()); |
837 | 839 | } |
838 | 840 |
|
| 841 | + @Test |
| 842 | + public void testWritingManifestFile() throws HiveException, IOException { |
| 843 | + String testTableName = "testWritingManifest"; |
| 844 | + JobConf jobConf = new JobConf(); |
| 845 | + FileSystem fs = FileSystem.getLocal(jobConf); |
| 846 | + Path testTablePath = new Path(HiveConf.getVar(jobConf, HiveConf.ConfVars.LOCAL_SCRATCH_DIR) + "/" + testTableName); |
| 847 | + try { |
| 848 | + fs.mkdirs(testTablePath); |
| 849 | + List<Path> commitPaths = new ArrayList<>(); |
| 850 | + commitPaths.add(new Path(testTableName + "/delta00001_00001/00000_0")); |
| 851 | + Utilities.writeCommitManifest(commitPaths, testTablePath, fs, |
| 852 | + "00001", 2L, 0, null, false, |
| 853 | + false, null, null, false); |
| 854 | + |
| 855 | + RemoteIterator<LocatedFileStatus> it = fs.listFiles(testTablePath, true); |
| 856 | + List<Path> resultPaths = new ArrayList<>(); |
| 857 | + while(it.hasNext()) { |
| 858 | + resultPaths.add(it.next().getPath()); |
| 859 | + } |
| 860 | + assertEquals(1, resultPaths.size()); |
| 861 | + Path resultPath = resultPaths.get(0); |
| 862 | + assertEquals("00001.manifest", resultPath.getName()); |
| 863 | + assertEquals("_tmp.delta_0000002_0000002_0000", resultPath.getParent().getName()); |
| 864 | + FileStatus[] files = fs.listStatus(testTablePath, AcidUtils.acidHiddenFileFilter); |
| 865 | + assertEquals(0, files.length); |
| 866 | + } finally { |
| 867 | + if (fs.exists(testTablePath)) { |
| 868 | + fs.delete(testTablePath, true); |
| 869 | + } |
| 870 | + } |
| 871 | + } |
| 872 | + |
839 | 873 | private FileStatus[] generateTestNotEmptyFileStatuses(String... fileNames) { |
840 | 874 | return generateTestNotEmptyFileStatuses(null, fileNames); |
841 | 875 | } |
|
0 commit comments