From 9425ea5bf3834561daacdb284fb269964c91a585 Mon Sep 17 00:00:00 2001 From: S O'Donnell Date: Fri, 12 May 2023 10:54:32 +0100 Subject: [PATCH] HDDS-7732. EC: Verify block deletion from missing EC containers --- .../replication/TestReplicationManager.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/TestReplicationManager.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/TestReplicationManager.java index 2176508d8b6e..e15648f5b61c 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/TestReplicationManager.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/TestReplicationManager.java @@ -147,7 +147,6 @@ public void setup() throws IOException { Mockito.when(containerManager.getContainers()).thenAnswer( invocation -> new ArrayList<>(containerInfoSet)); - replicationManager = createReplicationManager(); containerReplicaMap = new HashMap<>(); containerInfoSet = new HashSet<>(); @@ -502,6 +501,34 @@ public void testUnderReplicatedAndUnrecoverable() ReplicationManagerReport.HealthState.MISSING)); } + @Test + public void testUnrecoverableAndEmpty() + throws ContainerNotFoundException { + ContainerInfo container = createContainerInfo(repConfig, 1, + HddsProtos.LifeCycleState.CLOSED); + + ContainerReplica replica = createContainerReplica(container.containerID(), + 1, IN_SERVICE, ContainerReplicaProto.State.CLOSED, + 0, 0, MockDatanodeDetails.randomDatanodeDetails(), UUID.randomUUID()); + + storeContainerAndReplicas(container, Collections.singleton(replica)); + + replicationManager.processContainer(container, repQueue, repReport); + // If it is unrecoverable, there is no point in putting it into the under + // replication list. It will be checked again on the next RM run. + Assert.assertEquals(0, repQueue.underReplicatedQueueSize()); + Assert.assertEquals(0, repQueue.overReplicatedQueueSize()); + Assert.assertEquals(0, repReport.getStat( + ReplicationManagerReport.HealthState.UNDER_REPLICATED)); + Assert.assertEquals(0, repReport.getStat( + ReplicationManagerReport.HealthState.MISSING)); + // As it is marked empty in the report, it must have gone through the + // empty container handler, indicating is was handled as empty. + Assert.assertEquals(1, repReport.getStat( + ReplicationManagerReport.HealthState.EMPTY)); + } + + /** * A closed EC container with 3 closed and 2 unhealthy replicas is under * replicated. RM should add it to under replicated queue.