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);
}
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));
}
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);
}
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"));
}
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));
}
Aggregations