http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestHBaseNegativeCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestHBaseNegativeCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestHBaseNegativeCliDriver.java new file mode 100644 index 0000000..88d626c --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestHBaseNegativeCliDriver.java @@ -0,0 +1,62 @@ +/** + * 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 TestHBaseNegativeCliDriver { + + static CliAdapter adapter = new CliConfigs.HBaseNegativeCliConfig().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 TestHBaseNegativeCliDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +}
http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniLlapCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniLlapCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniLlapCliDriver.java new file mode 100644 index 0000000..ad525fe --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniLlapCliDriver.java @@ -0,0 +1,62 @@ +/** + * 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 TestMiniLlapCliDriver { + + static CliAdapter adapter = new CliConfigs.MiniLlapCliConfig().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 TestMiniLlapCliDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniTezCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniTezCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniTezCliDriver.java new file mode 100644 index 0000000..c23b0b3 --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMiniTezCliDriver.java @@ -0,0 +1,62 @@ +/** + * 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 TestMiniTezCliDriver { + + static CliAdapter adapter = new CliConfigs.MiniTezCliConfig().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 TestMiniTezCliDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMinimrCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMinimrCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMinimrCliDriver.java new file mode 100644 index 0000000..96a9e8f --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestMinimrCliDriver.java @@ -0,0 +1,62 @@ +/** + * 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 TestMinimrCliDriver { + + static CliAdapter adapter = new CliConfigs.MinimrCliConfig().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 TestMinimrCliDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeCliDriver.java new file mode 100644 index 0000000..1040228 --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeCliDriver.java @@ -0,0 +1,62 @@ +/** + * 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 TestNegativeCliDriver { + + static CliAdapter adapter = new CliConfigs.NegativeCliConfig().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 TestNegativeCliDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeMinimrCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeMinimrCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeMinimrCliDriver.java new file mode 100644 index 0000000..f7e2caa --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestNegativeMinimrCliDriver.java @@ -0,0 +1,62 @@ +/** + * 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 TestNegativeMinimrCliDriver { + + static CliAdapter adapter = new CliConfigs.NegativeMinimrCli().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 TestNegativeMinimrCliDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestPerfCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestPerfCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestPerfCliDriver.java new file mode 100644 index 0000000..4df4eeb --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestPerfCliDriver.java @@ -0,0 +1,62 @@ +/** + * 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 TestPerfCliDriver { + + static CliAdapter adapter = new CliConfigs.PerfCliConfig().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 TestPerfCliDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/qtest/src/test/java/org/apache/hadoop/hive/ql/parse/TestParseNegativeDriver.java ---------------------------------------------------------------------- diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/ql/parse/TestParseNegativeDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/ql/parse/TestParseNegativeDriver.java new file mode 100644 index 0000000..4c1224f --- /dev/null +++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/ql/parse/TestParseNegativeDriver.java @@ -0,0 +1,62 @@ +/** + * 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.ql.parse; + +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 TestParseNegativeDriver { + + static CliAdapter adapter = new CliConfigs.ParseNegativeConfig().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 TestParseNegativeDriver(String name, File qfile) { + this.name = name; + this.qfile = qfile; + } + + @Test + public void testCliDriver() throws Exception { + adapter.runTest(name, qfile); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/AbstractCliConfig.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/AbstractCliConfig.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/AbstractCliConfig.java new file mode 100644 index 0000000..efbd465 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/AbstractCliConfig.java @@ -0,0 +1,417 @@ +/** + * 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 java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.regex.Pattern; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.hadoop.hive.ql.QTestUtil; +import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType; +import com.google.common.base.Splitter; +import com.google.common.collect.Sets; + +public abstract class AbstractCliConfig { + + public static final String HIVE_ROOT = getHiveRoot(); + + public static enum MetastoreType { + sql, hbase + }; + + private MetastoreType metastoreType = MetastoreType.sql; + private String queryFile; + private String queryFileRegex; + private String queryDirectory; + // pending change to boolean + private String runDisabled; + // FIXME: file paths in strings should be changed to either File or Path ... anything but String + private String resultsDirectory; + private Set<String> excludedQueryFileNames = new LinkedHashSet<>(); + private String hadoopVersion; + private String logDirectory; + // these should have viable defaults + private String cleanupScript; + private String initScript; + private String hiveConfDir; + private MiniClusterType clusterType; + + // FIXME: null value is treated differently on the other end..when those filter will be + // moved...this may change + private Set<String> includeQueryFileNames; + private Class<? extends CliAdapter> cliAdapter; + + public AbstractCliConfig(Class<? extends CliAdapter> adapter) { + cliAdapter=adapter; + clusterType = MiniClusterType.none; + queryFile = getSysPropValue("qfile"); + queryFileRegex = getSysPropValue("qfile_regex"); + runDisabled = getSysPropValue("run_disabled"); + } + + private static String getHiveRoot() { + List<String> candidateSiblings = new ArrayList<>(); + if (System.getProperty("hive.root") != null) { + try { + candidateSiblings.add(new File(System.getProperty("hive.root")).getCanonicalPath()); + } catch (IOException e) { + throw new RuntimeException("error getting hive.root",e); + } + } + candidateSiblings.add(new File(".").getAbsolutePath()); + + for (String string : candidateSiblings) { + File curr = new File(string); + do { + Set<String> lls = Sets.newHashSet(curr.list()); + if (lls.contains("itests") && lls.contains("ql") && lls.contains("metastore")) { + System.out.println("detected hiveRoot: " + curr); + return QTestUtil.ensurePathEndsInSlash(curr.getAbsolutePath()); + } + curr = curr.getParentFile(); + } while (curr != null); + } + throw new RuntimeException("unable to find hiveRoot"); + } + + protected void setQueryDir(String dir) { + queryDirectory = getAbsolutePath(dir); + } + + @Deprecated + public void overrideUserQueryFile(String q) { + queryFile = q; + } + + public void includesFrom(URL resource, String key) { + try (InputStream is = resource.openStream()) { + Properties props = new Properties(); + props.load(is); + String fileNames = getSysPropValue(key); + if (fileNames == null) { + fileNames = props.getProperty(key); + } + if (fileNames != null) { + for (String qFile : TEST_SPLITTER.split(fileNames)) { + includeQuery(qFile); + } + } + } catch (IOException e) { + throw new RuntimeException("error processing:" + resource, e); + } + } + + protected void includeQuery(String qFile) { + if (includeQueryFileNames == null) { + includeQueryFileNames = new HashSet<>(); + } + includeQueryFileNames.add(qFile); + } + + public void excludesFrom(URL resource, String key) { + try (InputStream is = resource.openStream()) { + Properties props = new Properties(); + props.load(is); + + String fileNames = getSysPropValue(key); + if (fileNames == null) { + fileNames = props.getProperty(key); + } + if (fileNames != null) { + for (String qFile : TEST_SPLITTER.split(fileNames)) { + excludeQuery(qFile); + } + } + } catch (IOException e) { + throw new RuntimeException("error processing:" + resource, e); + } + } + + protected void excludeQuery(String qFile) { + excludedQueryFileNames.add(qFile); + } + + + private static final Splitter TEST_SPLITTER = + Splitter.onPattern("[, ]").trimResults().omitEmptyStrings(); + + public static class IncludeFilter implements FileFilter { + + Set<String> includeOnly; + + public IncludeFilter(Set<String> includeOnly) { + this.includeOnly = includeOnly; + } + + @Override + public boolean accept(File fpath) { + return includeOnly == null || includeOnly.contains(fpath.getName()); + } + } + + public static class QFileFilter extends IncludeFilter { + + public QFileFilter(Set<String> includeOnly) { + super(includeOnly); + } + + @Override + public boolean accept(File fpath) { + if (!super.accept(fpath)) { + return false; + } + if (fpath.isDirectory() || !fpath.getName().endsWith(".q")) { + return false; + } + return true; + } + } + + public static class DisabledQFileFilter extends IncludeFilter { + public DisabledQFileFilter(Set<String> includeOnly) { + super(includeOnly); + } + + @Override + public boolean accept(File fpath) { + if (!super.accept(fpath)) { + return false; + } + return !fpath.isDirectory() && fpath.getName().endsWith(".q.disabled"); + } + } + + public static class QFileRegexFilter implements FileFilter { + Pattern filterPattern; + + public QFileRegexFilter(String filter) { + filterPattern = Pattern.compile(filter); + } + + @Override + public boolean accept(File filePath) { + if (filePath.isDirectory() || !filePath.getName().endsWith(".q")) { + return false; + } + String testName = StringUtils.chomp(filePath.getName(), ".q"); + return filterPattern.matcher(testName).matches(); + } + } + + public Set<File> getQueryFiles() throws Exception { + prepareDirs(); + + Set<String> includeOnly = includeQueryFileNames; + + // queryDirectory should not be null + File queryDir = new File(queryDirectory); + + // dedup file list + Set<File> testFiles = new LinkedHashSet<>(); + if (queryFile != null && !queryFile.equals("")) { + // The user may have passed a list of files - comma separated + for (String qFile : TEST_SPLITTER.split(queryFile)) { + if (null != queryDir) { + testFiles.add(new File(queryDir, qFile)); + } else { + testFiles.add(new File(qFile)); + } + } + } else if (queryFileRegex != null && !queryFileRegex.equals("")) { + for (String regex : TEST_SPLITTER.split(queryFileRegex)) { + testFiles.addAll(Arrays.asList(queryDir.listFiles(new QFileRegexFilter(regex)))); + } + } else if (runDisabled != null && runDisabled.equals("true")) { + testFiles.addAll(Arrays.asList(queryDir.listFiles(new DisabledQFileFilter(includeOnly)))); + } else { + testFiles.addAll(Arrays.asList(queryDir.listFiles(new QFileFilter(includeOnly)))); + } + + for (String qFileName : excludedQueryFileNames) { + testFiles.remove(new File(queryDir, qFileName)); + } + + return testFiles; + } + + private void prepareDirs() throws Exception { + File hiveRootDir = new File(HIVE_ROOT); + if (!hiveRootDir.exists()) { + throw new RuntimeException( + "Hive Root Directory " + hiveRootDir.getCanonicalPath() + " does not exist"); + } + + File logDir = new File(logDirectory); + if (!logDir.exists()) { + FileUtils.forceMkdir(logDir); + } + + File resultsDir = new File(resultsDirectory); + if (!resultsDir.exists()) { + FileUtils.forceMkdir(resultsDir); + } + } + + public String getHadoopVersion() { + if (hadoopVersion == null) { + System.out.println("detecting hadoop.version from loaded libs"); + try { + String hadoopPropsLoc = "/META-INF/maven/org.apache.hadoop/hadoop-hdfs/pom.properties"; + URL hadoopPropsURL = getClass().getResource(hadoopPropsLoc); + if (hadoopPropsURL == null) { + throw new RuntimeException("failed to get hadoop properties: " + hadoopPropsLoc); + } + try (InputStream is = hadoopPropsURL.openStream()) { + Properties props = new Properties(); + props.load(is); + hadoopVersion = props.getProperty("version"); + if (hadoopVersion == null) { + throw new RuntimeException("version property not found"); + } + } catch (IOException e) { + throw new RuntimeException("unable to extract hadoop.version from: " + hadoopPropsURL, e); + } + } catch (Exception e) { + throw new RuntimeException( + "can't get hadoop.version ; specify manually using hadoop.version property!"); + } + } + return hadoopVersion; + } + + protected void setHadoopVersion(String hadoopVersion) { + this.hadoopVersion = hadoopVersion; + } + + public String getLogDir() { + return logDirectory; + } + + protected void setLogDir(String logDirectory) { + this.logDirectory = getAbsolutePath(logDirectory); + } + + public String getResultsDir() { + return resultsDirectory; + } + + protected void setResultsDir(String resultsDir) { + resultsDirectory = getAbsolutePath(resultsDir); + } + + public String getCleanupScript() { + return cleanupScript; + } + + protected void setCleanupScript(String cleanupScript) { + this.cleanupScript = cleanupScript; + } + + public String getInitScript() { + return initScript; + } + + protected void setInitScript(String initScript) { + String initScriptPropValue = getSysPropValue("initScript"); + if (initScriptPropValue != null) { + System.out.println("initScript override(by system property):" + initScriptPropValue); + this.initScript = initScriptPropValue; + } else { + this.initScript = initScript; + } + } + + public String getHiveConfDir() { + return hiveConfDir; + } + + protected void setHiveConfDir(String hiveConfDir) { + if (hiveConfDir.trim().isEmpty()) { + this.hiveConfDir = hiveConfDir; + } else { + this.hiveConfDir = getAbsolutePath(hiveConfDir); + } + } + + public MiniClusterType getClusterType() { + return clusterType; + } + + protected void setClusterType(MiniClusterType type) { + String modeStr = getSysPropValue("clustermode"); + if (modeStr != null) { + // FIXME: this should be changeto valueOf ... + // that will also kill that fallback 'none' which is I think more like a problem than a + // feature ;) + clusterType = MiniClusterType.valueForString(modeStr); + } else { + clusterType = type; + } + if (clusterType == null) { + throw new RuntimeException("clustertype cant be null"); + } + } + + private String getSysPropValue(String propName) { + String propValue = System.getProperty(propName); + if (propValue == null || propValue.trim().length() == 0) { + return null; + } + System.out.println("property: " + propName + " used as override with val: " + propValue); + return propValue.trim(); + } + + public CliAdapter getCliAdapter() { + try { + Constructor<? extends CliAdapter> cz = cliAdapter.getConstructor(AbstractCliConfig.class); + return cz.newInstance(this); + } catch (Exception e) { + throw new RuntimeException("unable to build adapter", e); + } + } + + protected void setMetastoreType(MetastoreType mt) { + metastoreType=mt; + } + + public MetastoreType getMetastoreType() { + return metastoreType; + } + + public String getQueryDirectory() { + return queryDirectory; + } + + private String getAbsolutePath(String dir) { + return new File(new File(HIVE_ROOT), dir).getAbsolutePath(); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliAdapter.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliAdapter.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliAdapter.java new file mode 100644 index 0000000..b89d6e7 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliAdapter.java @@ -0,0 +1,107 @@ +/** + * 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 java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +/** + * This class adapts old vm test-executors to be executed in multiple instances + */ +public abstract class CliAdapter { + + protected final AbstractCliConfig cliConfig; + + public CliAdapter(AbstractCliConfig cliConfig) { + this.cliConfig = cliConfig; + } + + public final List<Object[]> getParameters() throws Exception { + Set<File> f = cliConfig.getQueryFiles(); + List<Object[]> ret = new ArrayList<>(); + + for (File file : f) { + String label = file.getName().replaceAll("\\.[^\\.]+$", ""); + ret.add(new Object[] { label, file }); + } + return ret; + } + + abstract public void beforeClass() throws Exception; + + // HIVE-14444 pending rename: before + abstract public void setUp(); + + // HIVE-14444 pending rename: after + abstract public void tearDown(); + + // HIVE-14444 pending rename: afterClass + abstract public void shutdown() throws Exception; + + abstract public void runTest(String name, String name2, String absolutePath) throws Exception; + + public final TestRule buildClassRule() { + return new TestRule() { + @Override + public Statement apply(final Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + CliAdapter.this.beforeClass(); + try { + base.evaluate(); + } finally { + CliAdapter.this.shutdown(); + } + } + }; + } + }; + } + + public final TestRule buildTestRule() { + return new TestRule() { + @Override + public Statement apply(final Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + CliAdapter.this.setUp(); + try { + base.evaluate(); + } finally { + CliAdapter.this.tearDown(); + } + } + }; + } + }; + } + + // HIVE-14444: pending refactor to push File forward + public final void runTest(String name, File qfile) throws Exception { + runTest(name, qfile.getName(), qfile.getAbsolutePath()); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java new file mode 100644 index 0000000..e7af372 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java @@ -0,0 +1,503 @@ +/** + * 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 java.io.File; +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType; +import org.apache.hadoop.hive.ql.parse.CoreParseNegative; + +public class CliConfigs { + + private static URL testConfigProps = getTestPropsURL(); + + private static URL getTestPropsURL() { + try { + return new File( + AbstractCliConfig.HIVE_ROOT + "/itests/src/test/resources/testconfiguration.properties") + .toURI().toURL(); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + public static class CliConfig extends AbstractCliConfig { + + public CliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + excludesFrom(testConfigProps, "minillap.query.files"); + excludesFrom(testConfigProps, "minimr.query.files"); + excludesFrom(testConfigProps, "minitez.query.files"); + excludesFrom(testConfigProps, "encrypted.query.files"); + excludesFrom(testConfigProps, "spark.only.query.files"); + excludesFrom(testConfigProps, "disabled.query.files"); + + setResultsDir("ql/src/test/results/clientpositive"); + setLogDir("itests/qtest/target/qfile-results/clientpositive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class ParseNegativeConfig extends AbstractCliConfig { + public ParseNegativeConfig() { + super(CoreParseNegative.class); + try { + setQueryDir("ql/src/test/queries/negative"); + + setResultsDir("ql/src/test/results/compiler/errors"); + setLogDir("itests/qtest/target/qfile-results/negative"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir("data/conf/perf-reg/"); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class MinimrCliConfig extends AbstractCliConfig { + public MinimrCliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + includesFrom(testConfigProps, "minimr.query.files"); + + setResultsDir("ql/src/test/results/clientpositive"); + setLogDir("itests/qtest/target/qfile-results/clientpositive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.mr); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class MiniTezCliConfig extends AbstractCliConfig { + public MiniTezCliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + includesFrom(testConfigProps, "minitez.query.files"); + includesFrom(testConfigProps, "minitez.query.files.shared"); + + setResultsDir("ql/src/test/results/clientpositive/tez"); + setLogDir("itests/qtest/target/qfile-results/clientpositive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir("data/conf/tez"); + setClusterType(MiniClusterType.tez); + setMetastoreType(MetastoreType.hbase); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class MiniLlapCliConfig extends AbstractCliConfig { + public MiniLlapCliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + includesFrom(testConfigProps, "minillap.query.files"); + includesFrom(testConfigProps, "minillap.shared.query.files"); + + setResultsDir("ql/src/test/results/clientpositive/llap"); + setLogDir("itests/qtest/target/qfile-results/clientpositive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir("data/conf/llap"); + setClusterType(MiniClusterType.llap); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class EncryptedHDFSCliConfig extends AbstractCliConfig { + public EncryptedHDFSCliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + includesFrom(testConfigProps, "encrypted.query.files"); + + setResultsDir("ql/src/test/results/clientpositive/encrypted"); + setLogDir("itests/qtest/target/qfile-results/clientpositive"); + + setInitScript("q_test_init_for_encryption.sql"); + setCleanupScript("q_test_cleanup_for_encryption.sql"); + + setHiveConfDir("data/conf"); + setClusterType(MiniClusterType.encrypted); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class ContribCliConfig extends AbstractCliConfig { + public ContribCliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("contrib/src/test/queries/clientpositive"); + + setResultsDir("contrib/src/test/results/clientpositive"); + setLogDir("itests/qtest/target/qfile-results/contribclientpositive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class PerfCliConfig extends AbstractCliConfig { + public PerfCliConfig() { + super(CorePerfCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive/perf"); + + excludesFrom(testConfigProps, "minimr.query.files"); + excludesFrom(testConfigProps, "minitez.query.files"); + excludesFrom(testConfigProps, "encrypted.query.files"); + + setResultsDir("ql/src/test/results/clientpositive/perf/"); + setLogDir("itests/qtest/target/qfile-results/clientpositive/"); + + setInitScript("q_perf_test_init.sql"); + setCleanupScript("q_perf_test_cleanup.sql"); + + setHiveConfDir("data/conf/perf-reg/"); + setClusterType(MiniClusterType.tez); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class CompareCliConfig extends AbstractCliConfig { + public CompareCliConfig() { + super(CoreCompareCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientcompare"); + + setResultsDir("ql/src/test/results/clientcompare"); + setLogDir("itests/qtest/target/qfile-results/clientcompare"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class NegativeCliConfig extends AbstractCliConfig { + public NegativeCliConfig() { + super(CoreNegativeCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientnegative"); + + excludesFrom(testConfigProps, "minimr.query.negative.files"); + excludeQuery("authorization_uri_import.q"); + + setResultsDir("ql/src/test/results/clientnegative"); + setLogDir("itests/qtest/target/qfile-results/clientnegative"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class NegativeMinimrCli extends AbstractCliConfig { + public NegativeMinimrCli() { + super(CoreNegativeCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientnegative"); + + includesFrom(testConfigProps, "minimr.query.negative.files"); + + setResultsDir("ql/src/test/results/clientnegative"); + setLogDir("itests/qtest/target/qfile-results/clientnegative"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.mr); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class HBaseCliConfig extends AbstractCliConfig { + public HBaseCliConfig() { + super(CoreHBaseCliDriver.class); + try { + setQueryDir("hbase-handler/src/test/queries/positive"); + + setResultsDir("hbase-handler/src/test/results/positive"); + setLogDir("itests/qtest/target/qfile-results/hbase-handler/positive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class HBaseMinimrCliConfig extends AbstractCliConfig { + public HBaseMinimrCliConfig() { + super(CoreHBaseCliDriver.class); + try { + setQueryDir("hbase-handler/src/test/queries/positive"); + // XXX: i think this was non intentionally set to run only hbase_bulk.m??? + // includeQuery("hbase_bulk.m"); => will be filter out because not ends with .q + // to keep existing behaviour i added this method + overrideUserQueryFile("hbase_bulk.m"); + + setResultsDir("hbase-handler/src/test/results/positive"); + setLogDir("itests/qtest/target/qfile-results/hbase-handler/minimrpositive"); + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + setHiveConfDir(""); + setClusterType(MiniClusterType.mr); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class DummyConfig extends AbstractCliConfig { + public DummyConfig() { + super(CoreDummy.class); + try { + setQueryDir("ql/src/test/queries/clientcompare"); + + setResultsDir("ql/src/test/results/clientcompare"); + setLogDir("itests/qtest/target/qfile-results/clientcompare"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class HBaseNegativeCliConfig extends AbstractCliConfig { + public HBaseNegativeCliConfig() { + super(CoreHBaseNegativeCliDriver.class); + try { + setQueryDir("hbase-handler/src/test/queries/negative"); + + setResultsDir("hbase-handler/src/test/results/negative"); + setLogDir("itests/qtest/target/qfile-results/hbase-handler/negative"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class ContribNegativeCliConfig extends AbstractCliConfig { + public ContribNegativeCliConfig() { + super(CoreNegativeCliDriver.class); + try { + setQueryDir("contrib/src/test/queries/clientnegative"); + + setResultsDir("contrib/src/test/results/clientnegative"); + setLogDir("itests/qtest/target/qfile-results/contribclientnegative"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class BeeLineConfig extends AbstractCliConfig { + public BeeLineConfig() { + // FIXME: beeline is disabled... + super(null); + // super(CoreBeeLineDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + excludesFrom(testConfigProps, "beeline.positive.exclude"); + + setResultsDir("ql/src/test/results/clientpositive"); + setLogDir("itests/qtest/target/qfile-results/beelinepositive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + // XXX: pending merge of ACC ; and upgrade of executor + public static class AccumuloCliConfig extends AbstractCliConfig { + public AccumuloCliConfig() { + super(null); + // super(CoreAccumuloCliDriver.class); + try { + setQueryDir("accumulo-handler/src/test/queries/positive"); + + excludesFrom(testConfigProps, "beeline.positive.exclude"); + + setResultsDir("accumulo-handler/src/test/results/positive"); + setLogDir("itests/qtest/target/qfile-results/accumulo-handler/positive"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir(""); + setClusterType(MiniClusterType.none); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class SparkCliConfig extends AbstractCliConfig { + public SparkCliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + includesFrom(testConfigProps, "spark.query.files"); + + setResultsDir("ql/src/test/results/clientpositive/spark"); + setLogDir("itests/qtest-spark/target/qfile-results/clientpositive/spark"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir("data/conf/spark/standalone"); + setClusterType(MiniClusterType.spark); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class SparkOnYarnCliConfig extends AbstractCliConfig { + public SparkOnYarnCliConfig() { + super(CoreCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientpositive"); + + includesFrom(testConfigProps, "miniSparkOnYarn.query.files"); + + setResultsDir("ql/src/test/results/clientpositive/spark"); + setLogDir("itests/qtest-spark/target/qfile-results/clientpositive/spark"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir("data/conf/spark/yarn-client"); + setClusterType(MiniClusterType.miniSparkOnYarn); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } + + public static class SparkNegativeCliConfig extends AbstractCliConfig { + public SparkNegativeCliConfig() { + super(CoreNegativeCliDriver.class); + try { + setQueryDir("ql/src/test/queries/clientnegative"); + + includesFrom(testConfigProps, "spark.query.negative.files"); + + setResultsDir("ql/src/test/results/clientnegative/spark"); + setLogDir("itests/qtest-spark/target/qfile-results/clientnegative/spark"); + + setInitScript("q_test_init.sql"); + setCleanupScript("q_test_cleanup.sql"); + + setHiveConfDir("data/conf/spark/standalone"); + setClusterType(MiniClusterType.spark); + } catch (Exception e) { + throw new RuntimeException("can't construct cliconfig", e); + } + } + } +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreBeeLineDriver.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreBeeLineDriver.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreBeeLineDriver.java new file mode 100644 index 0000000..e5144e3 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreBeeLineDriver.java @@ -0,0 +1,171 @@ +/** + * 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; +//beeline is excluded by default +//AFAIK contains broken tests +//and produces compile errors...i'll comment out this whole class for now... +/* + +import static org.junit.Assert.fail; +import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.*; + +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.ql.QTestUtil; +import org.apache.hive.beeline.util.QFileClient; +import org.apache.hive.service.server.HiveServer2; +import org.junit.AfterClass; +import org.junit.BeforeClass; +// HIVE-14444: i've dropped this: @RunWith(ConcurrentTestRunner.class) +public class CoreBeeLineDriver extends CliAdapter { + private final String hiveRootDirectory = AbstractCliConfig.HIVE_ROOT; + private final String queryDirectory; + private final String logDirectory; + private final String resultsDirectory; + private boolean overwrite = false; + private static String scratchDirectory; + private static QTestUtil.QTestSetup miniZKCluster = null; + + private static HiveServer2 hiveServer2; + + public CoreBeeLineDriver(AbstractCliConfig testCliConfig) { + super(testCliConfig); + queryDirectory = testCliConfig.getQueryDirectory(); + logDirectory = testCliConfig.getLogDir(); + resultsDirectory = testCliConfig.getResultsDir(); + } + + @Override + @BeforeClass + public void beforeClass() throws Exception { + HiveConf hiveConf = new HiveConf(); + hiveConf.logVars(System.err); + System.err.flush(); + + scratchDirectory = hiveConf.getVar(SCRATCHDIR); + + String testOutputOverwrite = System.getProperty("test.output.overwrite"); + if (testOutputOverwrite != null && "true".equalsIgnoreCase(testOutputOverwrite)) { + overwrite = true; + } + + miniZKCluster = new QTestUtil.QTestSetup(); + miniZKCluster.preTest(hiveConf); + + System.setProperty("hive.zookeeper.quorum", + hiveConf.get("hive.zookeeper.quorum")); + System.setProperty("hive.zookeeper.client.port", + hiveConf.get("hive.zookeeper.client.port")); + + String disableserver = System.getProperty("test.service.disable.server"); + if (null != disableserver && disableserver.equalsIgnoreCase("true")) { + System.err.println("test.service.disable.server=true " + + "Skipping HiveServer2 initialization!"); + return; + } + + hiveServer2 = new HiveServer2(); + hiveServer2.init(hiveConf); + System.err.println("Starting HiveServer2..."); + hiveServer2.start(); + Thread.sleep(5000); + } + + + @Override + @AfterClass + public void shutdown() { + try { + if (hiveServer2 != null) { + System.err.println("Stopping HiveServer2..."); + hiveServer2.stop(); + } + } catch (Throwable t) { + t.printStackTrace(); + } + + if (miniZKCluster != null) { + try { + miniZKCluster.tearDown(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public void runTest(String qFileName) throws Exception { + QFileClient qClient = new QFileClient(new HiveConf(), hiveRootDirectory, + queryDirectory, logDirectory, resultsDirectory) + .setQFileName(qFileName) + .setUsername("user") + .setPassword("password") + .setJdbcUrl("jdbc:hive2://localhost:10000") + .setJdbcDriver("org.apache.hive.jdbc.HiveDriver") + .setTestDataDirectory(hiveRootDirectory + "/data/files") + .setTestScriptDirectory(hiveRootDirectory + "/data/scripts"); + + long startTime = System.currentTimeMillis(); + System.err.println(">>> STARTED " + qFileName + + " (Thread " + Thread.currentThread().getName() + ")"); + try { + qClient.run(); + } catch (Exception e) { + System.err.println(">>> FAILED " + qFileName + " with exception:"); + e.printStackTrace(); + throw e; + } + long elapsedTime = (System.currentTimeMillis() - startTime)/1000; + String time = "(" + elapsedTime + "s)"; + + if (qClient.compareResults()) { + System.err.println(">>> PASSED " + qFileName + " " + time); + } else { + if (qClient.hasErrors()) { + System.err.println(">>> FAILED " + qFileName + " (ERROR) " + time); + fail(); + } + if (overwrite) { + System.err.println(">>> PASSED " + qFileName + " (OVERWRITE) " + time); + qClient.overwriteResults(); + } else { + System.err.println(">>> FAILED " + qFileName + " (DIFF) " + time); + fail(); + } + } + } + + @Override + public void setUp() { + // TODO Auto-generated method stub + + } + + @Override + public void tearDown() { + // TODO Auto-generated method stub + + } + + @Override + public void runTest(String name, String name2, String absolutePath) throws Exception { + runTest(name2); + } + +} + + +*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java new file mode 100644 index 0000000..5435f9f --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java @@ -0,0 +1,137 @@ +/** + * 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 static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.hadoop.hive.cli.control.AbstractCliConfig.MetastoreType; +import org.apache.hadoop.hive.ql.QTestUtil; +import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; + +public class CoreCliDriver extends CliAdapter { + + private static QTestUtil qt; + + public CoreCliDriver(AbstractCliConfig testCliConfig) { + super(testCliConfig); + } + + @Override + @BeforeClass + public void beforeClass() { + MiniClusterType miniMR =cliConfig.getClusterType(); + String hiveConfDir = cliConfig.getHiveConfDir(); + String initScript = cliConfig.getInitScript(); + String cleanupScript = cliConfig.getCleanupScript(); + boolean useHBaseMetastore = cliConfig.getMetastoreType() == MetastoreType.hbase; + try { + String hadoopVer = cliConfig.getHadoopVersion(); + qt = new QTestUtil((cliConfig.getResultsDir()), (cliConfig.getLogDir()), miniMR, + hiveConfDir, hadoopVer, initScript, cleanupScript, useHBaseMetastore, true); + + // do a one time initialization + qt.cleanUp(); + qt.createSources(); + + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + throw new RuntimeException("Unexpected exception in static initialization",e); + } + } + + @Override + @Before + public void setUp() { + try { + qt.clearTestSideEffects(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in setup"); + } + } + + @Override + @After + public void tearDown() { + try { + qt.clearPostTestEffects(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in tearDown"); + } + } + + @Override + @AfterClass + public void shutdown() throws Exception { + try { + qt.shutdown(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in shutdown"); + } + } + + static String debugHint = "\nSee ./ql/target/tmp/log/hive.log or ./itests/qtest/target/tmp/log/hive.log, " + + "or check ./ql/target/surefire-reports or ./itests/qtest/target/surefire-reports/ for specific test cases logs."; + + @Override + public void runTest(String tname, String fname, String fpath) throws Exception { + long startTime = System.currentTimeMillis(); + try { + System.err.println("Begin query: " + fname); + + qt.addFile(fpath); + + if (qt.shouldBeSkipped(fname)) { + System.err.println("Test " + fname + " skipped"); + return; + } + + qt.cliInit(fname, false); + int ecode = qt.executeClient(fname); + if (ecode != 0) { + qt.failed(ecode, fname, debugHint); + } + ecode = qt.checkCliDriverResults(fname); + if (ecode != 0) { + qt.failedDiff(ecode, fname, debugHint); + } + } + catch (Throwable e) { + qt.failed(e, fname, debugHint); + } + + long elapsedTime = System.currentTimeMillis() - startTime; + System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime/1000 + "s"); + assertTrue("Test passed", true); + } +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCompareCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCompareCliDriver.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCompareCliDriver.java new file mode 100644 index 0000000..71a02bc --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCompareCliDriver.java @@ -0,0 +1,158 @@ +/** + * 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 static org.junit.Assert.fail; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.hadoop.hive.ql.QTestUtil; +import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +public class CoreCompareCliDriver extends CliAdapter{ + + private static QTestUtil qt; + public CoreCompareCliDriver(AbstractCliConfig testCliConfig) { + super(testCliConfig); + } + + + @Override + @BeforeClass + public void beforeClass() { + + MiniClusterType miniMR = cliConfig.getClusterType(); + String hiveConfDir = cliConfig.getHiveConfDir(); + String initScript = cliConfig.getInitScript(); + String cleanupScript = cliConfig.getCleanupScript(); + try { + String hadoopVer = cliConfig.getHadoopVersion(); + qt = new QTestUtil(cliConfig.getResultsDir(), cliConfig.getLogDir(), miniMR, + hiveConfDir, hadoopVer, initScript, cleanupScript, false, false); + + // do a one time initialization + qt.cleanUp(); + qt.createSources(); + + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in static initialization"); + } + } + + @Override + @Before + public void setUp() { + try { + qt.clearTestSideEffects(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in setup"); + } + } + + @Override + @After + public void tearDown() { + try { + qt.clearPostTestEffects(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in tearDown"); + } + } + + @Override + @AfterClass + public void shutdown() throws Exception { + try { + qt.shutdown(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in shutdown"); + } + } + + private Map<String, List<String>> versionFiles = new HashMap<>(); + + static String debugHint = "\nSee ./ql/target/tmp/log/hive.log or ./itests/qtest/target/tmp/log/hive.log, " + + "or check ./ql/target/surefire-reports or ./itests/qtest/target/surefire-reports/ for specific test cases logs."; + + @Override + public void runTest(String tname, String fname, String fpath) throws Exception { + final String queryDirectory = cliConfig.getQueryDirectory(); + + long startTime = System.currentTimeMillis(); + try { + System.err.println("Begin query: " + fname); + // TODO: versions could also be picked at build time. + List<String> versionFiles = QTestUtil.getVersionFiles(queryDirectory, tname); + if (versionFiles.size() < 2) { + fail("Cannot run " + tname + " with only " + versionFiles.size() + " versions"); + } + + qt.addFile(fpath); + for (String versionFile : versionFiles) { + qt.addFile(new File(queryDirectory, versionFile), true); + } + + if (qt.shouldBeSkipped(fname)) { + return; + } + + int ecode = 0; + List<String> outputs = new ArrayList<>(versionFiles.size()); + for (String versionFile : versionFiles) { + // 1 for "_" after tname; 3 for ".qv" at the end. Version is in between. + String versionStr = versionFile.substring(tname.length() + 1, versionFile.length() - 3); + outputs.add(qt.cliInit(tname + "." + versionStr, false)); + // TODO: will this work? + ecode = qt.executeClient(versionFile, fname); + if (ecode != 0) { + qt.failed(ecode, fname, debugHint); + } + } + + ecode = qt.checkCompareCliDriverResults(fname, outputs); + if (ecode != 0) { + qt.failedDiff(ecode, fname, debugHint); + } + } + catch (Throwable e) { + qt.failed(e, fname, debugHint); + } + + long elapsedTime = System.currentTimeMillis() - startTime; + System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime/1000 + "s"); + } +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreDummy.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreDummy.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreDummy.java new file mode 100644 index 0000000..b7afb48 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreDummy.java @@ -0,0 +1,57 @@ +/** + * 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 static org.junit.Assert.fail; + +import java.util.List; + +import org.apache.hadoop.hive.ql.QTestUtil; + +public class CoreDummy extends CliAdapter { + + public CoreDummy(AbstractCliConfig cliConfig) { + super(cliConfig); + } + + @Override + public void beforeClass() { + } + + @Override + public void setUp() { + } + + @Override + public void tearDown() { + } + + @Override + public void shutdown() throws Exception { + } + + @Override + public void runTest(String name, String name2, String absolutePath) throws Exception { + List<String> versionFiles = QTestUtil.getVersionFiles(cliConfig.getQueryDirectory(), name); + if (versionFiles.size() < 2) { + fail("Cannot run " + name2 + " with only " + versionFiles.size() + " versions"); + } + fail("x"); + } + +} http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseCliDriver.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseCliDriver.java new file mode 100644 index 0000000..956a42d --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseCliDriver.java @@ -0,0 +1,137 @@ +/** + * 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 static org.apache.hadoop.hive.cli.control.AbstractCliConfig.HIVE_ROOT; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.hadoop.hive.hbase.HBaseQTestUtil; +import org.apache.hadoop.hive.hbase.HBaseTestSetup; +import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; + +public class CoreHBaseCliDriver extends CliAdapter { + + private HBaseQTestUtil qt; + private HBaseTestSetup setup = new HBaseTestSetup(); + + public CoreHBaseCliDriver(AbstractCliConfig testCliConfig) { + super(testCliConfig); + } + + @Override + @BeforeClass + public void beforeClass() { + MiniClusterType miniMR = cliConfig.getClusterType(); + String initScript = cliConfig.getInitScript(); + String cleanupScript =cliConfig.getCleanupScript(); + + try { + qt = new HBaseQTestUtil(cliConfig.getResultsDir(), cliConfig.getLogDir(), miniMR, + setup, initScript, cleanupScript); + qt.cleanUp(null); + qt.createSources(null); + + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in static initialization: "+e.getMessage()); + } + + } + + @Override + @Before + public void setUp() { + try { + qt.clearTestSideEffects(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in setup"); + } + } + @Override + @After + public void tearDown() { + try { + qt.clearPostTestEffects(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in tearDown"); + } + } + + @Override + @AfterClass + public void shutdown() throws Exception { + try { + // FIXME: there were 2 afterclass methods...i guess this is the right order...maybe not + qt.shutdown(); + setup.tearDown(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in shutdown"); + } + } + + @Override + public void runTest(String tname, String fname, String fpath) throws Exception { + long startTime = System.currentTimeMillis(); + try { + System.err.println("Begin query: " + fname); + + qt.addFile(fpath); + + if (qt.shouldBeSkipped(fname)) { + System.err.println("Test " + fname + " skipped"); + return; + } + + qt.cliInit(fname, false); + + int ecode = qt.executeClient(fname); + if (ecode != 0) { + qt.failed(ecode, fname, null); + } + + ecode = qt.checkCliDriverResults(fname); + if (ecode != 0) { + qt.failedDiff(ecode, fname, null); + } + + } catch (Throwable e) { + qt.failed(e, fname, null); + } + + long elapsedTime = System.currentTimeMillis() - startTime; + System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime/1000 + "s"); + assertTrue("Test passed", true); + } +} + http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseNegativeCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseNegativeCliDriver.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseNegativeCliDriver.java new file mode 100644 index 0000000..6225180 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreHBaseNegativeCliDriver.java @@ -0,0 +1,121 @@ +/** + * 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 static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.hadoop.hive.hbase.HBaseQTestUtil; +import org.apache.hadoop.hive.hbase.HBaseTestSetup; +import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; + +public class CoreHBaseNegativeCliDriver extends CliAdapter { + + private HBaseQTestUtil qt; + private static HBaseTestSetup setup = new HBaseTestSetup(); + + public CoreHBaseNegativeCliDriver(AbstractCliConfig testCliConfig) { + super(testCliConfig); + } + + @Override + public void beforeClass() throws Exception { + } + + // hmm..this looks a bit wierd...setup boots qtestutil...this part used to be in beforeclass + @Override + @Before + public void setUp() { + + MiniClusterType miniMR = cliConfig.getClusterType(); + String initScript = cliConfig.getInitScript(); + String cleanupScript = cliConfig.getCleanupScript(); + + try { + qt = new HBaseQTestUtil(cliConfig.getResultsDir(), cliConfig.getLogDir(), miniMR, + setup, initScript, cleanupScript); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in setup"); + } + } + + @Override + @After + public void tearDown() { + try { + qt.shutdown(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in tearDown"); + } + } + + @Override + @AfterClass + public void shutdown() throws Exception { + // closeHBaseConnections + setup.tearDown(); + } + + @Override + public void runTest(String tname, String fname, String fpath) throws Exception { + long startTime = System.currentTimeMillis(); + try { + System.err.println("Begin query: " + fname); + + qt.addFile(fpath); + + if (qt.shouldBeSkipped(fname)) { + System.err.println("Test " + fname + " skipped"); + return; + } + + qt.cliInit(fname); + qt.clearTestSideEffects(); + int ecode = qt.executeClient(fname); + if (ecode == 0) { + qt.failed(fname, null); + } + + ecode = qt.checkCliDriverResults(fname); + if (ecode != 0) { + qt.failedDiff(ecode, fname, null); + } + qt.clearPostTestEffects(); + + } catch (Throwable e) { + qt.failed(e, fname, null); + } + + long elapsedTime = System.currentTimeMillis() - startTime; + System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime/1000 + "s"); + assertTrue("Test passed", true); + } + + +} + http://git-wip-us.apache.org/repos/asf/hive/blob/1f7e10c0/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreNegativeCliDriver.java ---------------------------------------------------------------------- diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreNegativeCliDriver.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreNegativeCliDriver.java new file mode 100644 index 0000000..65b2ce7 --- /dev/null +++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreNegativeCliDriver.java @@ -0,0 +1,139 @@ +/** + * 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 static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.hadoop.hive.ql.QTestUtil; +import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; + +public class CoreNegativeCliDriver extends CliAdapter{ + + private QTestUtil qt; + public CoreNegativeCliDriver(AbstractCliConfig testCliConfig) { + super(testCliConfig); + } + + @Override + public void beforeClass(){ + MiniClusterType miniMR = cliConfig.getClusterType(); + String hiveConfDir = cliConfig.getHiveConfDir(); + String initScript = cliConfig.getInitScript(); + String cleanupScript = cliConfig.getCleanupScript(); + + try { + String hadoopVer = cliConfig.getHadoopVersion(); + qt = new QTestUtil((cliConfig.getResultsDir()), (cliConfig.getLogDir()), miniMR, + hiveConfDir, hadoopVer, initScript, cleanupScript, false, false); + // do a one time initialization + qt.cleanUp(); + qt.createSources(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in static initialization"); + } + } + + @Override + @Before + public void setUp() { + try { + qt.clearTestSideEffects(); + } catch (Throwable e) { + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in setup"); + } + } + + @Override + @After + public void tearDown() { + try { + qt.clearPostTestEffects(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in tearDown"); + } + } + + @Override + @AfterClass + public void shutdown() throws Exception { + try { + qt.shutdown(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in shutdown"); + } + } + + /** + * Dummy last test. This is only meant to shutdown qt + */ + public void testNegativeCliDriver_shutdown() { + System.err.println ("Cleaning up " + "$className"); + } + + static String debugHint = "\nSee ./ql/target/tmp/log/hive.log or ./itests/qtest/target/tmp/log/hive.log, " + + "or check ./ql/target/surefire-reports or ./itests/qtest/target/surefire-reports/ for specific test cases logs."; + + + @Override + public void runTest(String tname, String fname, String fpath) throws Exception { + long startTime = System.currentTimeMillis(); + try { + System.err.println("Begin query: " + fname); + + qt.addFile(fpath); + + if (qt.shouldBeSkipped(fname)) { + System.err.println("Test " + fname + " skipped"); + return; + } + + qt.cliInit(fname, false); + int ecode = qt.executeClient(fname); + if (ecode == 0) { + qt.failed(fname, debugHint); + } + + ecode = qt.checkCliDriverResults(fname); + if (ecode != 0) { + qt.failedDiff(ecode, fname, debugHint); + } + } + catch (Throwable e) { + qt.failed(e, fname, debugHint); + } + + long elapsedTime = System.currentTimeMillis() - startTime; + System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime/1000 + "s"); + assertTrue("Test passed", true); + } +}