use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method createAmountOfJobs.
/**
* This method creates a given amount of jobs and returns them in a List.
* The caller can choose whether to build the jobs or not.
* @param amount amount to be created
* @param isBuilt flag if the jobs should be built
* @return List of Jobs
*/
private List<Job> createAmountOfJobs(int amount, boolean isBuilt) {
List<Job> jobs = new ArrayList<>();
for (int i = 0; i < amount; i++) {
Job job;
if (isBuilt) {
job = createJobAndBuild();
} else {
job = jenkins.jobs.create(FreeStyleJob.class);
}
jobs.add(job);
}
return jobs;
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method only_jobs_matching_regex_are_added.
/**
* Test if the created jobs are correctly added to the ListView using a regex.
*/
@Test
public void only_jobs_matching_regex_are_added() {
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" + " jobs {\n" + " regex('" + LIST_VIEW_REGEX + "')\n" + " }\n" + "}";
View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
assertThat(view, containsJob(job1));
assertThat(view, containsJob(job2));
assertThat(view, not(containsJob(jobs.get(0))));
assertThat(view, not(containsJob(jobs.get(1))));
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method createSeedJobWithJobDsl.
private Job createSeedJobWithJobDsl(String jobDsl) {
Job seed = jenkins.jobs.create(FreeStyleJob.class, "Seed");
JobDslBuildStep jobDslBuildStep = seed.addBuildStep(JobDslBuildStep.class);
jobDslBuildStep.setScript(jobDsl);
seed.save();
return seed;
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class GerritTriggerTest method build_is_triggered_after_comment_is_added.
@Test
public void build_is_triggered_after_comment_is_added() {
GerritTriggerNewServer newServer = new GerritTriggerNewServer(jenkins);
newServer.saveNewTestServerConfigIfNone(gtHostname);
GerritTriggerServer server = new GerritTriggerServer(jenkins, gtHostname);
server.saveTestServerConfig(gtHostname, gtGerritFrontUrl, gtGerrituser, gtPrivateKey);
Job j = jenkins.jobs.create(FreeStyleJob.class);
String jobName = j.name;
GerritTriggerJob job = new GerritTriggerJob(jenkins, jobName);
job.saveTestJobConfig(GerritTriggerJob.EventToTriggerOn.CommentAdded, gtHostname, gtProject);
try {
GitLogResult gitLogResult = pushChangeForReview(jobName);
addComment(gitLogResult.commitId);
changes.add(gitLogResult.changeId);
Build b = new Build(j, j.getNextBuildNumber());
assertTrue(b.waitUntilFinished().isSuccess());
elasticSleep(10000);
ProcessBuilder gerritQuery = new ProcessBuilder("ssh", "-p", "29418", "-i", gtPrivateKey, gtGerrituser + "@" + gtHostname, "gerrit", "query", "change_id=" + gitLogResult.changeId, "--all-approvals", "--format JSON");
String json = removeLastLine(stringFrom(logProcessBuilderIssues(gerritQuery, "gerrit query")));
checkApprovalValueFromJSON(json, "Verified", 1);
checkApprovalValueFromJSON(json, "Code-Review", 1);
} catch (InterruptedException | IOException e) {
fail(e.getMessage());
}
}
use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.
the class GerritTriggerTest method build_is_triggered_after_ref_is_updated.
@Test
public void build_is_triggered_after_ref_is_updated() {
GerritTriggerNewServer newServer = new GerritTriggerNewServer(jenkins);
newServer.saveNewTestServerConfigIfNone(gtHostname);
GerritTriggerServer server = new GerritTriggerServer(jenkins, gtHostname);
server.saveTestServerConfig(gtHostname, gtGerritFrontUrl, gtGerrituser, gtPrivateKey);
Job j = jenkins.jobs.create(FreeStyleJob.class);
String jobName = j.name;
GerritTriggerJob job = new GerritTriggerJob(jenkins, jobName);
job.saveTestJobConfig(GerritTriggerJob.EventToTriggerOn.RefUpdated, gtHostname, gtProject);
try {
pushChangeToGerritNotForReview(jobName);
Build b = new Build(j, j.getNextBuildNumber());
assertTrue(b.waitUntilFinished().isSuccess());
elasticSleep(10000);
} catch (InterruptedException | IOException e) {
fail(e.getMessage());
}
}
Aggregations