This is an automated email from the ASF dual-hosted git repository.

umamahesh pushed a commit to branch HDDS-3816-ec
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/HDDS-3816-ec by this push:
     new 78ca097  HDDS-6083: EC: Fix flakyness of tests around nodefailures 
(#3021)
78ca097 is described below

commit 78ca097eac83ee34a735d3f780f0b9b4efedd63a
Author: Uma Maheswara Rao G <[email protected]>
AuthorDate: Tue Feb 1 16:44:41 2022 -0800

    HDDS-6083: EC: Fix flakyness of tests around nodefailures (#3021)
    
    Co-authored-by: Uma Maheswara Rao G <[email protected]>
---
 .../hadoop/ozone/client/TestOzoneECClient.java     | 28 +++++++++++-----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git 
a/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneECClient.java
 
b/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneECClient.java
index ee19210..2804199 100644
--- 
a/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneECClient.java
+++ 
b/hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/TestOzoneECClient.java
@@ -74,8 +74,9 @@ public class TestOzoneECClient {
   private final XceiverClientFactory factoryStub =
       new MockXceiverClientFactory();
   private OzoneConfiguration conf = new OzoneConfiguration();
-  private final MockOmTransport transportStub = new MockOmTransport(
-      new MultiNodePipelineBlockAllocator(conf, dataBlocks + parityBlocks, 
15));
+  private MultiNodePipelineBlockAllocator allocator =
+      new MultiNodePipelineBlockAllocator(conf, dataBlocks + parityBlocks, 15);
+  private final MockOmTransport transportStub = new MockOmTransport(allocator);
   private final RawErasureEncoder encoder =
       new RSRawErasureCoderFactory().createEncoder(
           new ECReplicationConfig(dataBlocks, parityBlocks));
@@ -426,24 +427,24 @@ public class TestOzoneECClient {
   @Test
   public void testWriteShouldFailIfMoreThanParityNodesFail()
       throws IOException {
-    testNodeFailuresWhileWriting(3, 3, 2);
+    testNodeFailuresWhileWriting(new int[] {0, 1, 2}, 3, 2);
   }
 
   @Test
   public void testWriteShouldSuccessIfLessThanParityNodesFail()
       throws IOException {
-    testNodeFailuresWhileWriting(1, 2, 2);
+    testNodeFailuresWhileWriting(new int[] {0}, 2, 2);
   }
 
   @Test
   public void testWriteShouldSuccessIf4NodesFailed() throws IOException {
-    testNodeFailuresWhileWriting(4, 1, 2);
+    testNodeFailuresWhileWriting(new int[] {0, 1, 2, 3}, 1, 2);
   }
 
   @Test
   public void testWriteShouldSuccessWithAdditional1BlockGroupAfterFailure()
       throws IOException {
-    testNodeFailuresWhileWriting(4, 10, 3);
+    testNodeFailuresWhileWriting(new int[] {0, 1, 2, 3}, 10, 3);
   }
 
   @Test
@@ -600,7 +601,7 @@ public class TestOzoneECClient {
     }
   }
 
-  public void testNodeFailuresWhileWriting(int numFailureToInject,
+  public void testNodeFailuresWhileWriting(int[] nodesIndexesToMarkFailure,
       int numChunksToWriteAfterFailure, int numExpectedBlockGrps)
       throws IOException {
     store.createVolume(volumeName);
@@ -609,19 +610,18 @@ public class TestOzoneECClient {
     OzoneBucket bucket = volume.getBucket(bucketName);
 
     try (OzoneOutputStream out = bucket.createKey(keyName, 1024 * 3,
-        new ECReplicationConfig(3, 2, ECReplicationConfig.EcCodec.RS,
+        new ECReplicationConfig(3, 2,
+            ECReplicationConfig.EcCodec.RS,
             chunkSize), new HashMap<>())) {
       for (int i = 0; i < dataBlocks; i++) {
         out.write(inputChunks[i]);
       }
 
       List<DatanodeDetails> failedDNs = new ArrayList<>();
-      Map<DatanodeDetails, MockDatanodeStorage> storages =
-          ((MockXceiverClientFactory) factoryStub).getStorages();
-      DatanodeDetails[] dnDetails =
-          storages.keySet().toArray(new DatanodeDetails[storages.size()]);
-      for (int i = 0; i < numFailureToInject; i++) {
-        failedDNs.add(dnDetails[i]);
+      List<HddsProtos.DatanodeDetailsProto> dns = allocator.getClusterDns();
+      for (int j = 0; j < nodesIndexesToMarkFailure.length; j++) {
+        failedDNs.add(DatanodeDetails
+            .getFromProtoBuf(dns.get(nodesIndexesToMarkFailure[j])));
       }
 
       // First let's set storage as bad

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

Reply via email to