Search in sources :

Example 1 with FailureDiagnostics

use of org.jenkinsci.test.acceptance.junit.FailureDiagnostics in project acceptance-test-harness by jenkinsci.

the class LocalController method diagnose.

@Override
public void diagnose(Throwable cause) {
    if (cause instanceof TimeoutException) {
        FailureDiagnostics diagnostics = injector.getInstance(FailureDiagnostics.class);
        String td = getThreaddump();
        if (td != null) {
            diagnostics.write("threaddump.log", td);
        }
    }
    if (getenv("INTERACTIVE") != null && getenv("INTERACTIVE").equals("true")) {
        if (cause instanceof MultipleFailureException) {
            System.out.println("Multiple exceptions occurred:");
            for (Throwable c : ((MultipleFailureException) cause).getFailures()) {
                out.println();
                c.printStackTrace(out);
                out.println();
            }
        } else {
            cause.printStackTrace(out);
        }
        out.println("Commencing interactive debugging. Browser session was kept open.");
        synchronized (this) {
            try {
                this.wait();
            } catch (InterruptedException e) {
                return;
            }
        }
    }
}
Also used : MultipleFailureException(org.junit.runners.model.MultipleFailureException) FailureDiagnostics(org.jenkinsci.test.acceptance.junit.FailureDiagnostics) TimeoutException(org.openqa.selenium.TimeoutException)

Example 2 with FailureDiagnostics

use of org.jenkinsci.test.acceptance.junit.FailureDiagnostics in project acceptance-test-harness by jenkinsci.

the class LocalController method diagnoseFailedLoad.

private void diagnoseFailedLoad(Exception cause) throws IOException {
    String td = getThreaddump();
    if (td != null) {
        IOException ex = new IOException(cause.getMessage() + "\n\n" + td);
        ex.setStackTrace(cause.getStackTrace());
        cause = ex;
    }
    // Copy log to diagnostics
    FailureDiagnostics diagnostics = injector.getInstance(FailureDiagnostics.class);
    File log = diagnostics.touch("jenkins.log");
    Files.copy(logFile.toPath(), log.toPath(), StandardCopyOption.REPLACE_EXISTING);
    throw (cause instanceof IOException) ? (IOException) cause : new IOException("Jenkins failed to load", cause);
}
Also used : FailureDiagnostics(org.jenkinsci.test.acceptance.junit.FailureDiagnostics) IOException(java.io.IOException) File(java.io.File)

Aggregations

FailureDiagnostics (org.jenkinsci.test.acceptance.junit.FailureDiagnostics)2 File (java.io.File)1 IOException (java.io.IOException)1 MultipleFailureException (org.junit.runners.model.MultipleFailureException)1 TimeoutException (org.openqa.selenium.TimeoutException)1