Airliquide76 commented on code in PR #8589: URL: https://github.com/apache/pinot/pull/8589#discussion_r880488657
########## pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/PurgeMinionClusterIntegrationTest.java: ########## @@ -0,0 +1,380 @@ +/** + * 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.pinot.integration.tests; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import javax.annotation.Nullable; +import org.apache.commons.io.FileUtils; +import org.apache.helix.task.TaskState; +import org.apache.pinot.common.lineage.SegmentLineageAccessHelper; +import org.apache.pinot.common.metadata.segment.SegmentZKMetadata; +import org.apache.pinot.common.minion.MinionTaskMetadataUtils; +import org.apache.pinot.common.utils.TarGzCompressionUtils; +import org.apache.pinot.controller.helix.core.PinotHelixResourceManager; +import org.apache.pinot.controller.helix.core.minion.PinotHelixTaskResourceManager; +import org.apache.pinot.controller.helix.core.minion.PinotTaskManager; +import org.apache.pinot.core.common.MinionConstants; +import org.apache.pinot.segment.local.segment.creator.impl.SegmentIndexCreationDriverImpl; +import org.apache.pinot.segment.spi.creator.SegmentGeneratorConfig; +import org.apache.pinot.segment.spi.creator.SegmentIndexCreationDriver; +import org.apache.pinot.spi.config.table.SegmentPartitionConfig; +import org.apache.pinot.spi.config.table.SegmentZKPropsConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TableTaskConfig; +import org.apache.pinot.spi.config.table.TableType; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.utils.builder.TableConfigBuilder; +import org.apache.pinot.spi.utils.builder.TableNameBuilder; +import org.apache.pinot.util.TestUtils; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + + +/** + * Integration test for minion task of type "PurgeTask" + */ +public class PurgeMinionClusterIntegrationTest extends BaseClusterIntegrationTest { + private static final String PURGE_FIRST_RUN_TABLE = "myTable1"; + private static final String PURGE_DELTA_PASSED_TABLE = "myTable2"; + private static final String PURGE_DELTA_NOT_PASSED_TABLE = "myTable3"; + + protected PinotHelixTaskResourceManager _helixTaskResourceManager; + protected PinotTaskManager _taskManager; + protected PinotHelixResourceManager _pinotHelixResourceManager; + + protected final File _segmentDir1 = new File(_tempDir, "segmentDir1"); + protected final File _segmentDir2 = new File(_tempDir, "segmentDir2"); + protected final File _segmentDir3 = new File(_tempDir, "segmentDir3"); + + protected final File _tarDir1 = new File(_tempDir, "tarDir1"); + protected final File _tarDir2 = new File(_tempDir, "tarDir2"); + protected final File _tarDir3 = new File(_tempDir, "tarDir3"); + + @BeforeClass + public void setUp() + throws Exception { + TestUtils.ensureDirectoriesExistAndEmpty(_tempDir, _segmentDir1, _tarDir1, + _segmentDir2, _tarDir2, _segmentDir3, _tarDir3); + + // Start the Pinot cluster + startZk(); + startController(); + startBrokers(1); + startServers(1); + + // Create and upload the schema and table config + Schema schema = createSchema(); + addSchema(schema); + TableConfig purgeTableConfig = + createOfflineTableConfig(PURGE_FIRST_RUN_TABLE, getPurgeTaskConfig()); + TableConfig purgeDeltaPassedTableConfig = + createOfflineTableConfig(PURGE_DELTA_PASSED_TABLE, getPurgeTaskConfig()); + TableConfig purgeDeltaNotPassedTableConfig = + createOfflineTableConfig(PURGE_DELTA_NOT_PASSED_TABLE, getPurgeTaskConfig()); + addTableConfig(purgeTableConfig); + addTableConfig(purgeDeltaPassedTableConfig); + addTableConfig(purgeDeltaNotPassedTableConfig); + + + + + // Unpack the Avro files + List<File> avroFiles = unpackAvroData(_tempDir); + + // Create and upload segments + ClusterIntegrationTestUtils + .buildSegmentsFromAvro(avroFiles, purgeTableConfig, schema, 0, _segmentDir1, _tarDir1); + + buildSegmentsFromAvroWithPurgeTime(avroFiles, purgeDeltaPassedTableConfig, schema, 0, + _segmentDir2, _tarDir2, String.valueOf(System.currentTimeMillis() - 863660000)); + buildSegmentsFromAvroWithPurgeTime(avroFiles, purgeDeltaNotPassedTableConfig, schema, 0, + _segmentDir3, _tarDir3, String.valueOf(System.currentTimeMillis() - 400000)); + + uploadSegments(PURGE_FIRST_RUN_TABLE, _tarDir1); + uploadSegments(PURGE_DELTA_PASSED_TABLE, _tarDir2); + uploadSegments(PURGE_DELTA_NOT_PASSED_TABLE, _tarDir3); + + // Set up the H2 connection + setUpH2Connection(avroFiles); + + // Initialize the query generator + setUpQueryGenerator(avroFiles); + + startMinion(); Review Comment: Done. -- 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]
