yandrey321 commented on code in PR #9258: URL: https://github.com/apache/ozone/pull/9258#discussion_r2852817702
########## hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconTasksV2MultiNode.java: ########## @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.recon; + +import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_CONTAINER_REPORT_INTERVAL; +import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_PIPELINE_REPORT_INTERVAL; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.Duration; +import java.util.List; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.protocol.proto.HddsProtos; +import org.apache.hadoop.hdds.scm.pipeline.PipelineManager; +import org.apache.hadoop.ozone.MiniOzoneCluster; +import org.apache.hadoop.ozone.recon.persistence.ContainerHealthSchemaManagerV2.UnhealthyContainerRecordV2; +import org.apache.hadoop.ozone.recon.scm.ReconContainerManager; +import org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade; +import org.apache.hadoop.ozone.recon.tasks.ReconTaskConfig; +import org.apache.ozone.recon.schema.ContainerSchemaDefinitionV2; +import org.apache.ozone.test.LambdaTestUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * Integration tests for ContainerHealthTaskV2 with multi-node clusters. + * + * These tests are separate from TestReconTasks because they require + * different cluster configurations (3 datanodes) and would conflict + * with the @BeforeEach/@AfterEach setup in that class. + */ +public class TestReconTasksV2MultiNode { + + private static MiniOzoneCluster cluster; + private static ReconContainerManager reconContainerManager; + private static PipelineManager reconPipelineManager; + + @BeforeAll + public static void setupCluster() throws Exception { + OzoneConfiguration testConf = new OzoneConfiguration(); + testConf.set(HDDS_CONTAINER_REPORT_INTERVAL, "5s"); + testConf.set(HDDS_PIPELINE_REPORT_INTERVAL, "5s"); + + ReconTaskConfig taskConfig = testConf.getObject(ReconTaskConfig.class); + taskConfig.setMissingContainerTaskInterval(Duration.ofSeconds(10)); + testConf.setFromObject(taskConfig); + + testConf.set("ozone.scm.stale.node.interval", "6s"); + testConf.set("ozone.scm.dead.node.interval", "8s"); + + ReconService reconService = new ReconService(testConf); + cluster = MiniOzoneCluster.newBuilder(testConf) + .setNumDatanodes(3) + .addService(reconService) + .build(); + + cluster.waitForClusterToBeReady(); + + ReconStorageContainerManagerFacade reconScm = (ReconStorageContainerManagerFacade) + reconService.getReconServer().getReconStorageContainerManager(); + reconPipelineManager = reconScm.getPipelineManager(); + reconContainerManager = (ReconContainerManager) reconScm.getContainerManager(); + } + + @BeforeEach + public void cleanupBeforeEach() throws Exception { + // Ensure each test starts from a clean unhealthy-container table. + reconContainerManager.getContainerSchemaManagerV2().clearAllUnhealthyContainerRecords(); + // Ensure Recon has initialized pipeline state before assertions. + LambdaTestUtils.await(60000, 5000, Review Comment: 5 seconds of wait time will slow down test execution, I'd recommend 100 -300 ms wait time -- 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]
