Search in sources :

Example 1 with QFileBeeLineClient

use of org.apache.hive.beeline.QFileBeeLineClient in project hive by apache.

the class CoreBeeLineDriver method runTest.

private void runTest(QFile qFile, List<Callable<Void>> preCommands) throws Exception {
    try (QFileBeeLineClient beeLineClient = clientBuilder.getClient(qFile.getLogFile())) {
        long startTime = System.currentTimeMillis();
        System.err.println(">>> STARTED " + qFile.getName());
        beeLineClient.execute(qFile, preCommands);
        long queryEndTime = System.currentTimeMillis();
        System.err.println(">>> EXECUTED " + qFile.getName() + ": " + (queryEndTime - startTime) + "ms");
        qFile.filterOutput();
        long filterEndTime = System.currentTimeMillis();
        System.err.println(">>> FILTERED " + qFile.getName() + ": " + (filterEndTime - queryEndTime) + "ms");
        if (!overwrite) {
            QTestProcessExecResult result = qFile.compareResults();
            long compareEndTime = System.currentTimeMillis();
            System.err.println(">>> COMPARED " + qFile.getName() + ": " + (compareEndTime - filterEndTime) + "ms");
            if (result.getReturnCode() == 0) {
                System.err.println(">>> PASSED " + qFile.getName());
            } else {
                System.err.println(">>> FAILED " + qFile.getName());
                String messageText = "Client result comparison failed with error code = " + result.getReturnCode() + " while executing fname=" + qFile.getName() + "\n";
                String messageBody = Strings.isNullOrEmpty(result.getCapturedOutput()) ? qFile.getDebugHint() : result.getCapturedOutput();
                fail(messageText + messageBody);
            }
        } else {
            qFile.overwriteResults();
            System.err.println(">>> PASSED " + qFile.getName());
        }
    } catch (Exception e) {
        throw new Exception("Exception running or analyzing the results of the query file: " + qFile + "\n" + qFile.getDebugHint(), e);
    }
}
Also used : QFileBeeLineClient(org.apache.hive.beeline.QFileBeeLineClient) QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 2 with QFileBeeLineClient

use of org.apache.hive.beeline.QFileBeeLineClient in project hive by apache.

the class CoreBeeLineDriver method runTest.

public void runTest(QFile qFile) throws Exception {
    try (QFileBeeLineClient beeLineClient = clientBuilder.getClient(qFile.getLogFile())) {
        long startTime = System.currentTimeMillis();
        System.err.println(">>> STARTED " + qFile.getName());
        beeLineClient.execute(qFile);
        long queryEndTime = System.currentTimeMillis();
        System.err.println(">>> EXECUTED " + qFile.getName() + ": " + (queryEndTime - startTime) + "ms");
        qFile.filterOutput();
        long filterEndTime = System.currentTimeMillis();
        System.err.println(">>> FILTERED " + qFile.getName() + ": " + (filterEndTime - queryEndTime) + "ms");
        if (!overwrite) {
            QTestProcessExecResult result = qFile.compareResults();
            long compareEndTime = System.currentTimeMillis();
            System.err.println(">>> COMPARED " + qFile.getName() + ": " + (compareEndTime - filterEndTime) + "ms");
            if (result.getReturnCode() == 0) {
                System.err.println(">>> PASSED " + qFile.getName());
            } else {
                System.err.println(">>> FAILED " + qFile.getName());
                String messageText = "Client result comparison failed with error code = " + result.getReturnCode() + " while executing fname=" + qFile.getName() + "\n";
                String messageBody = Strings.isNullOrEmpty(result.getCapturedOutput()) ? qFile.getDebugHint() : result.getCapturedOutput();
                fail(messageText + messageBody);
            }
        } else {
            qFile.overwriteResults();
            System.err.println(">>> PASSED " + qFile.getName());
        }
    } catch (Exception e) {
        throw new Exception("Exception running or analyzing the results of the query file: " + qFile + "\n" + qFile.getDebugHint(), e);
    }
}
Also used : QFileBeeLineClient(org.apache.hive.beeline.QFileBeeLineClient) QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) IOException(java.io.IOException) SQLException(java.sql.SQLException)

Example 3 with QFileBeeLineClient

use of org.apache.hive.beeline.QFileBeeLineClient in project hive by apache.

the class CoreBeeLineDriver method runInfraScript.

protected void runInfraScript(String[] commands, File beeLineOutput, File log) throws IOException, SQLException {
    try (QFileBeeLineClient beeLineClient = clientBuilder.getClient(beeLineOutput)) {
        String[] preCommands = new String[] { "set hive.exec.pre.hooks=" + PreExecutePrinter.class.getName() + ";", "set test.data.dir=" + testDataDirectory + ";", "set test.script.dir=" + testScriptDirectory + ";" };
        String[] allCommands = Stream.concat(Arrays.stream(preCommands), Arrays.stream(commands)).toArray(String[]::new);
        beeLineClient.execute(allCommands, log, Converter.NONE);
    } catch (Exception e) {
        throw new SQLException("Error running infra commands, " + "\nCheck the following logs for details:\n - " + beeLineOutput + "\n - " + log, e);
    }
}
Also used : QFileBeeLineClient(org.apache.hive.beeline.QFileBeeLineClient) SQLException(java.sql.SQLException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 QFileBeeLineClient (org.apache.hive.beeline.QFileBeeLineClient)3 QTestProcessExecResult (org.apache.hadoop.hive.ql.QTestProcessExecResult)2