Search in sources :

Example 1 with QTestProcessExecResult

use of org.apache.hadoop.hive.ql.QTestProcessExecResult 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 QTestProcessExecResult

use of org.apache.hadoop.hive.ql.QTestProcessExecResult in project hive by apache.

the class CoreHBaseCliDriver method runTest.

@Override
public void runTest(String tname, String fname, String fpath) {
    long startTime = System.currentTimeMillis();
    try {
        System.err.println("Begin query: " + fname);
        qt.setInputFile(fpath);
        qt.cliInit();
        try {
            qt.executeClient();
        } catch (CommandProcessorException e) {
            qt.failedQuery(e.getCause(), e.getResponseCode(), fname, null);
        }
        QTestProcessExecResult result = qt.checkCliDriverResults();
        if (result.getReturnCode() != 0) {
            qt.failedDiff(result.getReturnCode(), fname, result.getCapturedOutput());
        }
    } catch (Exception e) {
        qt.failedWithException(e, fname, null);
    }
    long elapsedTime = System.currentTimeMillis() - startTime;
    System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
    assertTrue("Test passed", true);
}
Also used : CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException)

Example 3 with QTestProcessExecResult

use of org.apache.hadoop.hive.ql.QTestProcessExecResult in project hive by apache.

the class CoreKuduCliDriver method runTest.

@Override
public void runTest(String tname, String fname, String fpath) {
    long startTime = System.currentTimeMillis();
    try {
        System.err.println("Begin query: " + fname);
        qt.setInputFile(fpath);
        qt.cliInit();
        try {
            qt.executeClient();
        } catch (CommandProcessorException e) {
            qt.failedQuery(e.getCause(), e.getResponseCode(), fname, null);
        }
        QTestProcessExecResult result = qt.checkCliDriverResults();
        if (result.getReturnCode() != 0) {
            qt.failedDiff(result.getReturnCode(), fname, result.getCapturedOutput());
        }
        qt.clearPostTestEffects();
    } catch (Exception e) {
        qt.failedWithException(e, fname, null);
    }
    long elapsedTime = System.currentTimeMillis() - startTime;
    System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
    assertTrue("Test passed", true);
}
Also used : CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException)

Example 4 with QTestProcessExecResult

use of org.apache.hadoop.hive.ql.QTestProcessExecResult in project hive by apache.

the class CoreAccumuloCliDriver method runTest.

@Override
public void runTest(String tname, String fname, String fpath) {
    long startTime = System.currentTimeMillis();
    try {
        System.err.println("Begin query: " + fname);
        qt.setInputFile(fpath);
        qt.cliInit();
        try {
            qt.executeClient();
        } catch (CommandProcessorException e) {
            qt.failedQuery(e.getCause(), e.getResponseCode(), fname, null);
        }
        QTestProcessExecResult result = qt.checkCliDriverResults();
        if (result.getReturnCode() != 0) {
            qt.failedDiff(result.getReturnCode(), fname, result.getCapturedOutput());
        }
        qt.clearPostTestEffects();
    } catch (AssumptionViolatedException e) {
        throw e;
    } catch (Exception e) {
        qt.failedWithException(e, fname, null);
    }
    long elapsedTime = System.currentTimeMillis() - startTime;
    System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
    assertTrue("Test passed", true);
}
Also used : CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException)

Example 5 with QTestProcessExecResult

use of org.apache.hadoop.hive.ql.QTestProcessExecResult in project hive by apache.

the class CoreCliDriver method runTest.

@Override
public void runTest(String testName, String fname, String fpath) {
    Stopwatch sw = Stopwatch.createStarted();
    boolean skipped = false;
    boolean failed = false;
    try {
        LOG.info("Begin query: " + fname);
        System.err.println("Begin query: " + fname);
        qt.setInputFile(fpath);
        qt.cliInit();
        try {
            qt.executeClient();
        } catch (CommandProcessorException e) {
            failed = true;
            qt.failedQuery(e.getCause(), e.getResponseCode(), fname, QTestUtil.DEBUG_HINT);
        }
        setupAdditionalPartialMasks();
        QTestProcessExecResult result = qt.checkCliDriverResults();
        resetAdditionalPartialMasks();
        if (result.getReturnCode() != 0) {
            failed = true;
            String message = Strings.isNullOrEmpty(result.getCapturedOutput()) ? QTestUtil.DEBUG_HINT : "\r\n" + result.getCapturedOutput();
            qt.failedDiff(result.getReturnCode(), fname, message);
        }
    } catch (AssumptionViolatedException e) {
        skipped = true;
        throw e;
    } catch (Exception e) {
        failed = true;
        qt.failedWithException(e, fname, QTestUtil.DEBUG_HINT);
    } finally {
        String message = "Done query " + fname + ". succeeded=" + !failed + ", skipped=" + skipped + ". ElapsedTime(ms)=" + sw.stop().elapsed(TimeUnit.MILLISECONDS);
        LOG.info(message);
        System.err.println(message);
    }
    assertTrue("Test passed", true);
}
Also used : CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) Stopwatch(com.google.common.base.Stopwatch) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException)

Aggregations

QTestProcessExecResult (org.apache.hadoop.hive.ql.QTestProcessExecResult)12 CommandProcessorException (org.apache.hadoop.hive.ql.processors.CommandProcessorException)9 AssumptionViolatedException (org.junit.internal.AssumptionViolatedException)4 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 QFileBeeLineClient (org.apache.hive.beeline.QFileBeeLineClient)2 Stopwatch (com.google.common.base.Stopwatch)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1