You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ad...@apache.org on 2022/03/19 09:17:31 UTC

[ozone] branch master updated: HDDS-6470. Fix TestOzoneManagerHAWithData#testOMRestart() (#3213)

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

adoroszlai 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 be2021a  HDDS-6470. Fix TestOzoneManagerHAWithData#testOMRestart() (#3213)
be2021a is described below

commit be2021a369a3d8b351e45edd6b5df97d6264f4cf
Author: Kaijie Chen <ch...@kaijie.org>
AuthorDate: Sat Mar 19 17:17:10 2022 +0800

    HDDS-6470. Fix TestOzoneManagerHAWithData#testOMRestart() (#3213)
---
 .../ozone/om/TestOzoneManagerHAWithData.java       | 54 ++++++++--------------
 1 file changed, 20 insertions(+), 34 deletions(-)

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 2181fc3..a9e6a1f 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
@@ -431,16 +431,16 @@ public class TestOzoneManagerHAWithData extends TestOzoneManagerHA {
         .build();
 
     objectStore.createVolume(volumeName, createVolumeArgs);
-    OzoneVolume retVolumeinfo = objectStore.getVolume(volumeName);
+    OzoneVolume ozoneVolume = objectStore.getVolume(volumeName);
 
-    retVolumeinfo.createBucket(bucketName);
-    OzoneBucket ozoneBucket = retVolumeinfo.getBucket(bucketName);
+    ozoneVolume.createBucket(bucketName);
+    OzoneBucket ozoneBucket = ozoneVolume.getBucket(bucketName);
 
     for (int i = 0; i < 10; i++) {
       createKey(ozoneBucket);
     }
 
-    long lastAppliedTxOnFollowerOM =
+    final long followerOM1LastAppliedIndex =
         followerOM1.getOmRatisServer().getLastAppliedTermIndex().getIndex();
 
     // Stop one follower OM
@@ -450,38 +450,25 @@ public class TestOzoneManagerHAWithData extends TestOzoneManagerHA {
     // the logs corresponding to atleast some of the missed transactions
     // should be purged. This will force the OM to install snapshot when
     // restarted.
-    long minNewTxIndex = lastAppliedTxOnFollowerOM + (getLogPurgeGap() * 10);
-    long leaderOMappliedLogIndex = leaderOM.getOmRatisServer()
-        .getLastAppliedTermIndex().getIndex();
-
-    List<String> missedKeys = new ArrayList<>();
-    while (leaderOMappliedLogIndex < minNewTxIndex) {
-      missedKeys.add(createKey(ozoneBucket));
-      leaderOMappliedLogIndex = leaderOM.getOmRatisServer()
-          .getLastAppliedTermIndex().getIndex();
+    long minNewTxIndex = followerOM1LastAppliedIndex + getLogPurgeGap() * 10L;
+    while (leaderOM.getOmRatisServer().getLastAppliedTermIndex().getIndex()
+        < minNewTxIndex) {
+      createKey(ozoneBucket);
     }
 
-    // Restart the stopped OM.
-    followerOM1.restart();
-
     // Get the latest snapshotIndex from the leader OM.
-    long leaderOMSnaphsotIndex = leaderOM.getRatisSnapshotIndex();
+    final long leaderOMSnaphsotIndex = leaderOM.getRatisSnapshotIndex();
 
-    // The recently started OM should be lagging behind the leader OM.
-    long followerOMLastAppliedIndex =
-        followerOM1.getOmRatisServer().getLastAppliedTermIndex().getIndex();
-    Assert.assertTrue(
-        followerOMLastAppliedIndex < leaderOMSnaphsotIndex);
+    // The stopped OM should be lagging behind the leader OM.
+    Assert.assertTrue(followerOM1LastAppliedIndex < leaderOMSnaphsotIndex);
+
+    // Restart the stopped OM.
+    followerOM1.restart();
 
     // Wait for the follower OM to catch up
-    GenericTestUtils.waitFor(() -> {
-      long lastAppliedIndex =
-          followerOM1.getOmRatisServer().getLastAppliedTermIndex().getIndex();
-      if (lastAppliedIndex >= leaderOMSnaphsotIndex) {
-        return true;
-      }
-      return false;
-    }, 100, 200000);
+    GenericTestUtils.waitFor(() -> followerOM1.getOmRatisServer()
+        .getLastAppliedTermIndex().getIndex() >= leaderOMSnaphsotIndex,
+        100, 200000);
 
     // Do more transactions. The restarted OM should receive the
     // new transactions. It's last applied tx index should increase from the
@@ -489,11 +476,10 @@ public class TestOzoneManagerHAWithData extends TestOzoneManagerHA {
     for (int i = 0; i < 10; i++) {
       createKey(ozoneBucket);
     }
-    long followerOM1lastAppliedIndex = followerOM1.getOmRatisServer()
-        .getLastAppliedTermIndex().getIndex();
-    Assert.assertTrue(followerOM1lastAppliedIndex >
-        leaderOMSnaphsotIndex);
 
+    final long followerOM1LastAppliedIndexNew =
+        followerOM1.getOmRatisServer().getLastAppliedTermIndex().getIndex();
+    Assert.assertTrue(followerOM1LastAppliedIndexNew > leaderOMSnaphsotIndex);
   }
 
   @Test

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