Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-28576: Add jdbc tests for tpcds queries #5510

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
712 changes: 712 additions & 0 deletions data/scripts/q_test_external_tpcds_tables_postgres.q

Large diffs are not rendered by default.

472 changes: 472 additions & 0 deletions data/scripts/q_test_tpcds_tables.postgres.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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;

import java.io.File;
import java.util.List;

import org.apache.hadoop.hive.cli.control.CliAdapter;
import org.apache.hadoop.hive.cli.control.CliConfigs;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class TestMiniLlapLocalJdbcCliDriver {
static CliAdapter adapter = new CliConfigs.MiniLlapLocalJdbcCliConfig().getCliAdapter();

@Parameters(name = "{0}")
public static List<Object[]> getParameters() throws Exception {
return adapter.getParameters();
}

@ClassRule
public static TestRule cliClassRule = adapter.buildClassRule();

@Rule
public TestRule cliTestRule = adapter.buildTestRule();

private String name;
private File qfile;

public TestMiniLlapLocalJdbcCliDriver(String name, File qfile) {
this.name = name;
this.qfile = qfile;
}

@Test
public void testCliDriver() throws Exception {
adapter.runTest(name, qfile);
}
}
7 changes: 7 additions & 0 deletions itests/src/test/resources/testconfiguration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ tez.perf.disabled.query.files=\
mv_query67.q,\
mv_query68.q

jdbc.disabled.query.files=\
mv_query30.q,\
mv_query44.q,\
mv_query45.q,\
mv_query67.q,\
mv_query68.q

druid.query.files=\
druid_materialized_view_rewrite_ssb.q,\
druid_timeseries.q,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public abstract class AbstractCliConfig {
// these should have viable defaults
private String cleanupScript;
private String initScript;
private String jdbcInitScript;
private String externalTablesForJdbcInitScript;
private String hiveConfDir;
private MiniClusterType clusterType;
private FsType fsType;
Expand Down Expand Up @@ -345,6 +347,22 @@ protected void setInitScript(String initScript) {
this.initScript = initScript;
}
}

public String getJdbcInitScript() {
return jdbcInitScript;
}

public void setJdbcInitScript(String jdbcInitScript) {
this.jdbcInitScript = jdbcInitScript;
}

public String getExternalTablesForJdbcInitScript() {
return externalTablesForJdbcInitScript;
}

public void setExternalTablesForJdbcInitScript(String externalTablesForJdbcInitScript) {
this.externalTablesForJdbcInitScript = externalTablesForJdbcInitScript;
}
public String getHiveConfDir() {
return hiveConfDir;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,24 @@ public TezTPCDS30TBCliConfig() {
}
}

public static class MiniLlapLocalJdbcCliConfig extends AbstractCliConfig {
public MiniLlapLocalJdbcCliConfig() {
super(CoreJdbcCliDriver.class);
try {
setQueryDir("ql/src/test/queries/clientpositive/perf");
setLogDir("itests/qtest/target/qfile-results/clientpositive/jdbc/postgres");
setResultsDir("ql/src/test/results/clientpositive/jdbc/postgres");
setHiveConfDir("data/conf/llap");
setClusterType(MiniClusterType.LLAP_LOCAL);
setJdbcInitScript("q_test_tpcds_tables.postgres.sql");
setExternalTablesForJdbcInitScript("q_test_external_tpcds_tables_postgres.q");
excludesFrom(testConfigProps, "jdbc.disabled.query.files");
} catch (Exception e) {
throw new RuntimeException("can't construct cliconfig", e);
}
}
}

public static class NegativeLlapLocalCliConfig extends AbstractCliConfig {
public NegativeLlapLocalCliConfig() {
super(CoreNegativeCliDriver.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
externalDB.launchDockerContainer();
externalDB.execute(scriptFile.toString());
}
}

@Override
@Before
public void setUp() throws Exception {
super.setUp();
if (!externalTablesCreated && cliConfig.getExternalTablesForJdbcInitScript() != null) {
LOG.info("Running init script for external tables...");
File scriptFile = new File(
QTestUtil.getScriptsDir(getQt().getConf()) + File.separator +
cliConfig.getExternalTablesForJdbcInitScript()
);
if (!scriptFile.isFile()) {
LOG.info("No init script for external tables detected. Skipping");
return;
}
String initCommands = FileUtils.readFileToString(scriptFile);
getQt().getCliDriver().processLine(initCommands);
externalTablesCreated = true;
}
}

@Override
@After
public void tearDown() throws Exception {
getQt().clearPostTestEffects();
}

@Override
@AfterClass
public void shutdown() throws Exception {
LOG.info("Cleaning up...");
super.tearDown();
super.shutdown();
if (externalDB != null) {
LOG.info("Cleaning up docker...");
externalDB.cleanupDockerContainer();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,35 @@
public class QTestDatabaseHandler implements QTestOptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(QTestDatabaseHandler.class);

private enum DatabaseType {
public enum DatabaseType {
POSTGRES {
@Override
AbstractExternalDB create() {
public AbstractExternalDB create() {
return new PostgresExternalDB();
}
}, MYSQL {
@Override
AbstractExternalDB create() {
public AbstractExternalDB create() {
return new MySQLExternalDB();
}
}, MARIADB {
@Override
AbstractExternalDB create() {
public AbstractExternalDB create() {
return new MariaDB();
}
}, MSSQL {
@Override
AbstractExternalDB create() {
public AbstractExternalDB create() {
return new MSSQLServer();
}
}, ORACLE {
@Override
AbstractExternalDB create() {
public AbstractExternalDB create() {
return new Oracle();
}
};

abstract AbstractExternalDB create();
public abstract AbstractExternalDB create();
}

private final Map<DatabaseType, String> databaseToScript = new EnumMap<>(DatabaseType.class);
Expand Down
Loading
Loading