Search in sources :

Example 21 with WorkflowJob

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

the class ExternalWorkspaceManagerPluginTest method shareWorkspaceOneJobTwoNodes.

@Test
public void shareWorkspaceOneJobTwoNodes() {
    WorkflowJob job = createWorkflowJob(String.format("def extWorkspace = exwsAllocate '%s' \n" + "node ('linux') { \n" + "   exws (extWorkspace) { \n" + "      writeFile file: 'marker', text: 'content' \n" + "   } \n" + "} \n" + "node ('test') { \n" + "   exws (extWorkspace) { \n" + "       def content = readFile(file: 'marker') \n" + "       if (content != 'content') error('Content mismatch: ' + content) \n" + "   } \n" + "}", DISK_POOL_ID));
    Build build = job.startBuild();
    build.shouldSucceed();
    assertThat(build.getConsole(), containsString(String.format("Running in %s/%s/%s", fakeNodeMountingPoint, job.name, build.getNumber())));
    verifyExternalWorkspacesAction(job.name, build);
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 22 with WorkflowJob

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

the class ExternalWorkspaceManagerPluginTest method externalWorkspaceCleanup.

@Test
public void externalWorkspaceCleanup() {
    WorkflowJob job = createWorkflowJob(String.format("" + "def extWorkspace = exwsAllocate '%s' \n" + "node ('linux') { \n" + "	exws (extWorkspace) { \n" + "		try { \n" + "           writeFile file: 'foobar.txt', text: 'any' \n" + "		} finally { \n" + "			step ([$class: 'WsCleanup']) \n" + "		} \n" + "	} \n" + "}", DISK_POOL_ID));
    Build build = job.startBuild();
    build.shouldSucceed();
    String console = build.getConsole();
    assertThat(console, containsString(String.format("Running in %s/%s/%s", fakeNodeMountingPoint, job.name, build.getNumber())));
    assertThat(console, containsString("[WS-CLEANUP] Deleting project workspace"));
    assertThat(console, containsString("[WS-CLEANUP] done"));
    assertThat(listFiles(tmp.getRoot(), nameFileFilter("foobar.txt"), directoryFileFilter()), hasSize(0));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) StringContains.containsString(org.hamcrest.core.StringContains.containsString) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 23 with WorkflowJob

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

the class ExternalWorkspaceManagerPluginTest method shareWorkspaceTwoJobsTwoNodes.

@Test
public void shareWorkspaceTwoJobsTwoNodes() {
    WorkflowJob upstreamJob = createWorkflowJob(String.format("def extWorkspace = exwsAllocate '%s' \n" + "node ('linux') { \n" + "   exws (extWorkspace) { \n" + "      writeFile file: 'marker', text: 'content' \n " + "   } \n" + "}", DISK_POOL_ID));
    Build upstreamBuild = upstreamJob.startBuild();
    upstreamBuild.shouldSucceed();
    assertThat(upstreamBuild.getConsole(), containsString(String.format("Running in %s/%s/%s", fakeNodeMountingPoint, upstreamJob.name, upstreamBuild.getNumber())));
    verifyExternalWorkspacesAction(upstreamJob.name, upstreamBuild);
    WorkflowJob downstreamJob = createWorkflowJob(String.format("" + "def run = selectRun '%s' \n" + "def extWorkspace = exwsAllocate selectedRun: run \n" + "node ('test') { \n" + "   exws (extWorkspace) { \n" + "       def content = readFile(file: 'marker') \n" + "       if (content != 'content') error('Content mismatch: ' + content) \n" + "   } \n" + "}", upstreamJob.name));
    Build downstreamBuild = downstreamJob.startBuild();
    downstreamBuild.shouldSucceed();
    assertThat(downstreamBuild.getConsole(), containsString(String.format("Running in %s/%s/%s", fakeNodeMountingPoint, upstreamJob.name, upstreamBuild.getNumber())));
    verifyExternalWorkspacesAction(upstreamJob.name, downstreamBuild);
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 24 with WorkflowJob

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

the class StageViewTest method stageViewContainsMultipleStagesWithFail.

/**
 * Does check multiple jobs in the stage view. One with a failed, and one with a success.
 */
@Test
public void stageViewContainsMultipleStagesWithFail() {
    WorkflowJob job = this.createPipelineFromFile(MUTLI_JOB_FAIL);
    job.startBuild().shouldFail();
    job.open();
    job.getNavigationLinks();
    StageView stageView = new StageView(job, JOB_PATH);
    String firstJob = stageView.getLatestBuild().getStageViewItem(0).toString();
    String secondJob = stageView.getLatestBuild().getStageViewItem(1).toString();
    assertThat(stageView.getLatestBuild().getCssClasses(), containsString("FAILED"));
    assertThat(firstJob, containsString("ms"));
    assertThat(secondJob, containsString("failed"));
}
Also used : WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) StageView(org.jenkinsci.test.acceptance.plugins.stageview.StageView) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 25 with WorkflowJob

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

the class StageViewTest method multiBuildJobShouldContainCorrectNumberOfJobsHeadline.

/**
 * This tests verfies the width of the display. Stageviews have to adapt
 * to new stages with future builds.
 */
@Test
@WithPlugins("pipeline-stage-view@2.18")
public void multiBuildJobShouldContainCorrectNumberOfJobsHeadline() {
    WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
    String pre = "node {\n";
    String post = "}";
    String singleStage = "stage ('Clone sources'){\n" + "           echo 'cloned'\n" + "    }\n";
    job.script.set("");
    job.sandbox.check();
    job.save();
    Build build = job.startBuild().shouldSucceed();
    for (int i = 0; i < 10; i++) {
        String text = pre + repeatString(singleStage, i + 1) + post;
        job.configure(() -> job.script.set(text));
        build = job.startBuild().shouldSucceed();
    }
    assertThat(build, notNullValue());
    job.open();
    StageView stageView = new StageView(job, JOB_PATH);
    assertThat(stageView.getAllStageViewJobs(), hasSize(10));
    assertThat(stageView.getStageViewHeadlines(), hasSize(10));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) StageView(org.jenkinsci.test.acceptance.plugins.stageview.StageView) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)36 Test (org.junit.Test)24 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)21 Build (org.jenkinsci.test.acceptance.po.Build)19 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)14 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)8 StageView (org.jenkinsci.test.acceptance.plugins.stageview.StageView)8 Matchers.containsString (org.hamcrest.Matchers.containsString)4 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)4 Issue (org.jvnet.hudson.test.Issue)4 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)3 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)3 Category (org.junit.experimental.categories.Category)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Ignore (org.junit.Ignore)2 File (java.io.File)1 IOException (java.io.IOException)1 Pattern (java.util.regex.Pattern)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 LocalController (org.jenkinsci.test.acceptance.controller.LocalController)1