forked from jenkinsci/pipeline-graph-view-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipelineGraphViewRebuildTest.java
More file actions
122 lines (102 loc) · 4.62 KB
/
PipelineGraphViewRebuildTest.java
File metadata and controls
122 lines (102 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package io.jenkins.plugins.pipelinegraphview;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.junit.UsePlaywright;
import hudson.model.Result;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import io.jenkins.plugins.casc.misc.junit.jupiter.WithJenkinsConfiguredWithCode;
import io.jenkins.plugins.pipelinegraphview.playwright.PipelineJobPage;
import io.jenkins.plugins.pipelinegraphview.playwright.PipelineOverviewPage;
import io.jenkins.plugins.pipelinegraphview.playwright.PlaywrightConfig;
import io.jenkins.plugins.pipelinegraphview.utils.TestUtils;
import jenkins.test.RunMatchers;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.Issue;
@WithJenkinsConfiguredWithCode
@UsePlaywright(PlaywrightConfig.class)
class PipelineGraphViewRebuildTest {
@Issue("GH#330")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void rerunButtonStartsNewBuild(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
WorkflowRun run =
TestUtils.createAndRunJob(j, "hello_world", "helloWorldScriptedPipeline.jenkinsfile", Result.SUCCESS);
WorkflowJob job = run.getParent();
PipelineOverviewPage op = new PipelineJobPage(p, job)
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview();
String jobUrl = j.getURL() + job.getUrl();
assertThat(p).hasURL(jobUrl + "1/pipeline-overview/");
op.rerun();
assertThat(p).hasURL(jobUrl + "2/pipeline-overview/");
waitUntilBuildIsComplete(j, run);
}
@Test
@ConfiguredWithCode("configure-appearance.yml")
void replayButtonRedirects(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
WorkflowRun run =
TestUtils.createAndRunJob(j, "hello_world", "helloWorldScriptedPipeline.jenkinsfile", Result.SUCCESS);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.replay();
String newUrl = p.url();
String targetUrl = j.getURL() + run.getUrl() + "replay/";
assertEquals(targetUrl, newUrl);
}
@Issue("GH#617")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void rebuildButtonRedirectsForParameterizedJob(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
WorkflowRun run = TestUtils.createAndRunJob(
j, "echo_parameterized", "gh330_parameterizedBuild.jenkinsfile", Result.SUCCESS);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.rebuild();
String newUrl = p.url();
String targetUrl = j.getURL() + run.getUrl() + "rebuild/parameterized";
assertEquals(targetUrl, newUrl);
}
@Test
@ConfiguredWithCode("configure-appearance.yml")
void restartFromStageButtonRedirects(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
WorkflowRun run = TestUtils.createAndRunJob(
j, "hello_world", "helloWorldDeclarativePipeline.jenkinsfile", Result.SUCCESS);
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.restartFromStage();
String newUrl = p.url();
String targetUrl = j.getURL() + run.getUrl() + "restart/";
assertEquals(targetUrl, newUrl);
}
// We don't care about the build result but Windows fails with
// file locking issues if we don't wait for the build to finish.
private static void waitUntilBuildIsComplete(JenkinsConfiguredWithCodeRule j, WorkflowRun run) {
await().until(() -> j.jenkins.getQueue().isEmpty(), is(true));
WorkflowJob parent = run.getParent();
await().until(parent::getBuilds, hasSize(2));
WorkflowRun lastBuild = parent.getLastBuild();
await().until(() -> lastBuild, RunMatchers.completed());
}
}