Search in sources :

Example 1 with QFileTestBatch

use of org.apache.hive.ptest.execution.conf.QFileTestBatch in project hive by apache.

the class ExecutionPhase method execute.

@Override
public void execute() throws Throwable {
    long start = System.currentTimeMillis();
    List<TestBatch> testBatches = Lists.newArrayList();
    for (TestBatch batch : testBatchSupplier.get()) {
        testBatches.add(batch);
        if (batch.isParallel()) {
            parallelWorkQueue.add(batch);
        } else {
            isolatedWorkQueue.add(batch);
        }
    }
    logger.info("ParallelWorkQueueSize={}, IsolatedWorkQueueSize={}", parallelWorkQueue.size(), isolatedWorkQueue.size());
    if (logger.isDebugEnabled()) {
        for (TestBatch testBatch : parallelWorkQueue) {
            logger.debug("PBatch: {}", testBatch);
        }
        for (TestBatch testBatch : isolatedWorkQueue) {
            logger.debug("IBatch: {}", testBatch);
        }
    }
    try {
        int expectedNumHosts = hostExecutors.size();
        initalizeHosts();
        do {
            replaceBadHosts(expectedNumHosts);
            List<ListenableFuture<Void>> results = Lists.newArrayList();
            for (HostExecutor hostExecutor : ImmutableList.copyOf(hostExecutors)) {
                results.add(hostExecutor.submitTests(parallelWorkQueue, isolatedWorkQueue, failedTestResults));
            }
            Futures.allAsList(results).get();
        } while (!(parallelWorkQueue.isEmpty() && isolatedWorkQueue.isEmpty()));
        for (TestBatch batch : testBatches) {
            File batchLogDir;
            if (failedTestResults.contains(batch)) {
                batchLogDir = new File(failedLogDir, batch.getName());
            } else {
                batchLogDir = new File(succeededLogDir, batch.getName());
            }
            JUnitReportParser parser = new JUnitReportParser(logger, batchLogDir);
            executedTests.addAll(parser.getAllExecutedTests());
            for (String failedTest : parser.getAllFailedTests()) {
                failedTests.add(failedTest + " (batchId=" + batch.getBatchId() + ")");
            }
            // if the TEST*.xml was not generated or was corrupt, let someone know
            if (parser.getTestClassesWithReportAvailable().size() < batch.getTestClasses().size()) {
                Set<String> expTestClasses = new HashSet<>(batch.getTestClasses());
                expTestClasses.removeAll(parser.getTestClassesWithReportAvailable());
                for (String testClass : expTestClasses) {
                    StringBuilder messageBuilder = new StringBuilder();
                    messageBuilder.append(testClass).append(" - did not produce a TEST-*.xml file (likely timed out)").append(" (batchId=").append(batch.getBatchId()).append(")");
                    if (batch instanceof QFileTestBatch) {
                        Collection<String> tests = ((QFileTestBatch) batch).getTests();
                        if (tests.size() != 0) {
                            messageBuilder.append("\n\t[");
                            messageBuilder.append(Joiner.on(",").join(tests));
                            messageBuilder.append("]");
                        }
                    }
                    failedTests.add(messageBuilder.toString());
                }
            }
        }
    } finally {
        long elapsed = System.currentTimeMillis() - start;
        logger.info("PERF: exec phase " + TimeUnit.MINUTES.convert(elapsed, TimeUnit.MILLISECONDS) + " minutes");
    }
}
Also used : TestBatch(org.apache.hive.ptest.execution.conf.TestBatch) QFileTestBatch(org.apache.hive.ptest.execution.conf.QFileTestBatch) QFileTestBatch(org.apache.hive.ptest.execution.conf.QFileTestBatch) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) File(java.io.File) HashSet(java.util.HashSet)

Example 2 with QFileTestBatch

use of org.apache.hive.ptest.execution.conf.QFileTestBatch in project hive by apache.

the class TestExecutionPhase method setupQFile.

private void setupQFile(boolean isParallel) throws Exception {
    testDir = Dirs.create(new File(baseDir, "test"));
    Assert.assertTrue(new File(testDir, QFILENAME).createNewFile());
    testBatch = new QFileTestBatch(new AtomicInteger(1), "testcase", DRIVER, "qfile", Sets.newHashSet(QFILENAME), isParallel, "testModule");
    testBatches = Collections.singletonList(testBatch);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QFileTestBatch(org.apache.hive.ptest.execution.conf.QFileTestBatch) File(java.io.File)

Aggregations

File (java.io.File)2 QFileTestBatch (org.apache.hive.ptest.execution.conf.QFileTestBatch)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 HashSet (java.util.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 TestBatch (org.apache.hive.ptest.execution.conf.TestBatch)1