Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
FIX Jenkins-37962 REGRESSION: parallel karaoke not allowing branch se…
Browse files Browse the repository at this point in the history
…lection or completing correctly (#42)

* [JENKINS-37962] Add test for clicking on run button then on the emerging toast the open

* [JENKINS-37962] Update comment to describe test case

* [JENKINS-37962] better documentation of the steps
  • Loading branch information
scherler committed Sep 20, 2016
1 parent 8d50b41 commit c15815c
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 11 deletions.
17 changes: 17 additions & 0 deletions src/main/js/page_objects/blueocean/bluePipelineRunDetail.js
Expand Up @@ -32,6 +32,7 @@ module.exports = {
changes: 'table.changeset-table tr',
tests: 'div.new-failure-block div.result-item',
authors: 'a.authors',
circleSuccess: 'svg circle.success',
firstResult: {
selector: '//div[contains(@class, "result-item") and position()=1]',
locateStrategy: 'xpath',
Expand Down Expand Up @@ -123,6 +124,22 @@ module.exports.commands = [{
});
return self;
},
/**
* Validate that the log title contains the expected value
* @param {String} expected - the title we await
* @returns {Object} self - nightwatch page object
*/
assertLogTitle: function (expected) {
const self = this;
self.waitForElementVisible('@logHeader');
self.getText('@logHeader', function (response) {
sanityCheck(self, response);
console.log(response)
const urlProject = (response.value);
self.assert.equal(urlProject.indexOf(expected) > -1, true);
});
return self;
},
/**
* Close the modal view
* @returns {Object} self - nightwatch page object
Expand Down
23 changes: 12 additions & 11 deletions src/test/js/log-karaoke/noStages.js
@@ -1,3 +1,4 @@
const jobName = 'noStages';
/** @module noStages
* @memberof karaoke
* @description TEST: logs tailing a pipeline job without stages, but with steps - karaoke mode
Expand All @@ -6,11 +7,11 @@ module.exports = {
/** Create Pipeline Job "noStages" */
'Step 01': function (browser) {
const pipelinesCreate = browser.page.pipelineCreate().navigate();
pipelinesCreate.createPipeline('noStages', 'no-stages.groovy');
pipelinesCreate.createPipeline(jobName, 'no-stages.groovy');
},
/** Build Pipeline Job*/
'Step 02': function (browser) {
const pipelinePage = browser.page.jobUtils().forJob('noStages');
const pipelinePage = browser.page.jobUtils().forJob(jobName);
pipelinePage.buildStarted(function() {
// Reload the job page and check that there was a build done.
pipelinePage
Expand All @@ -23,10 +24,10 @@ module.exports = {
* need to click on an element so the up_arrow takes place in the window
* */
'Step 03': function (browser) {
const blueActivityPage = browser.page.bluePipelineActivity().forJob('noStages', 'jenkins');
const blueActivityPage = browser.page.bluePipelineActivity().forJob(jobName, 'jenkins');
// Check the run itself
blueActivityPage.waitForRunRunningVisible('noStages-1');
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('noStages', 'jenkins', 1);
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);

// Wait for the table of pipeline steps to start rendering with
// follow-on turned on.
Expand Down Expand Up @@ -81,7 +82,7 @@ module.exports = {
/** Check Job Blue Ocean Pipeline run detail page - follow*/
'Step 04': function (browser) {
// Reload the page so as to restart karaoke mode
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('noStages', 'jenkins', 1);
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);
browser.elements('css selector', 'div.result-item.success', function (collection) {
const count = collection.value.length;
// wait for the success update via sse event
Expand All @@ -102,9 +103,9 @@ module.exports = {
},
/** Check whether a log which exceed 150kb contains a link to full log and if clicked it disappear*/
'Step 05': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('noStages', 'jenkins', 1);
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);

browser.waitForJobRunEnded('noStages', function() {
browser.waitForJobRunEnded(jobName, function() {
// Note, tried using "last" selectors for both CSS and XPath
// and neither worked in nightwatch e.g. //div[starts-with(@class, 'logConsole')][last()]
// works in the browser, but not for nightwatch.
Expand All @@ -120,27 +121,27 @@ module.exports = {
},
/** Check whether a step that does not has a log as well will have the expando disabled*/
'Step 06': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('noStages', 'jenkins', 1);
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);
// NOTE: if the pipeline script (no-stages.groovy) changes then the following
// selector will need to be changed too.
browser
.waitForElementVisible('div.step-29 svg.disabled.result-item-expando');
},
/** Check whether the test tab shows an empty state hint*/
'Step 07': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('noStages', 'jenkins', 1);
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);
blueRunDetailPage.clickTab('tests');
blueRunDetailPage.validateEmpty();
},
/** Check whether the changes tab shows an empty state hint*/
'Step 08': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('noStages', 'jenkins', 1);
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);
blueRunDetailPage.clickTab('changes');
blueRunDetailPage.validateEmpty();
},
/** Check whether the artifacts tab shows an empty state hint*/
'Step 09': function (browser) {
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun('noStages', 'jenkins', 1);
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);
blueRunDetailPage.clickTab('artifacts');
blueRunDetailPage.validateEmpty();
}
Expand Down
58 changes: 58 additions & 0 deletions src/test/js/log-karaoke/parallelStages.js
@@ -0,0 +1,58 @@
const jobName = 'parallelStages';
/** @module stages
* @memberof karaoke
* @description REGRESSION-TEST: parallel karaoke not allowing branch selection or completing correctly
* @see {@link https://issues.jenkins-ci.org/browse/JENKINS-37962|JENKINS-37962}
*
* TODO @see {@link https://issues.jenkins-ci.org/browse/JENKINS-37753|JENKINS-37753}
* REGRESSION: Steps showing up as incomplete when they are in fact complete
*
*/
module.exports = {
/** Create Pipeline Job "parallelStages" */
'Step 01': function (browser) {
const pipelinesCreate = browser.page.pipelineCreate().navigate();
pipelinesCreate.createPipeline(jobName, 'parallel-stages.groovy');
},
/** Build Pipeline Job*/
'Step 02': function (browser) {
const pipelinePage = browser.page.jobUtils().forJob(jobName);
pipelinePage.buildStarted(function () {
// Reload the job page and check that there was a build done.
pipelinePage
.waitForElementVisible('div#pipeline-box')
.forRun(1)
.waitForElementVisible('@executer');
});
},
/** Check Job Blue Ocean Pipeline Activity Page has run.
* Check different nodes of the graph, first check that we are in first branch and that we have steps.
* Then change to the second parallel tree and check the same as before for the secondBranch*/
'Step 03': function (browser) {
const blueActivityPage = browser.page.bluePipelineActivity().forJob(jobName, 'jenkins');
// Check the run itself
blueActivityPage.waitForRunRunningVisible('parallelStages-1');
const blueRunDetailPage = browser.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 1);
blueRunDetailPage.validateGraph();
// if we have the first stage finished we can go on
blueRunDetailPage.waitForElementPresent('@circleSuccess');
// see whether we have focus on the first branch
blueRunDetailPage.assertLogTitle('firstBranch');
// give some time by waiting on 2 steps showing up
blueRunDetailPage.validateSteps(2);
// navigate to the secondBranch
blueRunDetailPage.forNode(11); // -> IF groovy changes this might to be adopted
// see whether we have focus on the second branch
blueRunDetailPage.assertLogTitle('secondBranch');
// we should have now 2 steps
blueRunDetailPage.validateSteps(2);
},
/** Wait for job to end, TODO: then validate that the steps are all marked as finished
* TODO @see {@link https://issues.jenkins-ci.org/browse/JENKINS-37753|JENKINS-37753}
* */
'Step 04': function (browser) {
browser.waitForJobRunEnded(jobName, function () {
// Here will test for JENKINS-37753
});
}
};
18 changes: 18 additions & 0 deletions src/test/resources/test_scripts/parallel-stages.groovy
@@ -0,0 +1,18 @@
node {
stage "hey"
sh "echo yeah"

stage "parallel"

parallel firstBranch: {
sh 'echo `date` Stage 2 - firstBranch www.spiegel.de'
sh 'ping -c 3 -i 1 www.spiegel.de'

}, secondBranch: {
sh 'echo `date` Stage 2 - secondBranch www.stern.de'
sh 'ping -c 5 -i 1 www.stern.de'
}

stage "ho"
sh "echo done"
}

0 comments on commit c15815c

Please sign in to comment.