This is an automated email from the ASF dual-hosted git repository.
erose pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 33ddda41e0 HDDS-13581. Fix Intermittent failure in
TestReplicationSupervisor#testReconcileContainerCommandDeduplication. (#8960)
33ddda41e0 is described below
commit 33ddda41e00e0e2772472308fd43eddb2b0c7329
Author: Ethan Rose <[email protected]>
AuthorDate: Mon Aug 25 18:12:20 2025 -0400
HDDS-13581. Fix Intermittent failure in
TestReplicationSupervisor#testReconcileContainerCommandDeduplication. (#8960)
---
.../replication/TestReplicationSupervisor.java | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java
index f439e6a1d3..8dee27e488 100644
---
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java
+++
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java
@@ -35,6 +35,7 @@
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -788,7 +789,7 @@ public void testPriorityOrdering(ContainerLayoutVersion
layout)
}
@ContainerLayoutTestInfo.ContainerTest
- public void testReconcileContainerCommandDeduplication() {
+ public void testReconcileContainerCommandDeduplication() throws Exception {
ReplicationSupervisor supervisor = ReplicationSupervisor.newBuilder()
.stateContext(context)
.build();
@@ -799,14 +800,26 @@ public void testReconcileContainerCommandDeduplication() {
// Create reconcile commands with the same container ID but different
peers
ReconcileContainerCommand command1 = new
ReconcileContainerCommand(containerID, Collections.singleton(
MockDatanodeDetails.randomDatanodeDetails()));
+ command1.setTerm(1);
ReconcileContainerCommand command2 = new
ReconcileContainerCommand(containerID, Collections.singleton(
MockDatanodeDetails.randomDatanodeDetails()));
+ command2.setTerm(1);
assertEquals(command1, command2);
+
+ // Create a controller that blocks the execution of reconciliation until
the latch is counted down from the test.
+ ContainerController blockingController = mock(ContainerController.class);
+ CountDownLatch latch = new CountDownLatch(1);
+ doAnswer(arg -> {
+ latch.await();
+ return null;
+ }).when(blockingController).reconcileContainer(any(), anyLong(), any());
+
ReconcileContainerTask task1 = new ReconcileContainerTask(
- mock(ContainerController.class),
+ blockingController,
mock(DNContainerOperationClient.class),
command1);
ReconcileContainerTask task2 = new ReconcileContainerTask(
+ // The second task should be discarded as a duplicate. It does not
need to block.
mock(ContainerController.class),
mock(DNContainerOperationClient.class),
command2);
@@ -820,6 +833,11 @@ public void testReconcileContainerCommandDeduplication() {
supervisor.addTask(task2);
assertEquals(1, supervisor.getTotalInFlightReplications());
assertEquals(1, supervisor.getReplicationQueuedCount());
+
+ // Now the task has been unblocked. The supervisor should finish
execution of the one blocked task.
+ latch.countDown();
+ GenericTestUtils.waitFor(() ->
+ supervisor.getTotalInFlightReplications() == 0 &&
supervisor.getReplicationQueuedCount() == 0, 500, 5000);
} finally {
supervisor.stop();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]