/// <exception cref="System.Exception"/> public virtual void TestGetFileChecksum(Path foo, int appendLength) { int appendRounds = 16; FileChecksum[] fc = new FileChecksum[appendRounds + 1]; DFSTestUtil.CreateFile(dfs, foo, appendLength, Replication, 0L); fc[0] = dfs.GetFileChecksum(foo); for (int i = 0; i < appendRounds; i++) { DFSTestUtil.AppendFile(dfs, foo, appendLength); fc[i + 1] = dfs.GetFileChecksum(foo); } for (int i_1 = 0; i_1 < appendRounds + 1; i_1++) { FileChecksum checksum = dfs.GetFileChecksum(foo, appendLength * (i_1 + 1)); NUnit.Framework.Assert.IsTrue(checksum.Equals(fc[i_1])); } }
public virtual void TestGetFileChecksum() { // Create two different files in HDFS fileSystemTestHelper.CreateFile(fHdfs, someFile); FileSystemTestHelper.CreateFile(fHdfs, fileSystemTestHelper.GetTestRootPath(fHdfs , someFile + "other"), 1, 512); // Get checksum through ViewFS FileChecksum viewFSCheckSum = vfs.GetFileChecksum(new Path("/vfstmp/someFileForTestGetFileChecksum" )); // Get checksum through HDFS. FileChecksum hdfsCheckSum = fHdfs.GetFileChecksum(new Path(someFile)); // Get checksum of different file in HDFS FileChecksum otherHdfsFileCheckSum = fHdfs.GetFileChecksum(new Path(someFile + "other" )); // Checksums of the same file (got through HDFS and ViewFS should be same) NUnit.Framework.Assert.AreEqual("HDFS and ViewFS checksums were not the same", viewFSCheckSum , hdfsCheckSum); // Checksum of different files should be different. NUnit.Framework.Assert.IsFalse("Some other HDFS file which should not have had the same " + "checksum as viewFS did!", viewFSCheckSum.Equals(otherHdfsFileCheckSum)); }