dombizita commented on code in PR #10570:
URL: https://github.com/apache/ozone/pull/10570#discussion_r3622177852
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/TestReplicationManager.java:
##########
@@ -1739,4 +1750,68 @@ private void mockReplicationCommandCounts(
});
}
+ /**
+ * Captures the ReplicateContainerCommand SCM sends to a datanode.
+ */
+ private ReplicateContainerCommand captureSentReplicateCommand() {
+ ArgumentCaptor<SCMCommand<?>> command =
+ ArgumentCaptor.forClass(SCMCommand.class);
+ verify(nodeManager).addDatanodeCommand(any(DatanodeID.class),
+ command.capture());
+ return (ReplicateContainerCommand) command.getValue();
+ }
+
+ private DatanodeInfo mockDatanodeWithApparentVersion(
+ DatanodeDetails dn, HDDSVersion version) {
+ DatanodeInfo info = mock(DatanodeInfo.class);
+ when(info.getLastKnownApparentVersion()).thenReturn(version);
+ when(nodeManager.getNode(dn.getID())).thenReturn(info);
+ return info;
+ }
+
+ @Test
+ public void testApparentVersionIsLowestOfSourceAndTarget()
+ throws NotLeaderException, NodeNotFoundException {
+ ContainerInfo containerInfo =
+ ReplicationTestUtil.createContainerInfo(repConfig, 1,
+ HddsProtos.LifeCycleState.CLOSED, 10, 20);
+ DatanodeDetails target = MockDatanodeDetails.randomDatanodeDetails();
+ DatanodeDetails source = MockDatanodeDetails.randomDatanodeDetails();
+
+ // Source is newer than target, so the lowest common version is the
+ // target's version, not the peer the command is sent to.
+ mockDatanodeWithApparentVersion(source, HDDSVersion.STREAM_BLOCK_SUPPORT);
+ mockDatanodeWithApparentVersion(target,
+ HDDSVersion.SEPARATE_RATIS_PORTS_AVAILABLE);
+ when(nodeManager.getLowestApparentVersion(source, target))
+ .thenCallRealMethod();
+
+ replicationManager.sendLowPriorityReplicateContainerCommand(containerInfo,
+ 1, source, target, clock.millis() + rmConf.getEventTimeout());
Review Comment:
Adjusted `testApparentVersionIsLowestOfSourceAndTarget` to do this.
--
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]