dombizita commented on code in PR #10084:
URL: https://github.com/apache/ozone/pull/10084#discussion_r3137701333
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -737,6 +738,71 @@ public void testProcessLayoutVersion() throws IOException {
testProcessLayoutVersionReportHigherMlv();
}
+ @Test
+ public void testDatanodeFinalizedCounterTracksLayoutVersionReports()
+ throws IOException, AuthenticationException {
+ try (SCMNodeManager nodeManager = createNodeManager(getConf())) {
+ DatanodeDetails node =
+ HddsTestUtils.createRandomDatanodeAndRegister(nodeManager);
+ assertEquals(1, SCMUpgradeFinalizer.getNumFinalizedDatanodes(nodeManager)
+ .getNumFinalizedDatanodes(),
+ "Initial datanode should be counted as finalized");
+
+ int softwareVersion =
+ nodeManager.getLayoutVersionManager().getSoftwareLayoutVersion();
+ int metadataVersion =
+ nodeManager.getLayoutVersionManager().getMetadataLayoutVersion();
+ nodeManager.processLayoutVersionReport(node,
+ LayoutVersionProto.newBuilder()
+ .setMetadataLayoutVersion(metadataVersion - 1)
+ .setSoftwareLayoutVersion(softwareVersion)
+ .build());
+ assertEquals(0, SCMUpgradeFinalizer.getNumFinalizedDatanodes(nodeManager)
+ .getNumFinalizedDatanodes(),
+ "Lower metadata layout version should decrement finalized count");
+
+ nodeManager.processLayoutVersionReport(node,
+ LayoutVersionProto.newBuilder()
+ .setMetadataLayoutVersion(metadataVersion)
+ .setSoftwareLayoutVersion(softwareVersion)
+ .build());
+ assertEquals(1, SCMUpgradeFinalizer.getNumFinalizedDatanodes(nodeManager)
+ .getNumFinalizedDatanodes(),
+ "Restored metadata layout version should restore finalized count");
+ }
+ }
+
+ @Test
+ public void testDatanodeFinalizedCounterTracksRegistrationAndRemoveNode()
+ throws IOException, AuthenticationException, NodeNotFoundException {
+ try (SCMNodeManager nodeManager = createNodeManager(getConf())) {
+ DatanodeDetails finalizedNode =
+ registerWithCapacity(nodeManager, CORRECT_LAYOUT_PROTO, success);
+ assertEquals(1, SCMUpgradeFinalizer.getNumFinalizedDatanodes(nodeManager)
+ .getNumFinalizedDatanodes(),
+ "Finalized registration should increment finalized count");
+
+ DatanodeDetails nonFinalizedNode =
+ registerWithCapacity(nodeManager, SMALLER_MLV_LAYOUT_PROTO, success);
+ assertEquals(1, SCMUpgradeFinalizer.getNumFinalizedDatanodes(nodeManager)
+ .getNumFinalizedDatanodes(),
+ "Non-finalized registration should not increment finalized count");
+
+ nonFinalizedNode.setPersistedOpState(
+ HddsProtos.NodeOperationalState.DECOMMISSIONED);
Review Comment:
I added tests for the ineligible health and operational states, please take
a look at them!
--
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]