abhishekbafna commented on code in PR #15634: URL: https://github.com/apache/pinot/pull/15634#discussion_r2087225832
########## pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/logicaltable/BaseLogicalTableIntegrationTest.java: ########## @@ -0,0 +1,515 @@ +/** + * 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.logicaltable; + +import com.fasterxml.jackson.databind.JsonNode; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.apache.commons.io.FileUtils; +import org.apache.pinot.controller.helix.ControllerRequestClient; +import org.apache.pinot.controller.helix.ControllerTest; +import org.apache.pinot.integration.tests.BaseClusterIntegrationTestSet; +import org.apache.pinot.integration.tests.ClusterIntegrationTestUtils; +import org.apache.pinot.integration.tests.QueryGenerator; +import org.apache.pinot.spi.config.table.QueryConfig; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TableType; +import org.apache.pinot.spi.data.LogicalTableConfig; +import org.apache.pinot.spi.data.PhysicalTableConfig; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.exception.QueryErrorCode; +import org.apache.pinot.spi.utils.builder.LogicalTableConfigBuilder; +import org.apache.pinot.spi.utils.builder.TableConfigBuilder; +import org.apache.pinot.spi.utils.builder.TableNameBuilder; +import org.apache.pinot.util.TestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.expectThrows; + + +public abstract class BaseLogicalTableIntegrationTest extends BaseClusterIntegrationTestSet { + protected static final Logger LOGGER = LoggerFactory.getLogger(BaseLogicalTableIntegrationTest.class); + private static final String DEFAULT_TENANT = "DefaultTenant"; + private static final String DEFAULT_LOGICAL_TABLE_NAME = "mytable"; + protected static final String DEFAULT_TABLE_NAME = "physicalTable"; + private static final int NUM_OFFLINE_SEGMENTS = 12; + protected static BaseLogicalTableIntegrationTest _sharedClusterTestSuite = null; + + @BeforeSuite + public void setUpSuite() + throws Exception { + LOGGER.info("Setting up integration test suite"); + TestUtils.ensureDirectoriesExistAndEmpty(_tempDir, _segmentDir, _tarDir); + _sharedClusterTestSuite = this; + + // Start the Pinot cluster + startZk(); + LOGGER.info("Start Kafka in the integration test suite"); + startKafka(); + startController(); + startBroker(); + startServers(2); + LOGGER.info("Finished setting up integration test suite"); + } + + @AfterSuite + public void tearDownSuite() + throws Exception { + LOGGER.info("Tearing down integration test suite"); + // Stop Kafka + LOGGER.info("Stop Kafka in the integration test suite"); + stopKafka(); + // Shutdown the Pinot cluster + stopServer(); + stopBroker(); + stopController(); + stopZk(); + FileUtils.deleteDirectory(_tempDir); + LOGGER.info("Finished tearing down integration test suite"); + } + + @Override + protected String getTableName() { + return DEFAULT_TABLE_NAME; + } + + @BeforeClass + public void setUp() + throws Exception { + TestUtils.ensureDirectoriesExistAndEmpty(_tempDir, _segmentDir, _tarDir); + if (_sharedClusterTestSuite != this) { + _controllerRequestURLBuilder = _sharedClusterTestSuite._controllerRequestURLBuilder; + } + + List<File> avroFiles = getAllAvroFiles(); + int numSegmentsPerTable = NUM_OFFLINE_SEGMENTS / getOfflineTableNames().size(); + int index = 0; + for (String tableName : getOfflineTableNames()) { + File tarDir = new File(_tarDir, tableName); + + TestUtils.ensureDirectoriesExistAndEmpty(tarDir); + + // Create and upload the schema and table config + Schema schema = createSchema(getSchemaFileName()); + schema.setSchemaName(tableName); + addSchema(schema); + TableConfig offlineTableConfig = createOfflineTableConfig(tableName); + addTableConfig(offlineTableConfig); + + List<File> offlineAvroFiles = new ArrayList<>(numSegmentsPerTable); + for (int i = index; i < index + numSegmentsPerTable; i++) { + offlineAvroFiles.add(avroFiles.get(i)); + } + index += numSegmentsPerTable; + + // Create and upload segments + ClusterIntegrationTestUtils.buildSegmentsFromAvro(offlineAvroFiles, offlineTableConfig, schema, 0, _segmentDir, + tarDir); + uploadSegments(tableName, tarDir); + } + + createLogicalTable(); + + // Set up the H2 connection + setUpH2Connection(avroFiles); + + // Initialize the query generator + setUpQueryGenerator(avroFiles); + + // Wait for all documents loaded + waitForAllDocsLoaded(600_000L); + } + + @AfterClass + public void tearDown() Review Comment: don't we need to cleanup the H2 setup? -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org