jojochuang commented on code in PR #3581:
URL: https://github.com/apache/ozone/pull/3581#discussion_r924982243


##########
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/checksum/TestReplicatedBlockChecksumComputer.java:
##########
@@ -35,34 +41,60 @@
 public class TestReplicatedBlockChecksumComputer {
   @Test
   public void testComputeMd5Crc() throws IOException {
-    final int lenOfZeroBytes = 32;
-    byte[] emptyChunkChecksum = new byte[lenOfZeroBytes];
-    MD5Hash emptyBlockMD5 = MD5Hash.digest(emptyChunkChecksum);
+    final int lenOfBytes = 32;
+    byte[] randomChunkChecksum = new byte[lenOfBytes];
+    Random r = new Random();
+    r.nextBytes(randomChunkChecksum);
+    MD5Hash emptyBlockMD5 = MD5Hash.digest(randomChunkChecksum);
     byte[] emptyBlockMD5Hash = emptyBlockMD5.getDigest();
+    AbstractBlockChecksumComputer computer =
+        buildBlockChecksumComputer(randomChunkChecksum,
+            lenOfBytes, ContainerProtos.ChecksumType.CRC32);
+    computer.compute(MD5MD5CRC);
+    ByteBuffer output = computer.getOutByteBuffer();
+    assertArrayEquals(emptyBlockMD5Hash, output.array());
+  }
+
+  @Test
+  public void testComputeCompositeCrc() throws IOException {
+    final int lenOfBytes = 32;
+    byte[] randomChunkChecksum = new byte[lenOfBytes];
+    Random r = new Random();
+    r.nextBytes(randomChunkChecksum);
+
+    CrcComposer crcComposer =
+        CrcComposer.newCrcComposer(DataChecksum.Type.CRC32C, 4);
+    int chunkCrc = CrcUtil.readInt(randomChunkChecksum, 0);

Review Comment:
   CrcUtil is in Hadoop3 only so this feature will break with only hadoop2 
filesystem dependency. It does fail here because we don't have the test 
coverage.
   
   I have another PR that adds CrcUtil and other : 
https://github.com/apache/ozone/pull/3196/files



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to