diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java index ced9c28878a61..0481238a68c6c 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java @@ -59,6 +59,7 @@ import org.opensearch.index.remote.RemoteTranslogTransferTracker; import org.opensearch.index.translog.RemoteTranslogStats; import org.opensearch.indices.NodeIndicesStats; +import org.opensearch.indices.recovery.PeerRecoveryStats; import org.opensearch.ingest.IngestStats; import org.opensearch.monitor.fs.FsInfo; import org.opensearch.monitor.jvm.JvmStats; @@ -576,6 +577,24 @@ public void testSerialization() throws IOException { deserializedAdmissionControllerStats.getRejectionCount().get(AdmissionControlActionType.INDEXING.getType()) ); } + + PeerRecoveryStats peerRecoveryStats = nodeStats.getPeerRecoveryStats(); + PeerRecoveryStats deserializedPeerRecoveryStats = deserializedNodeStats.getPeerRecoveryStats(); + if (peerRecoveryStats == null) { + assertNull(deserializedPeerRecoveryStats); + } else { + assertEquals( + peerRecoveryStats.getTotalCancelledRecoveries(), + deserializedPeerRecoveryStats.getTotalCancelledRecoveries() + ); + assertEquals( + peerRecoveryStats.getTotalCompletedRecoveries(), + deserializedPeerRecoveryStats.getTotalCompletedRecoveries() + ); + assertEquals(peerRecoveryStats.getTotalFailedRecoveries(), deserializedPeerRecoveryStats.getTotalFailedRecoveries()); + assertEquals(peerRecoveryStats.getTotalRetriedRecoveries(), deserializedPeerRecoveryStats.getTotalRetriedRecoveries()); + assertEquals(peerRecoveryStats.getTotalStartedRecoveries(), deserializedPeerRecoveryStats.getTotalStartedRecoveries()); + } } } } @@ -926,6 +945,17 @@ public void apply(String action, AdmissionControlActionType admissionControlActi NodeIndicesStats indicesStats = getNodeIndicesStats(remoteStoreStats); + PeerRecoveryStats peerRecoveryStats = null; + if (frequently()) { + peerRecoveryStats = new PeerRecoveryStats( + randomNonNegativeLong(), + randomNonNegativeLong(), + randomNonNegativeLong(), + randomNonNegativeLong(), + randomNonNegativeLong() + ); + } + // TODO: Only remote_store based aspects of NodeIndicesStats are being tested here. // It is possible to test other metrics in NodeIndicesStats as well since it extends Writeable now return new NodeStats( @@ -957,7 +987,7 @@ public void apply(String action, AdmissionControlActionType admissionControlActi segmentReplicationRejectionStats, null, admissionControlStats, - null + peerRecoveryStats ); }