diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconTasks.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconTasks.java index cba7311b3b4f..3d418459dc5f 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconTasks.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconTasks.java @@ -41,8 +41,12 @@ import org.apache.ozone.test.LambdaTestUtils; import org.hadoop.ozone.recon.schema.ContainerSchemaDefinition; import org.hadoop.ozone.recon.schema.tables.pojos.UnhealthyContainers; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import org.slf4j.event.Level; @@ -58,12 +62,14 @@ * Integration Tests for Recon's tasks. */ @Timeout(300) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +@TestMethodOrder(OrderAnnotation.class) public class TestReconTasks { private MiniOzoneCluster cluster = null; private OzoneConfiguration conf; - @BeforeEach - public void init() throws Exception { + @BeforeAll + void init() throws Exception { conf = new OzoneConfiguration(); conf.set(HDDS_CONTAINER_REPORT_INTERVAL, "5s"); conf.set(HDDS_PIPELINE_REPORT_INTERVAL, "5s"); @@ -74,21 +80,22 @@ public void init() throws Exception { conf.set("ozone.scm.stale.node.interval", "6s"); conf.set("ozone.scm.dead.node.interval", "8s"); - cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(1) + cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3) .includeRecon(true).build(); cluster.waitForClusterToBeReady(); GenericTestUtils.setLogLevel(SCMDatanodeHeartbeatDispatcher.LOG, Level.DEBUG); } - @AfterEach - public void shutdown() { + @AfterAll + void shutdown() { if (cluster != null) { cluster.shutdown(); } } @Test + @Order(3) public void testSyncSCMContainerInfo() throws Exception { ReconStorageContainerManagerFacade reconScm = (ReconStorageContainerManagerFacade) @@ -121,6 +128,7 @@ public void testSyncSCMContainerInfo() throws Exception { } @Test + @Order(1) public void testMissingContainerDownNode() throws Exception { ReconStorageContainerManagerFacade reconScm = (ReconStorageContainerManagerFacade) @@ -141,7 +149,7 @@ public void testMissingContainerDownNode() throws Exception { (ReconContainerManager) reconScm.getContainerManager(); ContainerInfo containerInfo = scmContainerManager - .allocateContainer(RatisReplicationConfig.getInstance(ONE), "test"); + .allocateContainer(RatisReplicationConfig.getInstance(ONE), "testMissingContainer"); long containerID = containerInfo.getContainerID(); try (RDBBatchOperation rdbBatchOperation = new RDBBatchOperation()) { @@ -181,6 +189,8 @@ public void testMissingContainerDownNode() throws Exception { 0, 1000); return (allMissingContainers.isEmpty()); }); + // Cleaning up some data + scmContainerManager.deleteContainer(containerInfo.containerID()); IOUtils.closeQuietly(client); } @@ -202,6 +212,7 @@ public void testMissingContainerDownNode() throws Exception { * @throws Exception */ @Test + @Order(2) public void testEmptyMissingContainerDownNode() throws Exception { ReconStorageContainerManagerFacade reconScm = (ReconStorageContainerManagerFacade) @@ -219,9 +230,10 @@ public void testEmptyMissingContainerDownNode() throws Exception { ContainerManager scmContainerManager = scm.getContainerManager(); ReconContainerManager reconContainerManager = (ReconContainerManager) reconScm.getContainerManager(); + int previousContainerCount = reconContainerManager.getContainers().size(); ContainerInfo containerInfo = scmContainerManager - .allocateContainer(RatisReplicationConfig.getInstance(ONE), "test"); + .allocateContainer(RatisReplicationConfig.getInstance(ONE), "testEmptyMissingContainer"); long containerID = containerInfo.getContainerID(); Pipeline pipeline = @@ -230,8 +242,8 @@ public void testEmptyMissingContainerDownNode() throws Exception { runTestOzoneContainerViaDataNode(containerID, client); // Make sure Recon got the container report with new container. - assertEquals(scmContainerManager.getContainers(), - reconContainerManager.getContainers()); + assertEquals(scmContainerManager.getContainers().size(), + reconContainerManager.getContainers().size() - previousContainerCount); // Bring down the Datanode that had the container replica. cluster.shutdownHddsDatanode(pipeline.getFirstNode()); @@ -305,7 +317,8 @@ public void testEmptyMissingContainerDownNode() throws Exception { 0, 1000); return (allMissingContainers.isEmpty()); }); - + // Cleaning up some data + reconContainerManager.deleteContainer(containerInfo.containerID()); IOUtils.closeQuietly(client); } }