Skip to content
Permalink
Browse files

[JENKINS-37323] adding all known pipeline syntax as test case

  • Loading branch information...
scherler committed Sep 7, 2016
1 parent f73dda1 commit 5afc5f5bd8590828a1ba5fadf400233009752bc0
@@ -32,10 +32,14 @@ module.exports.commands = [{
this.waitForElementVisible('.activity-table tr#' + runName + ' svg.svgResultStatus');
this.waitForElementPresent('.activity-table tr#' + runName + ' svg circle.success');
},
waitForRunRunningVisible: function(runName) {
waitForRunRunningVisible: function(runName, callback) {
this.waitForElementVisible('.activity-table tr#' + runName);
this.waitForElementVisible('.activity-table tr#' + runName + ' svg.svgResultStatus');
this.waitForElementPresent('.activity-table tr#' + runName + ' svg path.running');
if (callback === undefined) {
this.waitForElementPresent('.activity-table tr#' + runName + ' svg path.running');
} else {
this.waitForElementPresent('.activity-table tr#' + runName + ' svg path.running', callback);
}
},
clickTab: function (browser, tab) {
var self = this;
@@ -1,37 +1,80 @@
const async = require("async");
const stringCleaner = function (string) {
return string.replace(/\r?\n|\r/g, '');
};
// using different syntax of the same pipeline
const cases = [{
name: 'stagesClassic',
script: 'stages-with-wait.groovy',
nodeId: '5',
},{
name: 'stagesBlock',
script: 'stages-with-wait-block-syntax.groovy',
nodeId: '6',
},{
name: 'stagesPM',
script: 'stages-with-wait-pipelineModel-syntax.groovy',
nodeId: '6',
},];
/*
Create a callback wrapper - we need to make sure that we have finished before
we use the callback. If we have an error we invoke with error.
@param callback, the callback we need to call
*/
const createCallbackWrapper = function (callback) {
return function callbackWrapper(status) {
if (status && status.state) {
callback(null, status);
} else {
callback(new Error(status))
}
};
};
module.exports = {
'Create Pipeline Job "stages"': function (browser) {
const pipelinesCreate = browser.page.pipelineCreate().navigate();
pipelinesCreate.createPipeline('stages', 'stages-with-wait.groovy');
// create the different jobs
async.mapSeries(cases, function (useCase, callback) {
console.log('creating pipeline job', useCase.name, useCase.script);
// navigate to the create page
const pipelinesCreate = browser.page.pipelineCreate().navigate();
pipelinesCreate
.createPipeline(useCase.name, useCase.script, createCallbackWrapper(callback))
;
});
},

'Build Pipeline Job': function (browser) {
const pipelinePage = browser.page.jobUtils().forJob('stages');
pipelinePage.buildStarted(function() {
// Reload the job page and check that there was a build done.
pipelinePage
.waitForElementVisible('div#pipeline-box')
.forRun(1)
.waitForElementVisible('@executer');
// we need to create a browser page outside the async loop
// const pipelinesCreate = browser.page.pipelineCreate().navigate();
async.mapSeries(cases, function (useCase, callback) {
const pipelinePage = browser.page.jobUtils().forJob(useCase.name);
pipelinePage.buildStarted(function() {
// Reload the job page and check that there was a build done.
pipelinePage
.waitForElementVisible('div#pipeline-box')
.forRun(1)
.waitForElementVisible('@executer', createCallbackWrapper(callback));
});
});
},

'Check Job Blue Ocean Pipeline Activity Page has run': function (browser) {
const blueActivityPage = browser.page.bluePipelineActivity().forJob('stages', 'jenkins');
// Check the run itself
blueActivityPage.waitForRunRunningVisible('stages-1');
async.mapSeries(cases, function (useCase, callback) {
const blueActivityPage = browser.page.bluePipelineActivity().forJob(useCase.name, 'jenkins');
// Check the run itself
blueActivityPage.waitForRunRunningVisible(useCase.name + '-1', createCallbackWrapper(callback));
});
},

'Check Job Blue Ocean Pipeline run detail page - karaoke': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('stages', 'jenkins', 1);
// this test case tests a live pipeline that is why we only running it with one case
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(cases[0].name, 'jenkins', 1);
blueRunDetailPage.assertBasicLayoutOkay();
// if we have the first stage finished we are sure in karaoke mode
blueRunDetailPage.waitForElementPresent('svg circle.success');
// FIXME should be taken from somewhere dynamically
// Stop karaoke and go back in graph and see the result
const nodeDetail = blueRunDetailPage.forNode('6');
const nodeDetail = blueRunDetailPage.forNode(cases[0].nodeId);
// validate that karaoke has stopped but overall process still runs
nodeDetail.waitForElementVisible('g.progress-spinner.running');
// Validate the result of the node
@@ -70,17 +113,34 @@ module.exports = {
// turn on css again
browser.useCss();
// wait for job to finish
nodeDetail.waitForJobRunEnded('stages');
nodeDetail.waitForJobRunEnded(cases[0].name);
},

'Check whether there is an EmptyStateView for stages with no steps': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('stages', 'jenkins', 1);
blueRunDetailPage.waitForElementVisible('div.empty-state');
async.mapSeries(cases, function (useCase, callback) {
// the pipeline-model cannot have "noSteps" need to skip the test for that
if (useCase.name !== "stagesPM") {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(useCase.name, 'jenkins', 1);
blueRunDetailPage.waitForElementVisible('@emptystate', createCallbackWrapper(callback));
} else {
callback(null);
}
});
},

'Check whether the artifacts tab shows artifacts': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('stages', 'jenkins', 1);
blueRunDetailPage.clickTab(browser, 'artifacts');
blueRunDetailPage.validateNotEmptyArtifacts();
}
async.mapSeries(cases, function (useCase, callback) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(useCase.name, 'jenkins', 1);
blueRunDetailPage.clickTab(browser, 'artifacts');
blueRunDetailPage
.validateNotEmptyArtifacts(browser, 1)
.waitForElementVisible('@artifactTable', createCallbackWrapper(callback));
}, function(err, results) {
// Check whether the changes tab shows emptyState for only one case
// this test case is the finisher since we cannot finish with a async series without a closing func
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(cases[0].name, 'jenkins', 1);
blueRunDetailPage.clickTab(browser, 'changes');
blueRunDetailPage.waitForElementVisible('@emptystate');
});
},
};
@@ -0,0 +1,21 @@
node {
stage ('Stage 1'){
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 3; echo `date` Stage 1;'
}
stage ('Stage 2'){
parallel firstBranch: {
sh 'echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;'

}, secondBranch: {
sh 'echo `date` Stage 2 - second;sleep 3; echo `date` Stage 2 - second;sleep 3; echo `date` Stage 2 - second;'
},
failFast: true
}
stage ('fin'){
sh 'echo `date` fin;sleep 3; echo `date` fin;'
sh 'echo yeah > foo.txt'
archiveArtifacts 'foo.txt'
}
stage 'NoSteps'
}
@@ -0,0 +1,16 @@
pipeline {
agent label:""
stages {
stage ('Stage 1'){
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 3; echo `date` Stage 1;'
}

stage ('fin'){
sh 'echo `date` fin;sleep 3; echo `date` fin;'
sh 'echo yeah > foo.txt'
archiveArtifacts 'foo.txt'
}
}

}
@@ -1,21 +1,18 @@
node {
stage ('Stage 1'){
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 3; echo `date` Stage 1;'
}
stage ('Stage 2'){
parallel firstBranch: {
sh 'echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;'
stage 'Stage 1'
sh 'sleep 3; echo `date` Stage 1;'
sh 'sleep 3; echo `date` Stage 1;'
stage 'Stage 2'
parallel firstBranch: {
sh 'echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;sleep 3; echo `date` Stage 2 - first;'

}, secondBranch: {
sh 'echo `date` Stage 2 - second;sleep 3; echo `date` Stage 2 - second;sleep 3; echo `date` Stage 2 - second;'
},
failFast: true
}
stage ('fin'){
sh 'echo `date` fin;sleep 3; echo `date` fin;'
sh 'echo yeah > foo.txt'
archiveArtifacts 'foo.txt'
}
}, secondBranch: {
sh 'echo `date` Stage 2 - second;sleep 3; echo `date` Stage 2 - second;sleep 3; echo `date` Stage 2 - second;'
},
failFast: true
stage 'fin'
sh 'echo `date` fin;sleep 3; echo `date` fin;'
sh 'echo yeah > foo.txt'
archiveArtifacts 'foo.txt'
stage 'NoSteps'
}

0 comments on commit 5afc5f5

Please sign in to comment.
You can’t perform that action at this time.