use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_override_tab_name_with_groovy_parser.
/**
* Checks that a dynamic Groovy parser can override package tab title.
*/
@Test
@WithPlugins("analysis-core@1.91")
public void should_override_tab_name_with_groovy_parser() {
String parserName = createParser(OVERRIDE_PARSER_SCRIPT);
FreeStyleJob job = createFreeStyleJob(RESOURCES + GROOVY_TWO_LINES_FILE_NAME, settings -> settings.addWorkspaceScanner(parserName, "**/" + GROOVY_TWO_LINES_FILE_NAME));
Build build = buildSuccessfulJob(job);
WarningsAction action = createJavaResultAction(build);
action.open();
assertThat(driver, hasContent("DEAD_A"));
assertThat(driver, hasContent("DEAD_B"));
assertThat(driver, hasContent("BEEF"));
assertThat(driver.getPageSource(), containsString("<div id=\"packages\">BEEFs</div>"));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_resolve_environment_variables.
/**
* Verifies that environment variables are expanded in the file name pattern.
*/
@Test
@Issue("JENKINS-34157")
@WithPlugins("envinject")
public void should_resolve_environment_variables() {
FreeStyleJob job = createFreeStyleJob(RESOURCES + "jenkins-32150", settings -> {
settings.addWorkspaceScanner(CLANG_ID, "${ENV_PREFIX}/${PARAMETER}");
settings.addWorkspaceScanner(JAVA_TITLE, "${BUILD_NUMBER}/nothing");
settings.addWorkspaceScanner(JAVA_DOC_ID, "${BUILD_NUMBER}_${Reference}\\ND4\\ReleaseTools\\Build\\Log\\warning.log");
});
job.configure();
new EnvInjectConfig.Environment(job).properties.sendKeys("ENV_PREFIX=**");
String parameter = "PARAMETER";
job.addParameter(StringParameter.class).setName(parameter);
String reference = "Reference";
job.addParameter(StringParameter.class).setName(reference);
job.save();
Node slave = createSlaveForJob(job);
Map<String, String> parameters = new HashMap<>();
parameters.put("slavename", slave.getName());
parameters.put(parameter, "compile-log.txt");
parameters.put(reference, "master");
Build build = job.startBuild(parameters).shouldSucceed();
assertThatActionExists(job, build, "LLVM/Clang Warnings");
build.open();
int count = 10;
assertThat(driver, hasContent(CLANG_TITLE + ": " + count));
assertThat(build.getConsole(), containsString("[WARNINGS] Parsing warnings in files '**/compile-log.txt' with parser Clang (LLVM based)"));
assertThat(build.getConsole(), containsRegexp("\\[WARNINGS\\] Parsing warnings in files '[\\d]+/nothing'"));
assertThat(build.getConsole(), containsRegexp("\\[WARNINGS\\] Parsing warnings in files '[\\d]+_master\\\\ND4\\\\ReleaseTools\\\\Build\\\\Log\\\\warning.log'"));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class WarningsPluginTest method should_scan_console_log_of_slave_build.
@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_console_log_of_slave_build() throws ExecutionException, InterruptedException {
DumbSlave dockerSlave = createDockerAgent();
FreeStyleJob job = prepareDockerSlave(dockerSlave);
job.configure();
job.copyResource(resource(RESOURCE_WARNING_MAIN_JAVA_PATH));
ShellBuildStep shellBuildStep = job.addBuildStep(ShellBuildStep.class);
shellBuildStep.command(CMD_WARNING_MAIN_JAVA_CONSOLE);
WarningsPublisher warningsPublisher = job.addPublisher(WarningsPublisher.class);
warningsPublisher.addConsoleScanner(JAVA_ID);
job.save();
Build build = job.startBuild().shouldSucceed();
assertThatActionExists(job, build, "Java Warnings");
WarningsAction action = createJavaResultAction(build);
assertThatWarningsCountInSummaryIs(action, 3);
String codeLine = action.getLinkedSourceFileText(AnalysisAction.Tab.DETAILS, "WarningMain.java", 10);
String[] codeLineArr = codeLine.trim().split("\\s+", 2);
assertThat("Warning should be at line", codeLineArr[0], is("10"));
assertThat("Assert failed comparing code line is", codeLineArr[1], is("text = (TextClass) text2;"));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method job_filters_status_failed_exclude_unmatched.
/**
* This test creates a job and runs a build which fails. Afterwards 4 new jobs get created as well as a listView.
* The job filter of the listView is set to not show jobs which build status is not 'FAILED'.
*/
@Test
@WithPlugins("view-job-filters")
public void job_filters_status_failed_exclude_unmatched() {
Job failedJob = createJobThatFails();
List<Job> jobs = createAmountOfJobs(4, true);
String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + " columns {\n" + " name()\n" + " }\n" + " jobs{\n" + " names('" + failedJob.name + "','" + jobs.get(0).name + "','" + jobs.get(1).name + "','" + jobs.get(2).name + "','" + jobs.get(3).name + "')\n" + " }\n" + " jobFilters {\n" + " status {\n" + " matchType(MatchType.EXCLUDE_UNMATCHED)\n" + " status(Status.FAILED)\n" + " }\n" + " }\n" + "}";
View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
assertThat(view, containsJob(failedJob));
assertThat(view, not(containsJob(jobs.get(0))));
assertThat(view, not(containsJob(jobs.get(1))));
assertThat(view, not(containsJob(jobs.get(2))));
assertThat(view, not(containsJob(jobs.get(3))));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method job_filters_regex_name_include_unmatched.
/**
* This test creates a listView and 4 jobs. The job filters are checking the name with a regex and
* jobs not matching the regex are included in the listView.
*/
@Test
@WithPlugins("view-job-filters")
public void job_filters_regex_name_include_unmatched() {
Job job1 = createJobWithName(EXAMPLE_DISABLED_NAME);
Job job2 = createJobWithName(EXAMPLE_ENABLED_NAME);
List<Job> jobs = createAmountOfJobs(2, false);
String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + " columns {\n" + " name()\n" + " }\n" + " jobFilters {\n" + " regex {\n" + " matchType(MatchType.INCLUDE_UNMATCHED)\n" + " matchValue(RegexMatchValue.NAME)\n" + " regex('" + LIST_VIEW_REGEX + "')\n" + " }\n" + " }\n" + "}";
View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
assertThat(view, not(containsJob(job1)));
assertThat(view, not(containsJob(job2)));
assertThat(view, containsJob(jobs.get(0)));
assertThat(view, containsJob(jobs.get(1)));
}
Aggregations