hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject hadoop git commit: HDFS-11834. Ozone: Fix TestArchive#testArchive. Contributed by Xiaoyu Yao.
Date Tue, 29 Aug 2017 21:18:31 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HDFS-7240 ea05b4245 -> b23c2677a


HDFS-11834. Ozone: Fix TestArchive#testArchive. Contributed by Xiaoyu Yao.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b23c2677
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b23c2677
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b23c2677

Branch: refs/heads/HDFS-7240
Commit: b23c2677a20ff07a79171e382d62ec52954e4c79
Parents: ea05b42
Author: Anu Engineer <aengineer@apache.org>
Authored: Tue Aug 29 14:14:14 2017 -0700
Committer: Anu Engineer <aengineer@apache.org>
Committed: Tue Aug 29 14:14:14 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/scm/TestArchive.java | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b23c2677/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/scm/TestArchive.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/scm/TestArchive.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/scm/TestArchive.java
index 6fff47e..3030575 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/scm/TestArchive.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/scm/TestArchive.java
@@ -18,7 +18,7 @@
 package org.apache.hadoop.scm;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.RandomUtils;
 import org.apache.hadoop.fs.FileUtil;
 import org.junit.Assert;
 import org.junit.Before;
@@ -43,6 +43,10 @@ public class TestArchive {
   private static final int DIR_COUNT = 10;
   private static final int SUB_DIR_COUNT = 3;
   private static final int FILE_COUNT = 10;
+  private long checksumWrite = 0L;
+  private long checksumRead = 0L;
+  private long tmp = 0L;
+
   @Rule
   public TemporaryFolder folder = new TemporaryFolder();
 
@@ -68,10 +72,12 @@ public class TestArchive {
         for (int z = 0; z < FILE_COUNT; z++) {
           Path temp = Paths.get(targetDir.getPath().concat(File.separator)
               .concat(String.format("File%d.txt", z)));
-          byte[] buf = RandomStringUtils.randomAlphanumeric(r.nextInt(megaByte))
-              .getBytes("UTF-8");
+          byte[] buf = RandomUtils.nextBytes(r.nextInt(megaByte));
           Files.write(temp, buf);
+          crc.reset();
           crc.update(buf, 0, buf.length);
+          tmp = crc.getValue();
+          checksumWrite +=tmp;
         }
       }
     }
@@ -79,7 +85,6 @@ public class TestArchive {
 
   @Test
   public void testArchive() throws Exception {
-    Checksum readCrc = new Adler32();
     File archiveFile = new File(outputFolder.getRoot() + File.separator
         + "test.container.zip");
     long zipCheckSum = FileUtil.zip(folder.getRoot(), archiveFile);
@@ -98,9 +103,12 @@ public class TestArchive {
     while (iter.hasNext()) {
       count++;
       byte[] buf = Files.readAllBytes(iter.next().toPath());
-      readCrc.update(buf, 0, buf.length);
+      crc.reset();
+      crc.update(buf, 0, buf.length);
+      tmp = crc.getValue();
+      checksumRead += tmp;
     }
     Assert.assertEquals(DIR_COUNT * SUB_DIR_COUNT * FILE_COUNT, count);
-    Assert.assertEquals(crc.getValue(), readCrc.getValue());
+    Assert.assertEquals(checksumWrite, checksumRead);
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message