soumyakanti3578 commented on code in PR #5510: URL: https://github.com/apache/hive/pull/5510#discussion_r1992490507
########## itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreJdbcCliDriver.java: ########## @@ -0,0 +1,104 @@ +/* + * 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.hive.cli.control; + +import org.apache.commons.io.FileUtils; +import org.apache.hadoop.hive.cli.control.CoreCliDriver; +import org.apache.hadoop.hive.cli.control.AbstractCliConfig; +import org.apache.hadoop.hive.ql.externalDB.AbstractExternalDB; +import org.apache.hadoop.hive.ql.qoption.QTestDatabaseHandler; +import org.apache.hadoop.hive.ql.QTestArguments; +import org.apache.hadoop.hive.ql.QTestUtil; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class CoreJdbcCliDriver extends CoreCliDriver { + private AbstractExternalDB externalDB; + private static final Logger LOG = LoggerFactory.getLogger(CoreJdbcCliDriver.class); + private boolean externalTablesCreated = false; + + public CoreJdbcCliDriver(AbstractCliConfig testCliConfig) { + super(testCliConfig); + } + + @Override + @BeforeClass + public void beforeClass() throws Exception { + super.beforeClass(); + + if (cliConfig.getJdbcInitScript() != null) { + LOG.info("Launching docker container, running jdbc init script..."); + java.nio.file.Path scriptFile = Paths.get( + QTestUtil.getScriptsDir(getQt().getConf()) + File.separator + cliConfig.getJdbcInitScript() + ); + if (Files.notExists(scriptFile)) { + LOG.info("No jdbc init script detected. Skipping"); + return; + } + externalDB = QTestDatabaseHandler.DatabaseType.valueOf("POSTGRES").create(); Review Comment: Unfortunately I don't think we can reuse `QTestDatabaseHandler` here. We want to create a DB in `@BeforeClass` method so that the tables are available for all 200 tests. Otherwise we will have to create tpcds tables and corresponding hive external tables again and again for each test file. `QTestDatabaseHandler` is set up to create DB and launch docker for each individual test, as it is done in `beforeTest` method. Please let me know if I am missing something, and if there is a better way to handle this. -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org