hemantk-12 commented on code in PR #5083:
URL: https://github.com/apache/ozone/pull/5083#discussion_r1283922491
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java:
##########
@@ -1036,6 +1074,343 @@ public void testInstallCorruptedCheckpointFailure()
throws Exception {
assertLogCapture(logCapture, msg);
}
+ /**
+ * Goal of this test is to check whether background services work after
+ * leadership transfer.
+ * Services tested:
+ * -- SST filtering
+ * -- key deletion
+ * -- snapshot deletion
+ * -- compaction backup pruning
+ * On top of that there are some simple tests to confirm system integrity.
+ */
+ @Test
+ @DisplayName("testSnapshotBackgroundServices")
+ @SuppressWarnings("methodlength")
+ public void testSnapshotBackgroundServices()
+ throws Exception {
+ // Get the leader OM
+ String leaderOMNodeId = OmFailoverProxyUtil
+ .getFailoverProxyProvider(objectStore.getClientProxy())
+ .getCurrentProxyOMNodeId();
+ OzoneManager leaderOM = cluster.getOzoneManager(leaderOMNodeId);
+
+ // Find the inactive OM
+ String followerNodeId = leaderOM.getPeerNodes().get(0).getNodeId();
+ if (cluster.isOMActive(followerNodeId)) {
+ followerNodeId = leaderOM.getPeerNodes().get(1).getNodeId();
+ }
+ OzoneManager followerOM = cluster.getOzoneManager(followerNodeId);
+
+ // Create some snapshots, each with new keys
+ int keyIncrement = 10;
+ String snapshotNamePrefix = "snapshot";
+ String snapshotName = "";
+ List<String> keys = new ArrayList<>();
+ SnapshotInfo snapshotInfo = null;
+ for (int snapshotCount = 0; snapshotCount < 10;
+ snapshotCount++) {
+ snapshotName = snapshotNamePrefix + snapshotCount;
+ keys = writeKeys(keyIncrement);
+ snapshotInfo = createOzoneSnapshot(leaderOM, snapshotName);
+ }
+
+ // Get the latest db checkpoint from the leader OM.
+ TransactionInfo transactionInfo =
+ TransactionInfo.readTransactionInfo(leaderOM.getMetadataManager());
+ TermIndex leaderOMTermIndex =
+ TermIndex.valueOf(transactionInfo.getTerm(),
+ transactionInfo.getTransactionIndex());
+ long leaderOMSnapshotIndex = leaderOMTermIndex.getIndex();
+
+ // Start the inactive OM. Checkpoint installation will happen
spontaneously.
+ cluster.startInactiveOM(followerNodeId);
+
+ // The recently started OM should be lagging behind the leader OM.
+ // Wait & for follower to update transactions to leader snapshot index.
+ // Timeout error if follower does not load update within 10s
+ GenericTestUtils.waitFor(() ->
+ followerOM.getOmRatisServer().getLastAppliedTermIndex().getIndex()
+ >= leaderOMSnapshotIndex - 1, 100, 10000);
+
+ // Verify RPC server is running
+ GenericTestUtils.waitFor(followerOM::isOmRpcServerRunning, 100, 5000);
+
+ // Read & Write after snapshot installed.
+ List<String> newKeys = writeKeys(1);
+ readKeys(newKeys);
+
+ checkSnapshot(leaderOM, followerOM, snapshotName, keys, snapshotInfo);
+
+ // verify that the bootstrap Follower OM can become leader
+ leaderOM.transferLeadership(followerNodeId);
+
+ GenericTestUtils.waitFor(() -> {
+ try {
+ followerOM.checkLeaderStatus();
+ return true;
+ } catch (OMNotLeaderException | OMLeaderNotReadyException e) {
+ return false;
+ }
+ }, 100, 10000);
+ OzoneManager newLeaderOM = cluster.getOMLeader();
+ Assertions.assertEquals(followerOM, newLeaderOM);
+ OzoneManager newFollowerOM =
+ cluster.getOzoneManager(leaderOM.getOMNodeId());
+ Assertions.assertEquals(leaderOM, newFollowerOM);
+
+ readKeys(newKeys);
+
+ // Prepare baseline data for compaction backup pruning
+ // TODO: uncomment this when HDDS-9118 is resolved
Review Comment:
HDDS-9118 has been merged. Please un-comment this code.
--
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]