File checkFile = ((RawLocalFileSystem)fs).pathToFile(getChecksumFile(p));
File checkFile = ((RawLocalFileSystem)fs).pathToFile(getChecksumFile(p)); checkFile.renameTo(new File(badDir, checkFile.getName()+suffix));
File checkFile = ((RawLocalFileSystem)fs).pathToFile(getChecksumFile(p)); checkFile.renameTo(new File(badDir, checkFile.getName()+suffix));
File checkFile = ((RawLocalFileSystem)fs).pathToFile(getChecksumFile(p));
Path checksumFile = localFs.getChecksumFile(testPath); FileSystem rawFs = localFs.getRawFileSystem(); FSDataInputStream checksumStream = rawFs.open(checksumFile);
TestLocalFileSystem.readFile(localFs, testPath, 1025); localFs.delete(localFs.getChecksumFile(testPath), true); assertTrue("checksum deleted", !localFs.exists(localFs.getChecksumFile(testPath))); FileUtil.copy(localFs, localFs.getChecksumFile(testPath11), localFs, localFs.getChecksumFile(testPath),false,true,conf); assertTrue("checksum exists", localFs.exists(localFs.getChecksumFile(testPath)));
@Test public void testSetPermissionCrc() throws Exception { FileSystem rawFs = localFs.getRawFileSystem(); Path p = new Path(TEST_ROOT_DIR, "testCrcPermissions"); localFs.createNewFile(p); Path crc = localFs.getChecksumFile(p); assert(rawFs.exists(crc)); for (short mode : Arrays.asList((short)0666, (short)0660, (short)0600)) { FsPermission perm = new FsPermission(mode); localFs.setPermission(p, perm); assertEquals(perm, localFs.getFileStatus(p).getPermission()); assertEquals(perm, rawFs.getFileStatus(crc).getPermission()); } } }
Path checksumFile = localFs.getChecksumFile(testPath); FileSystem rawFs = localFs.getRawFileSystem(); FSDataInputStream checksumStream = rawFs.open(checksumFile);
@Test public void testSetPermissionCrc() throws Exception { FileSystem rawFs = localFs.getRawFileSystem(); Path p = new Path(TEST_ROOT_DIR, "testCrcPermissions"); localFs.createNewFile(p); Path crc = localFs.getChecksumFile(p); assert(rawFs.exists(crc)); for (short mode : Arrays.asList((short)0666, (short)0660, (short)0600)) { FsPermission perm = new FsPermission(mode); localFs.setPermission(p, perm); assertEquals(perm, localFs.getFileStatus(p).getPermission()); assertEquals(perm, rawFs.getFileStatus(crc).getPermission()); } } }
private void checkPath(Path p, boolean expectChecksum) throws IOException { assertTrue(lfs.exists(p)); boolean hasChecksum = lfs.exists(lfs.getChecksumFile(p)); assertEquals(expectChecksum, hasChecksum); }
Path checksumFile = localFs.getChecksumFile(testPath); FileSystem rawFs = localFs.getRawFileSystem(); FSDataInputStream checksumStream = rawFs.open(checksumFile);
private void checkPath(Path p, boolean expectChecksum) throws IOException { assertTrue(lfs.exists(p)); boolean hasChecksum = lfs.exists(lfs.getChecksumFile(p)); assertEquals(expectChecksum, hasChecksum); }
readFile(localFs, testPath, 1025); localFs.delete(localFs.getChecksumFile(testPath), true); assertTrue("checksum deleted", !localFs.exists(localFs.getChecksumFile(testPath))); FileUtil.copy(localFs, localFs.getChecksumFile(testPath11), localFs, localFs.getChecksumFile(testPath),false,true,localFs.getConf()); assertTrue("checksum exists", localFs.exists(localFs.getChecksumFile(testPath)));
readFile(localFs, testPath, 1025); localFs.delete(localFs.getChecksumFile(testPath), true); assertTrue("checksum deleted", !localFs.exists(localFs.getChecksumFile(testPath))); FileUtil.copy(localFs, localFs.getChecksumFile(testPath11), localFs, localFs.getChecksumFile(testPath),false,true,localFs.getConf()); assertTrue("checksum exists", localFs.exists(localFs.getChecksumFile(testPath)));
void verifyRename(Path srcPath, Path dstPath, boolean dstIsDir) throws Exception { localFs.delete(srcPath,true); localFs.delete(dstPath,true); Path realDstPath = dstPath; if (dstIsDir) { localFs.mkdirs(dstPath); realDstPath = new Path(dstPath, srcPath.getName()); } // ensure file + checksum are moved writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); // create a file with no checksum, rename, ensure dst checksum is removed writeFile(localFs.getRawFileSystem(), srcPath, 1); assertFalse(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertFalse(localFs.exists(localFs.getChecksumFile(realDstPath))); // create file with checksum, rename over prior dst with no checksum writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); }
void verifyRename(Path srcPath, Path dstPath, boolean dstIsDir) throws Exception { localFs.delete(srcPath,true); localFs.delete(dstPath,true); Path realDstPath = dstPath; if (dstIsDir) { localFs.mkdirs(dstPath); realDstPath = new Path(dstPath, srcPath.getName()); } // ensure file + checksum are moved writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); // create a file with no checksum, rename, ensure dst checksum is removed writeFile(localFs.getRawFileSystem(), srcPath, 1); assertFalse(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertFalse(localFs.exists(localFs.getChecksumFile(realDstPath))); // create file with checksum, rename over prior dst with no checksum writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); }
@Test public void testCorruptedChecksum() throws Exception { Path testPath = new Path(TEST_ROOT_DIR, "testCorruptChecksum"); Path checksumPath = localFs.getChecksumFile(testPath);
@Before public void prepFiles() throws Exception { lfs.setVerifyChecksum(true); lfs.setWriteChecksum(true); lfs.delete(srcPath, true); lfs.delete(dstPath, true); FSDataOutputStream out = lfs.create(srcPath); out.writeChars("hi"); out.close(); assertTrue(lfs.exists(lfs.getChecksumFile(srcPath))); }
@Test public void testCorruptedChecksum() throws Exception { Path testPath = new Path(TEST_ROOT_DIR, "testCorruptChecksum"); Path checksumPath = localFs.getChecksumFile(testPath);
@Before public void prepFiles() throws Exception { lfs.setVerifyChecksum(true); lfs.setWriteChecksum(true); lfs.delete(srcPath, true); lfs.delete(dstPath, true); FSDataOutputStream out = lfs.create(srcPath); out.writeChars("hi"); out.close(); assertTrue(lfs.exists(lfs.getChecksumFile(srcPath))); }