Skip to content

Commit

Permalink
Add serialisation tests
Browse files Browse the repository at this point in the history
Signed-off-by: Arpit Bandejiya <[email protected]>
  • Loading branch information
Arpit-Bandejiya committed Mar 26, 2024
1 parent d654a8a commit 99ffd46
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
}
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -957,7 +987,7 @@ public void apply(String action, AdmissionControlActionType admissionControlActi
segmentReplicationRejectionStats,
null,
admissionControlStats,
null
peerRecoveryStats
);
}

Expand Down

0 comments on commit 99ffd46

Please sign in to comment.