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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5c2ac71  HDDS-5788. Reduce run time for TestOzoneManagerHA tests 
(#2689)
5c2ac71 is described below

commit 5c2ac714d4357309bd08996093d834a96b6c47c8
Author: Jyotinder Singh <[email protected]>
AuthorDate: Fri Oct 1 13:48:30 2021 +0530

    HDDS-5788. Reduce run time for TestOzoneManagerHA tests (#2689)
---
 .../apache/hadoop/ozone/om/TestOzoneManagerHA.java | 113 ++++++++++++++++-----
 .../ozone/om/TestOzoneManagerHAMetadataOnly.java   |  22 +---
 .../ozone/om/TestOzoneManagerHAWithData.java       |  98 +-----------------
 .../ozone/om/TestOzoneManagerHAWithFailover.java   |  65 ++++++++++++
 .../hadoop/ozone/om/TestOzoneManagerPrepare.java   |  28 +++--
 5 files changed, 176 insertions(+), 150 deletions(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
index 2383f0a..6118a5e 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
@@ -37,8 +37,9 @@ import org.apache.hadoop.ozone.client.rpc.RpcClient;
 import org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider;
 import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServerConfig;
 import org.apache.ozone.test.GenericTestUtils;
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.After;
+import org.junit.AfterClass;
 import org.junit.Rule;
 import org.junit.Assert;
 
@@ -68,14 +69,14 @@ import static org.junit.Assert.fail;
  */
 public abstract class TestOzoneManagerHA {
 
-  private MiniOzoneOMHAClusterImpl cluster = null;
-  private MiniOzoneCluster.Builder clusterBuilder = null;
-  private ObjectStore objectStore;
-  private OzoneConfiguration conf;
-  private String clusterId;
-  private String scmId;
-  private String omId;
-  private String omServiceId;
+  private static MiniOzoneOMHAClusterImpl cluster = null;
+  private static MiniOzoneCluster.Builder clusterBuilder = null;
+  private static ObjectStore objectStore;
+  private static OzoneConfiguration conf;
+  private static String clusterId;
+  private static String scmId;
+  private static String omId;
+  private static String omServiceId;
   private static int numOfOMs = 3;
   private static final int LOG_PURGE_GAP = 50;
   /* Reduce max number of retries to speed up unit test. */
@@ -88,7 +89,7 @@ public abstract class TestOzoneManagerHA {
   public ExpectedException exception = ExpectedException.none();
 
   @Rule
-  public Timeout timeout = Timeout.seconds(300);;
+  public Timeout timeout = Timeout.seconds(300);
 
   public MiniOzoneOMHAClusterImpl getCluster() {
     return cluster;
@@ -137,8 +138,8 @@ public abstract class TestOzoneManagerHA {
    *
    * @throws IOException
    */
-  @Before
-  public void init() throws Exception {
+  @BeforeClass
+  public static void init() throws Exception {
     conf = new OzoneConfiguration();
     clusterId = UUID.randomUUID().toString();
     scmId = UUID.randomUUID().toString();
@@ -171,7 +172,6 @@ public abstract class TestOzoneManagerHA {
      */
     conf.set(OZONE_BLOCK_DELETING_SERVICE_INTERVAL, "10s");
     conf.set(OZONE_KEY_DELETING_LIMIT_PER_TASK, "2");
-    additionalConfiguration();
 
     clusterBuilder = MiniOzoneCluster.newOMHABuilder(conf)
         .setClusterId(clusterId)
@@ -179,33 +179,30 @@ public abstract class TestOzoneManagerHA {
         .setOMServiceId(omServiceId)
         .setOmId(omId)
         .setNumOfOzoneManagers(numOfOMs);
-    additionalClusterSettings();
 
-    cluster = (MiniOzoneOMHAClusterImpl)clusterBuilder.build();
+    cluster = (MiniOzoneOMHAClusterImpl) clusterBuilder.build();
     cluster.waitForClusterToBeReady();
     objectStore = OzoneClientFactory.getRpcClient(omServiceId, conf)
         .getObjectStore();
   }
 
-  /**
-   * Override this method in sub-classes to additional test specific
-   * configuration. Add settings to the conf instance variable.
-   */
-  protected void additionalConfiguration() {
-  }
 
   /**
-   * Override this method in sub-classes to additional test specific
-   * mini-cluster settings. Add settings the clusterBuilder instance variable.
+   * Reset cluster between tests.
    */
-  protected void additionalClusterSettings() {
+  @After
+  public void resetCluster()
+      throws IOException {
+    if (cluster != null) {
+      cluster.restartOzoneManager();
+    }
   }
 
   /**
-   * Shutdown MiniDFSCluster.
+   * Shutdown MiniDFSCluster after all tests of a class have run.
    */
-  @After
-  public void shutdown() {
+  @AfterClass
+  public static void shutdown() {
     if (cluster != null) {
       cluster.shutdown();
     }
@@ -213,6 +210,7 @@ public abstract class TestOzoneManagerHA {
 
   /**
    * Create a key in the bucket.
+   *
    * @return the key name.
    */
   public static String createKey(OzoneBucket ozoneBucket) throws IOException {
@@ -256,6 +254,7 @@ public abstract class TestOzoneManagerHA {
 
   /**
    * Stop the current leader OM.
+   *
    * @throws Exception
    */
   protected void stopLeaderOM() {
@@ -316,6 +315,7 @@ public abstract class TestOzoneManagerHA {
   /**
    * This method createFile and verifies the file is successfully created or
    * not.
+   *
    * @param ozoneBucket
    * @param keyName
    * @param data
@@ -324,7 +324,8 @@ public abstract class TestOzoneManagerHA {
    * @throws Exception
    */
   protected void testCreateFile(OzoneBucket ozoneBucket, String keyName,
-      String data, boolean recursive, boolean overwrite)
+                                String data, boolean recursive,
+                                boolean overwrite)
       throws Exception {
 
     OzoneOutputStream ozoneOutputStream = ozoneBucket.createFile(keyName,
@@ -349,4 +350,60 @@ public abstract class TestOzoneManagerHA {
     Assert.assertEquals(data, new String(fileContent, UTF_8));
   }
 
+  protected void createKeyTest(boolean checkSuccess) throws Exception {
+    String userName = "user" + RandomStringUtils.randomNumeric(5);
+    String adminName = "admin" + RandomStringUtils.randomNumeric(5);
+    String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
+
+    VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
+        .setOwner(userName)
+        .setAdmin(adminName)
+        .build();
+
+    try {
+      getObjectStore().createVolume(volumeName, createVolumeArgs);
+
+      OzoneVolume retVolumeinfo = getObjectStore().getVolume(volumeName);
+
+      Assert.assertTrue(retVolumeinfo.getName().equals(volumeName));
+      Assert.assertTrue(retVolumeinfo.getOwner().equals(userName));
+      Assert.assertTrue(retVolumeinfo.getAdmin().equals(adminName));
+
+      String bucketName = UUID.randomUUID().toString();
+      String keyName = UUID.randomUUID().toString();
+      retVolumeinfo.createBucket(bucketName);
+
+      OzoneBucket ozoneBucket = retVolumeinfo.getBucket(bucketName);
+
+      Assert.assertTrue(ozoneBucket.getName().equals(bucketName));
+      Assert.assertTrue(ozoneBucket.getVolumeName().equals(volumeName));
+
+      String value = "random data";
+      OzoneOutputStream ozoneOutputStream = ozoneBucket.createKey(keyName,
+          value.length(), ReplicationType.STAND_ALONE,
+          ReplicationFactor.ONE, new HashMap<>());
+      ozoneOutputStream.write(value.getBytes(UTF_8), 0, value.length());
+      ozoneOutputStream.close();
+
+      OzoneInputStream ozoneInputStream = ozoneBucket.readKey(keyName);
+
+      byte[] fileContent = new byte[value.getBytes(UTF_8).length];
+      ozoneInputStream.read(fileContent);
+      Assert.assertEquals(value, new String(fileContent, UTF_8));
+
+    } catch (ConnectException | RemoteException e) {
+      if (!checkSuccess) {
+        // If the last OM to be tried by the RetryProxy is down, we would get
+        // ConnectException. Otherwise, we would get a RemoteException from the
+        // last running OM as it would fail to get a quorum.
+        if (e instanceof RemoteException) {
+          GenericTestUtils.assertExceptionContains(
+              "OMNotLeaderException", e);
+        }
+      } else {
+        throw e;
+      }
+    }
+  }
+
 }
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
index 462d2af..8c085fb 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAMetadataOnly.java
@@ -1,4 +1,4 @@
-  /**
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with this
  * work for additional information regarding copyright ownership.  The ASF
@@ -17,11 +17,8 @@
 package org.apache.hadoop.ozone.om;
 
 import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.hadoop.hdds.HddsConfigKeys;
-import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.protocol.StorageType;
 import org.apache.hadoop.hdfs.LogVerificationAppender;
-import org.apache.hadoop.ozone.MiniOzoneCluster;
 import org.apache.hadoop.ozone.OzoneTestUtils;
 import org.apache.hadoop.ozone.client.ObjectStore;
 import org.apache.hadoop.ozone.client.OzoneBucket;
@@ -76,20 +73,6 @@ import static org.junit.Assert.fail;
  */
 public class TestOzoneManagerHAMetadataOnly extends TestOzoneManagerHA {
 
-  @Override
-  protected void additionalConfiguration() {
-    OzoneConfiguration conf = getConf();
-    // These test do not use any features of SCM, so we can skip safemode
-    // which gets the cluster to come up much faster.
-    conf.setBoolean(HddsConfigKeys.HDDS_SCM_SAFEMODE_ENABLED, false);
-  }
-
-  @Override
-  protected void additionalClusterSettings() {
-    MiniOzoneCluster.Builder builder = getClusterBuilder();
-    builder.setNumDatanodes(0);
-  }
-
   private OzoneVolume createAndCheckVolume(String volumeName)
       throws Exception {
     String userName = "user" + RandomStringUtils.randomNumeric(5);
@@ -110,6 +93,7 @@ public class TestOzoneManagerHAMetadataOnly extends 
TestOzoneManagerHA {
 
     return retVolume;
   }
+
   @Test
   public void testAllVolumeOperations() throws Exception {
 
@@ -342,7 +326,7 @@ public class TestOzoneManagerHAMetadataOnly extends 
TestOzoneManagerHA {
     ObjectStore objectStore = getObjectStore();
 
     Set<String> expectedVolumes = new TreeSet<>();
-    for (int i=0; i < 100; i++) {
+    for (int i = 0; i < 100; i++) {
       String volumeName = "vol" + i;
       expectedVolumes.add(volumeName);
       VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithData.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithData.java
index ba412f5..a0c014a 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithData.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithData.java
@@ -19,8 +19,6 @@ package org.apache.hadoop.ozone.om;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.hadoop.hdds.client.ReplicationFactor;
 import org.apache.hadoop.hdds.client.ReplicationType;
-import org.apache.hadoop.ipc.RemoteException;
-import org.apache.hadoop.ozone.OzoneConfigKeys;
 import org.apache.hadoop.ozone.client.ObjectStore;
 import org.apache.hadoop.ozone.client.OzoneBucket;
 import org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts;
@@ -38,7 +36,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 import java.io.IOException;
-import java.net.ConnectException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -280,40 +277,6 @@ public class TestOzoneManagerHAWithData extends 
TestOzoneManagerHA {
     Assert.assertTrue(!leaderOMNodeId.equals(newLeaderOMNodeId));
   }
 
-  /**
-   * 1. Stop one of the OM
-   * 2. make a call to OM, this will make failover attempts to find new node.
-   * a) if LE finishes but leader not ready, it retries to same node
-   * b) if LE not done, it will failover to new node and check
-   * 3. Try failover to same OM explicitly.
-   * Now #3 should wait additional waitBetweenRetries time.
-   * LE: Leader Election.
-   */
-  @Test
-  public void testIncrementalWaitTimeWithSameNodeFailover() throws Exception {
-    long waitBetweenRetries = getConf().getLong(
-        OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_KEY,
-        OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_DEFAULT);
-    OMFailoverProxyProvider omFailoverProxyProvider =
-        OmFailoverProxyUtil
-            .getFailoverProxyProvider(getObjectStore().getClientProxy());
-
-    // The OMFailoverProxyProvider will point to the current leader OM node.
-    String leaderOMNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
-
-    getCluster().stopOzoneManager(leaderOMNodeId);
-    Thread.sleep(NODE_FAILURE_TIMEOUT * 4);
-    createKeyTest(true); // failover should happen to new node
-
-    long numTimesTriedToSameNode = omFailoverProxyProvider.getWaitTime()
-        / waitBetweenRetries;
-    omFailoverProxyProvider.performFailoverIfRequired(omFailoverProxyProvider.
-        getCurrentProxyOMNodeId());
-    Assert.assertEquals((numTimesTriedToSameNode + 1) * waitBetweenRetries,
-        omFailoverProxyProvider.getWaitTime());
-  }
-
-
   private String initiateMultipartUpload(OzoneBucket ozoneBucket,
       String keyName) throws Exception {
 
@@ -353,63 +316,6 @@ public class TestOzoneManagerHAWithData extends 
TestOzoneManagerHA {
     Assert.assertEquals(value, new String(fileContent, UTF_8));
   }
 
-
-  private void createKeyTest(boolean checkSuccess) throws Exception {
-    String userName = "user" + RandomStringUtils.randomNumeric(5);
-    String adminName = "admin" + RandomStringUtils.randomNumeric(5);
-    String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
-
-    VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
-        .setOwner(userName)
-        .setAdmin(adminName)
-        .build();
-
-    try {
-      getObjectStore().createVolume(volumeName, createVolumeArgs);
-
-      OzoneVolume retVolumeinfo = getObjectStore().getVolume(volumeName);
-
-      Assert.assertTrue(retVolumeinfo.getName().equals(volumeName));
-      Assert.assertTrue(retVolumeinfo.getOwner().equals(userName));
-      Assert.assertTrue(retVolumeinfo.getAdmin().equals(adminName));
-
-      String bucketName = UUID.randomUUID().toString();
-      String keyName = UUID.randomUUID().toString();
-      retVolumeinfo.createBucket(bucketName);
-
-      OzoneBucket ozoneBucket = retVolumeinfo.getBucket(bucketName);
-
-      Assert.assertTrue(ozoneBucket.getName().equals(bucketName));
-      Assert.assertTrue(ozoneBucket.getVolumeName().equals(volumeName));
-
-      String value = "random data";
-      OzoneOutputStream ozoneOutputStream = ozoneBucket.createKey(keyName,
-          value.length(), ReplicationType.STAND_ALONE,
-          ReplicationFactor.ONE, new HashMap<>());
-      ozoneOutputStream.write(value.getBytes(UTF_8), 0, value.length());
-      ozoneOutputStream.close();
-
-      OzoneInputStream ozoneInputStream = ozoneBucket.readKey(keyName);
-
-      byte[] fileContent = new byte[value.getBytes(UTF_8).length];
-      ozoneInputStream.read(fileContent);
-      Assert.assertEquals(value, new String(fileContent, UTF_8));
-
-    } catch (ConnectException | RemoteException e) {
-      if (!checkSuccess) {
-        // If the last OM to be tried by the RetryProxy is down, we would get
-        // ConnectException. Otherwise, we would get a RemoteException from the
-        // last running OM as it would fail to get a quorum.
-        if (e instanceof RemoteException) {
-          GenericTestUtils.assertExceptionContains(
-              "OMNotLeaderException", e);
-        }
-      } else {
-        throw e;
-      }
-    }
-  }
-
   @Test
   public void testOMRatisSnapshot() throws Exception {
     String userName = "user" + RandomStringUtils.randomNumeric(5);
@@ -493,6 +399,10 @@ public class TestOzoneManagerHAWithData extends 
TestOzoneManagerHA {
 
   @Test
   public void testOMRestart() throws Exception {
+    // start fresh cluster
+    shutdown();
+    init();
+
     ObjectStore objectStore = getObjectStore();
     // Get the leader OM
     String leaderOMNodeId = OmFailoverProxyUtil
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithFailover.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithFailover.java
new file mode 100644
index 0000000..ecbb6e8
--- /dev/null
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHAWithFailover.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.hadoop.ozone.om;
+
+import org.apache.hadoop.ozone.OzoneConfigKeys;
+import org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static 
org.apache.hadoop.ozone.MiniOzoneOMHAClusterImpl.NODE_FAILURE_TIMEOUT;
+
+/**
+ * Test Ozone Manager operation in distributed handler scenario with failover.
+ * NOTE: Do not add new tests to this class since
+ * testIncrementalWaitTimeWithSameNodeFailove does not leave the cluster in a
+ * reusable state.
+ */
+public class TestOzoneManagerHAWithFailover extends TestOzoneManagerHA {
+  /**
+   * 1. Stop one of the OM
+   * 2. make a call to OM, this will make failover attempts to find new node.
+   * a) if LE finishes but leader not ready, it retries to same node
+   * b) if LE not done, it will failover to new node and check
+   * 3. Try failover to same OM explicitly.
+   * Now #3 should wait additional waitBetweenRetries time.
+   * LE: Leader Election.
+   */
+  @Test
+  public void testIncrementalWaitTimeWithSameNodeFailover() throws Exception {
+    long waitBetweenRetries = getConf().getLong(
+        OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_KEY,
+        OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_DEFAULT);
+    OMFailoverProxyProvider omFailoverProxyProvider =
+        OmFailoverProxyUtil
+            .getFailoverProxyProvider(getObjectStore().getClientProxy());
+
+    // The OMFailoverProxyProvider will point to the current leader OM node.
+    String leaderOMNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
+
+    getCluster().stopOzoneManager(leaderOMNodeId);
+    Thread.sleep(NODE_FAILURE_TIMEOUT * 4);
+    createKeyTest(true); // failover should happen to new node
+
+    long numTimesTriedToSameNode = omFailoverProxyProvider.getWaitTime()
+        / waitBetweenRetries;
+    omFailoverProxyProvider.performFailoverIfRequired(omFailoverProxyProvider.
+        getCurrentProxyOMNodeId());
+    Assert.assertEquals((numTimesTriedToSameNode + 1) * waitBetweenRetries,
+        omFailoverProxyProvider.getWaitTime());
+  }
+}
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerPrepare.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerPrepare.java
index 5e5cd07..fe4429e 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerPrepare.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerPrepare.java
@@ -49,6 +49,7 @@ import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Prepare
 import org.apache.ozone.test.LambdaTestUtils;
 import org.junit.Assert;
 import org.junit.Ignore;
+import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -80,13 +81,22 @@ public class TestOzoneManagerPrepare extends 
TestOzoneManagerHA {
   }
 
   /**
+   * Make sure OM is out of Prepare state before executing individual tests.
+   * @throws Exception
+   */
+  @Before
+  public void initOM() throws Exception {
+    setup();
+    submitCancelPrepareRequest();
+    assertClusterNotPrepared();
+  }
+
+  /**
    * Writes data to the cluster via the leader OM, and then prepares it.
    * Checks that every OM is prepared successfully.
    */
   @Test
   public void testPrepareWithTransactions() throws Exception {
-    setup();
-
     long prepareIndex = submitPrepareRequest();
     assertClusterPrepared(prepareIndex);
     assertRatisLogsCleared();
@@ -120,7 +130,6 @@ public class TestOzoneManagerPrepare extends 
TestOzoneManagerHA {
    */
   @Test
   public void testPrepareDownedOM() throws Exception {
-    setup();
     // Index of the OM that will be shut down during this test.
     final int shutdownOMIndex = 2;
     List<OzoneManager> runningOms = cluster.getOzoneManagersList();
@@ -175,7 +184,12 @@ public class TestOzoneManagerPrepare extends 
TestOzoneManagerHA {
 
   @Test
   public void testPrepareWithRestart() throws Exception {
+    // Create fresh cluster for this test to prevent timeout from restarting
+    // modified cluster.
+    shutdown();
+    init();
     setup();
+
     String volumeName = VOLUME + UUID.randomUUID().toString();
     writeKeysAndWaitForLogs(volumeName, 10);
 
@@ -194,9 +208,6 @@ public class TestOzoneManagerPrepare extends 
TestOzoneManagerHA {
       "be able to do anything with 2 OMs down.")
   @Test
   public void testPrepareFailsWhenTwoOmsAreDown() throws Exception {
-
-    setup();
-
     // Shut down 2 OMs.
     for (int i : Arrays.asList(1, 2)) {
       cluster.stopOzoneManager(i);
@@ -216,11 +227,11 @@ public class TestOzoneManagerPrepare extends 
TestOzoneManagerHA {
    * the requests will execute, so this test checks that the cluster ends in
    * a prepared state, and that create volume requests either succeed, or fail
    * indicating the cluster was prepared before they were encountered.
+   *
    * @throws Exception
    */
   @Test
   public void testPrepareWithMultipleThreads() throws Exception {
-    setup();
     final int numThreads = 10;
     final int prepareTaskIndex = 5;
 
@@ -276,7 +287,6 @@ public class TestOzoneManagerPrepare extends 
TestOzoneManagerHA {
 
   @Test
   public void testCancelPrepare() throws Exception {
-    setup();
     String volumeName = VOLUME + UUID.randomUUID().toString();
     Set<String> writtenKeys = writeKeysAndWaitForLogs(volumeName, 10);
     long prepareIndex = submitPrepareRequest();
@@ -348,7 +358,7 @@ public class TestOzoneManagerPrepare extends 
TestOzoneManagerHA {
 
     // Make sure all OMs have logs from writing data, so we can check that
     // they are purged after prepare.
-    for (OzoneManager om: ozoneManagers) {
+    for (OzoneManager om : ozoneManagers) {
       LambdaTestUtils.await(WAIT_TIMEOUT_MILLIS, 1000,
           () -> logFilesPresentInRatisPeer(om));
     }

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

Reply via email to