|
@@ -921,13 +921,6 @@ public class TestDistributedFileSystem {
|
|
out.close();
|
|
out.close();
|
|
}
|
|
}
|
|
|
|
|
|
- // verify the magic val for zero byte files
|
|
|
|
- {
|
|
|
|
- final FileChecksum zeroChecksum = hdfs.getFileChecksum(zeroByteFile);
|
|
|
|
- assertEquals(zeroChecksum.toString(),
|
|
|
|
- "MD5-of-0MD5-of-0CRC32:70bc8f4b72a86921468bf8e8441dce51");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//write another file
|
|
//write another file
|
|
final Path bar = new Path(dir, "bar" + n);
|
|
final Path bar = new Path(dir, "bar" + n);
|
|
{
|
|
{
|
|
@@ -936,8 +929,37 @@ public class TestDistributedFileSystem {
|
|
out.write(data);
|
|
out.write(data);
|
|
out.close();
|
|
out.close();
|
|
}
|
|
}
|
|
-
|
|
|
|
- { //verify checksum
|
|
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ // verify the magic val for zero byte file
|
|
|
|
+ final FileChecksum zeroChecksum = hdfs.getFileChecksum(zeroByteFile);
|
|
|
|
+ final String magicValue =
|
|
|
|
+ "MD5-of-0MD5-of-0CRC32:70bc8f4b72a86921468bf8e8441dce51";
|
|
|
|
+ // verify the magic val for zero byte files
|
|
|
|
+ assertEquals(magicValue, zeroChecksum.toString());
|
|
|
|
+
|
|
|
|
+ // verify checksum for empty file and 0 request length
|
|
|
|
+ final FileChecksum checksumWith0 = hdfs.getFileChecksum(bar, 0);
|
|
|
|
+ assertEquals(zeroChecksum, checksumWith0);
|
|
|
|
+
|
|
|
|
+ // verify none existent file
|
|
|
|
+ try {
|
|
|
|
+ hdfs.getFileChecksum(new Path(dir, "none-existent"), 8);
|
|
|
|
+ fail();
|
|
|
|
+ } catch (Exception ioe) {
|
|
|
|
+ FileSystem.LOG.info("GOOD: getting an exception", ioe);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // verify none existent file and 0 request length
|
|
|
|
+ try {
|
|
|
|
+ final FileChecksum noneExistentChecksumWith0 =
|
|
|
|
+ hdfs.getFileChecksum(new Path(dir, "none-existent"), 0);
|
|
|
|
+ fail();
|
|
|
|
+ } catch (Exception ioe) {
|
|
|
|
+ FileSystem.LOG.info("GOOD: getting an exception", ioe);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // verify checksums
|
|
final FileChecksum barcs = hdfs.getFileChecksum(bar);
|
|
final FileChecksum barcs = hdfs.getFileChecksum(bar);
|
|
final int barhashcode = barcs.hashCode();
|
|
final int barhashcode = barcs.hashCode();
|
|
assertEquals(hdfsfoocs.hashCode(), barhashcode);
|
|
assertEquals(hdfsfoocs.hashCode(), barhashcode);
|