Search in sources :

Example 1 with LogParserPublisher

use of org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher in project acceptance-test-harness by jenkinsci.

the class LogParserTest method checkMarkedFailedAndUnstable.

/**
 * Test case:
 * Check for a build to be marked as failed and another build to be marked as unstable.
 */
@Test
public void checkMarkedFailedAndUnstable() {
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "simple-job");
    job.configure(() -> {
        job.addShellStep("echo marked as error");
        LogParserPublisher lpp = job.addPublisher(LogParserPublisher.class);
        lpp.setMarkOnBuildFail(true);
        lpp.setRule(resource("/logparser_plugin/rules/log-parser-rule-markings"));
    });
    job.startBuild().waitUntilFinished().shouldFail();
    job.configure(() -> {
        job.addShellStep("echo marked as warning");
        LogParserPublisher lpp = job.getPublisher(LogParserPublisher.class);
        lpp.setMarkOnBuildFail(false);
        lpp.setMarkOnUnstableWarning(true);
    });
    job.startBuild().waitUntilFinished().shouldBeUnstable();
}
Also used : LogParserPublisher(org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 2 with LogParserPublisher

use of org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher in project acceptance-test-harness by jenkinsci.

the class LogParserTest method invalidRulePath.

/**
 * Test information for failed log parsing.
 */
@Test
public void invalidRulePath() {
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "fail-job");
    // configure invalid route
    job.configure(() -> {
        LogParserPublisher lpp = job.addPublisher(LogParserPublisher.class);
        lpp.setRule(LogParserPublisher.RuleType.PROJECT, "invalidPath");
    });
    Build build = job.startBuild().waitUntilFinished();
    // check information on build overview
    build.open();
    WebElement tableRow = find(By.xpath(SUMMARY_XPATH));
    WebElement logParserSummary = findLogParserSummary(tableRow);
    WebElement icon = logParserSummary.findElement(By.xpath("td[1]/img"));
    assertThat(icon.getAttribute("src"), containsString("graph"));
    WebElement text = logParserSummary.findElement(By.xpath("td[2]"));
    assertThat(text.getText(), is("Log parsing has failed"));
    LogParserOutputPage outputPage = new LogParserOutputPage(build);
    outputPage.open();
    WebElement output = find(By.id("main-panel"));
    assertThat(output.getText(), containsString("ERROR: Failed to parse console log"));
}
Also used : LogParserOutputPage(org.jenkinsci.test.acceptance.plugins.logparser.LogParserOutputPage) LogParserPublisher(org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher) WebElement(org.openqa.selenium.WebElement) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 3 with LogParserPublisher

use of org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher in project acceptance-test-harness by jenkinsci.

the class LogParserTest method configureSampleJob.

private Job configureSampleJob() {
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "sampleJob");
    // configure job
    job.configure(() -> {
        LogParserPublisher lpp = job.addPublisher(LogParserPublisher.class);
        lpp.setRule(LogParserPublisher.RuleType.GLOBAL, parserRules.get("sampleRule"));
        // write sample output
        Resource sampleRule = resource("/logparser_plugin/console-outputs/sample-log");
        catToConsole(job, sampleRule.url.getPath());
    });
    return job;
}
Also used : LogParserPublisher(org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher) Resource(org.jenkinsci.test.acceptance.junit.Resource)

Example 4 with LogParserPublisher

use of org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher in project acceptance-test-harness by jenkinsci.

the class LogParserTest method trendVisible.

/**
 * Check whether trend is visible
 */
@Test
public void trendVisible() {
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "simple-job");
    job.configure(() -> {
        // sample use of the LogParserPublisher
        LogParserPublisher lpp = job.addPublisher(LogParserPublisher.class);
        lpp.setShowGraphs(true);
        lpp.setRule(LogParserPublisher.RuleType.GLOBAL, parserRules.get("sampleRule"));
    });
    // Trend is shown after second build
    job.startBuild().waitUntilFinished();
    job.startBuild().waitUntilFinished();
    // Check trend is visible
    job.open();
    WebElement trend = find(By.className("test-trend-caption"));
    assertThat(trend.getText(), containsString("Log Parser Trend"));
    WebElement img = find(By.xpath("//img[@src='logparser/trend']"));
    assertThat(img.getAttribute("alt"), containsString("[Log Parser Chart]"));
}
Also used : LogParserPublisher(org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher) WebElement(org.openqa.selenium.WebElement) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

LogParserPublisher (org.jenkinsci.test.acceptance.plugins.logparser.LogParserPublisher)4 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)3 Test (org.junit.Test)3 WebElement (org.openqa.selenium.WebElement)2 Resource (org.jenkinsci.test.acceptance.junit.Resource)1 LogParserOutputPage (org.jenkinsci.test.acceptance.plugins.logparser.LogParserOutputPage)1