Search in sources :

Example 6 with QTestProcessExecResult

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

the class CoreHBaseNegativeCliDriver 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();
            qt.failed(fname, null);
        } catch (CommandProcessorException e) {
        // this is the expected result
        }
        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 7 with QTestProcessExecResult

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

the class CorePerfCliDriver method runTest.

@Override
public void runTest(String name, String fname, String fpath) {
    long startTime = System.currentTimeMillis();
    try {
        LOG.info("Begin query: " + fname);
        qt.setInputFile(fpath);
        qt.cliInit();
        try {
            qt.executeClient();
        } catch (CommandProcessorException e) {
            qt.failedQuery(e.getCause(), e.getResponseCode(), fname, QTestUtil.DEBUG_HINT);
        }
        QTestProcessExecResult result = qt.checkCliDriverResults();
        if (result.getReturnCode() != 0) {
            String message = Strings.isNullOrEmpty(result.getCapturedOutput()) ? QTestUtil.DEBUG_HINT : "\r\n" + result.getCapturedOutput();
            qt.failedDiff(result.getReturnCode(), fname, message);
        }
    } catch (AssumptionViolatedException e) {
        throw e;
    } catch (Exception e) {
        qt.failedWithException(e, fname, QTestUtil.DEBUG_HINT);
    }
    long elapsedTime = System.currentTimeMillis() - startTime;
    LOG.info("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
}
Also used : CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) CommandProcessorException(org.apache.hadoop.hive.ql.processors.CommandProcessorException) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException)

Example 8 with QTestProcessExecResult

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

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

the class CoreCompareCliDriver method runTest.

@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(new File(queryDirectory, tname + "." + versionStr), false));
            // TODO: will this work?
            ecode = qt.executeClient(versionFile, fname);
            if (ecode != 0) {
                qt.failed(ecode, fname, debugHint);
            }
        }
        QTestProcessExecResult result = qt.checkCompareCliDriverResults(fname, outputs);
        if (result.getReturnCode() != 0) {
            String message = Strings.isNullOrEmpty(result.getCapturedOutput()) ? debugHint : "\r\n" + result.getCapturedOutput();
            qt.failedDiff(result.getReturnCode(), fname, message);
        }
    } catch (Exception e) {
        qt.failed(e, fname, debugHint);
    }
    long elapsedTime = System.currentTimeMillis() - startTime;
    System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
}
Also used : QTestProcessExecResult(org.apache.hadoop.hive.ql.QTestProcessExecResult) ArrayList(java.util.ArrayList) File(java.io.File)

Example 10 with QTestProcessExecResult

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

the class AbstractCoreBlobstoreCliDriver method runTestHelper.

protected void runTestHelper(String tname, String fname, String fpath, boolean expectSuccess) {
    long startTime = System.currentTimeMillis();
    qt.getConf().set(HCONF_TEST_BLOBSTORE_PATH_UNIQUE, testBlobstorePathUnique);
    try {
        System.err.println("Begin query: " + fname);
        qt.setInputFile(fpath);
        qt.cliInit();
        try {
            qt.executeClient();
            if (!expectSuccess) {
                qt.failedQuery(null, 0, fname, debugHint);
            }
        } catch (CommandProcessorException e) {
            if (expectSuccess) {
                qt.failedQuery(e.getCause(), e.getResponseCode(), fname, debugHint);
            }
        }
        QTestProcessExecResult result = qt.checkCliDriverResults();
        if (result.getReturnCode() != 0) {
            String message = Strings.isNullOrEmpty(result.getCapturedOutput()) ? debugHint : "\r\n" + result.getCapturedOutput();
            qt.failedDiff(result.getReturnCode(), fname, message);
        }
    } catch (Exception e) {
        qt.failedWithException(e, fname, debugHint);
    }
    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)

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