Skip to content

Commit 8857beb

Browse files
authored
Merge pull request #208 from Vlatombe/flaky-InputStepRestartTest-interrupt
Better test result whenever InputStepRestartTest#interrupt fails
2 parents 7ebfe7e + 18a5487 commit 8857beb

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pom.xml

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
<type>pom</type>
5353
<scope>import</scope>
5454
</dependency>
55+
<dependency>
56+
<groupId>org.awaitility</groupId>
57+
<artifactId>awaitility</artifactId>
58+
<version>4.3.0</version>
59+
</dependency>
5560
</dependencies>
5661
</dependencyManagement>
5762
<dependencies>
@@ -116,5 +121,10 @@
116121
<artifactId>credentials-binding</artifactId>
117122
<scope>test</scope>
118123
</dependency>
124+
<dependency>
125+
<groupId>org.awaitility</groupId>
126+
<artifactId>awaitility</artifactId>
127+
<scope>test</scope>
128+
</dependency>
119129
</dependencies>
120130
</project>

src/test/java/org/jenkinsci/plugins/workflow/support/steps/input/InputStepRestartTest.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
3737
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
3838
import org.jenkinsci.plugins.workflow.support.actions.PauseAction;
39+
40+
import static org.awaitility.Awaitility.await;
41+
import static org.hamcrest.Matchers.notNullValue;
3942
import static org.junit.Assert.*;
4043
import org.junit.ClassRule;
4144
import org.junit.Rule;
4245
import org.junit.Test;
43-
import org.junit.runners.model.Statement;
4446
import org.jvnet.hudson.test.BuildWatcher;
4547
import org.jvnet.hudson.test.Issue;
4648
import org.jvnet.hudson.test.JenkinsRule;
@@ -97,11 +99,7 @@ private void sanity(WorkflowRun b) throws Exception {
9799
WorkflowRun b = j.jenkins.getItemByFullName("p", WorkflowJob.class).getBuildByNumber(1);
98100
assertNotNull(b);
99101
assertTrue(b.isBuilding());
100-
Executor executor;
101-
while ((executor = b.getExecutor()) == null) {
102-
Thread.sleep(100); // probably a race condition: AfterRestartTask could take a moment to be registered
103-
}
104-
assertNotNull(executor);
102+
Executor executor = await().until(b::getExecutor, notNullValue());
105103
executor.interrupt();
106104
j.assertBuildStatus(Result.ABORTED, j.waitForCompletion(b));
107105
sanity(b);

0 commit comments

Comments
 (0)