Search in sources :

Example 46 with Job

use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method should_create_just_one_job_if_two_with_same_name_are_declared.

/**
 * Tests whether a job exists once when two jobs with the same name are created
 * by JobDsl and the seed job is build.
 */
@Test
public void should_create_just_one_job_if_two_with_same_name_are_declared() {
    // Arrange
    String jobName = "MyJob";
    String jobDslScript = String.format("job('%s'); job('%s')", jobName, jobName);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    // Assert
    Job job = jenkins.jobs.get(Job.class, jobName);
    assertThat(job, pageObjectExists());
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 47 with Job

use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method should_run_two_concurrent_builds.

/**
 * Tests whether two builds are in progress at the same time of a new job with
 * concurrent build attribute created by JobDsl when the seed job is build and two
 * builds are triggered.
 */
@Test
public void should_run_two_concurrent_builds() {
    // Arrange
    String jobName = "MyJob";
    String jobDslScript = String.format("job('%s') { concurrentBuild(); steps { shell('sleep 10') } }", jobName);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    Job job = jenkins.jobs.get(Job.class, jobName);
    Build firstBuild = job.scheduleBuild().waitUntilStarted();
    Build secondBuild = job.scheduleBuild().waitUntilStarted();
    // Assert
    assertTrue(firstBuild.isInProgress());
    assertTrue(secondBuild.isInProgress());
    firstBuild.stop();
    secondBuild.stop();
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 48 with Job

use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_status_failed_exclude_matched.

/**
 * 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 'FAILED'.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_status_failed_exclude_matched() {
    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_MATCHED)\n" + "            status(Status.FAILED)\n" + "        }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, not(containsJob(failedJob)));
    assertThat(view, containsJob(jobs.get(0)));
    assertThat(view, containsJob(jobs.get(1)));
    assertThat(view, containsJob(jobs.get(2)));
    assertThat(view, containsJob(jobs.get(3)));
}
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) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 49 with Job

use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method should_create_new_job.

/**
 * Tests whether a new job is created by JobDsl when the seed job is build.
 */
@Test
public void should_create_new_job() {
    // Arrange
    String jobName = "MyJob";
    String jobDslScript = String.format("job('%s')", jobName);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    // Assert
    Job job = jenkins.jobs.get(Job.class, jobName);
    assertThat(job, pageObjectExists());
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 50 with Job

use of org.jenkinsci.test.acceptance.po.Job in project acceptance-test-harness by jenkinsci.

the class GitPluginNoDockerTest method generateJobWithLocalBranch.

private Job generateJobWithLocalBranch(GIT_IMPL type) {
    Job job = generateJob(type);
    GitScm scm = generateSCM(job).localBranch("selenium_test_branch");
    useJGitIfNeccesary(type, scm);
    return job;
}
Also used : Job(org.jenkinsci.test.acceptance.po.Job) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm)

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