Search in sources :

Example 21 with Job

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;
}
Also used : ArrayList(java.util.ArrayList) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob)

Example 22 with Job

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))));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 23 with Job

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;
}
Also used : JobDslBuildStep(org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob)

Example 24 with Job

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());
    }
}
Also used : GerritTriggerNewServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer) GerritTriggerServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer) Build(org.jenkinsci.test.acceptance.po.Build) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) IOException(java.io.IOException) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 25 with Job

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());
    }
}
Also used : GerritTriggerNewServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer) GerritTriggerServer(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer) Build(org.jenkinsci.test.acceptance.po.Build) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) IOException(java.io.IOException) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GerritTriggerJob(org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

Job (org.jenkinsci.test.acceptance.po.Job)55 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)48 Test (org.junit.Test)45 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)37 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)22 ListView (org.jenkinsci.test.acceptance.po.ListView)21 View (org.jenkinsci.test.acceptance.po.View)18 Build (org.jenkinsci.test.acceptance.po.Build)13 WebElement (org.openqa.selenium.WebElement)7 IOException (java.io.IOException)5 GerritTriggerJob (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob)5 GerritTriggerNewServer (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer)5 GerritTriggerServer (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer)5 GitScm (org.jenkinsci.test.acceptance.plugins.git.GitScm)5 Since (org.jenkinsci.test.acceptance.junit.Since)4 AnalysisAction (org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisAction)4 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)4 Issue (org.jvnet.hudson.test.Issue)4 Arrays (java.util.Arrays)3