Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-8675. Fix expectation in testUnderRepSentToOverRepHandlerIfNoNewNodes #4795

Merged
merged 1 commit into from May 31, 2023

Conversation

siddhantsangwan
Copy link
Contributor

What changes were proposed in this pull request?

Looks like we are writing the expected result into the actual result of commandsSent and comparing them:

      Set<Pair<DatanodeDetails, SCMCommand<?>>> expectedDelete =
          new HashSet<>();
      expectedDelete.add(Pair.of(overRepReplica.getDatanodeDetails(),
          createDeleteContainerCommand(container,
              overRepReplica.getReplicaIndex())));

      Mockito.when(replicationManager.processOverReplicatedContainer(
          underRep)).thenAnswer(invocationOnMock -> {
            commandsSent.addAll(expectedDelete);
            return expectedDelete.size();
          });
      commandsSent.clear();
      assertThrows(SCMException.class,
          () -> ecURH.processAndSendCommands(availableReplicas,
              Collections.emptyList(), underRep, 2));
      Mockito.verify(replicationManager, times(1))
          .processOverReplicatedContainer(underRep);
      Assertions.assertEquals(true, expectedDelete.equals(commandsSent));

Ideally, commandsSent should be populated with the actual command that was sent. However, since this is a unit test, it's better to not run the code in ECOverReplicationHandler and simply verify that replicationManager.processOverReplicatedContainer was called once. So I've removed the assertion Assertions.assertEquals(true, expectedDelete.equals(commandsSent)).

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-8675

How was this patch tested?

No new tests.

@adoroszlai adoroszlai merged commit 7285519 into apache:master May 31, 2023
15 checks passed
@adoroszlai
Copy link
Contributor

Thanks @siddhantsangwan for the patch, @sodonnel for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants