You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by el...@apache.org on 2020/02/18 10:14:49 UTC

[hadoop-ozone] branch master updated: HDDS-2992. Handle existing volume/bucket in contract tests

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

elek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 13167a7  HDDS-2992. Handle existing volume/bucket in contract tests
13167a7 is described below

commit 13167a72e34e34709862bed85e40321fb34d9da1
Author: Doroszlai, Attila <ad...@apache.org>
AuthorDate: Tue Feb 18 10:47:44 2020 +0100

    HDDS-2992. Handle existing volume/bucket in contract tests
    
    Closes #539
---
 .../java/org/apache/hadoop/ozone/TestDataUtil.java    | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java
index e27aa85..115336e 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDataUtil.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.ozone.client.OzoneVolume;
 import org.apache.hadoop.ozone.client.VolumeArgs;
 
 import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.ozone.om.exceptions.OMException;
 
 /**
  * Utility to help to generate test data.
@@ -88,8 +89,20 @@ public final class TestDataUtil {
 
   public static OzoneBucket createVolumeAndBucket(MiniOzoneCluster cluster)
       throws IOException {
-    String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
-    String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
-    return createVolumeAndBucket(cluster, volumeName, bucketName);
+    final int attempts = 5;
+    for (int i = 0; i < attempts; i++) {
+      try {
+        String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
+        String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
+        return createVolumeAndBucket(cluster, volumeName, bucketName);
+      } catch (OMException e) {
+        if (e.getResult() != OMException.ResultCodes.VOLUME_ALREADY_EXISTS &&
+            e.getResult() != OMException.ResultCodes.BUCKET_ALREADY_EXISTS) {
+          throw e;
+        }
+      }
+    }
+    throw new IllegalStateException("Could not create unique volume/bucket " +
+        "in " + attempts + " attempts");
   }
 }


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