peterxcli commented on code in PR #8157:
URL: https://github.com/apache/ozone/pull/8157#discussion_r2044313178
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneManagerHASnapshot.java:
##########
@@ -345,6 +345,29 @@ public void testKeyAndSnapshotDeletionService() throws
IOException, InterruptedE
checkSnapshotIsPurgedFromDB(omFollower, tableKey);
}
+ @Test
+ public void testSnapshotInFlightCount() throws Exception {
+ // snapshot inflight count should be reset to 0 when leader changes
+
+ // first do some snapshot creations
+ String snapshotName1 = UUID.randomUUID().toString();
+ store.createSnapshot(volumeName, bucketName, snapshotName1);
+
+ // then shutdown the leader
+ OzoneManager omLeader = cluster.getOMLeader();
+ cluster.shutdownOzoneManager(omLeader);
+
+ // wait for the new leader to be elected
+ cluster.waitForLeaderOM();
+
+ // check the inflight count on the new leader is 0
+ OzoneManager newLeader = cluster.getOMLeader();
+ assertEquals(0,
newLeader.getOmSnapshotManager().getInFlightSnapshotCount());
Review Comment:
I have check that if I comment out the reset logic, this test would failed
with:
```java
ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 112.5
s <<< FAILURE! -- in
org.apache.hadoop.ozone.om.snapshot.TestOzoneManagerHASnapshot
[ERROR]
org.apache.hadoop.ozone.om.snapshot.TestOzoneManagerHASnapshot.testSnapshotInFlightCount
-- Time elapsed: 1.501 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <0> but was: <-24>
at
org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at
org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at
org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at
org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
at
org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145)
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:531)
at
org.apache.hadoop.ozone.om.snapshot.TestOzoneManagerHASnapshot.testSnapshotInFlightCount(TestOzoneManagerHASnapshot.java:365)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
```
--
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]