Skip to content

Commit 15d932a

Browse files
authored
Merge branch 'master' into jarmstrong-githubapp-case-insensitive
2 parents 02fd9ef + 0c05abd commit 15d932a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@
115115
<version>589.vb_a_b_4a_a_8c443c</version> <!-- TODO until in BOM -->
116116
<scope>test</scope>
117117
</dependency>
118+
<dependency>
119+
<groupId>org.awaitility</groupId>
120+
<artifactId>awaitility</artifactId>
121+
<version>4.2.0</version>
122+
<scope>test</scope>
123+
<exclusions>
124+
<exclusion>
125+
<groupId>org.hamcrest</groupId>
126+
<artifactId>hamcrest</artifactId>
127+
</exclusion>
128+
</exclusions>
129+
</dependency>
118130
<dependency>
119131
<groupId>io.jenkins.plugins</groupId>
120132
<artifactId>okhttp-api</artifactId>

src/test/java/org/jenkinsci/plugins/github_branch_source/EventsTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
package org.jenkinsci.plugins.github_branch_source;
2727

28+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
29+
import static java.util.concurrent.TimeUnit.MINUTES;
2830
import static org.junit.Assert.assertEquals;
2931

3032
import java.io.IOException;
@@ -34,6 +36,7 @@
3436
import jenkins.scm.api.SCMHeadEvent;
3537
import jenkins.scm.api.SCMSourceEvent;
3638
import org.apache.commons.io.IOUtils;
39+
import org.awaitility.Awaitility;
3740
import org.jenkinsci.plugins.github.extension.GHSubscriberEvent;
3841
import org.junit.AfterClass;
3942
import org.junit.Before;
@@ -55,7 +58,7 @@ public class EventsTest {
5558

5659
@BeforeClass
5760
public static void setupDelay() {
58-
GitHubSCMSource.setEventDelaySeconds(1);
61+
GitHubSCMSource.setEventDelaySeconds(0); // fire immediately without delay
5962
}
6063

6164
@Before
@@ -188,7 +191,11 @@ private GHSubscriberEvent createEvent(String eventPayloadFile) throws IOExceptio
188191
private void waitAndAssertReceived(boolean received) throws InterruptedException {
189192
long watermark = SCMEvents.getWatermark();
190193
// event will be fired by subscriber at some point
191-
SCMEvents.awaitOne(watermark, 1200, TimeUnit.MILLISECONDS);
194+
SCMEvents.awaitOne(watermark, received ? 20 : 200, TimeUnit.MILLISECONDS);
195+
196+
if (received) {
197+
TestSCMEventListener.awaitUntilReceived();
198+
}
192199

193200
assertEquals(
194201
"Event should have " + ((!received) ? "not " : "") + "been received",
@@ -223,5 +230,12 @@ public static boolean didReceive() {
223230
public static void setReceived(boolean received) {
224231
eventReceived = received;
225232
}
233+
234+
public static void awaitUntilReceived() {
235+
Awaitility.await()
236+
.pollInterval(10, MILLISECONDS)
237+
.atMost(1, MINUTES)
238+
.until(() -> eventReceived);
239+
}
226240
}
227241
}

0 commit comments

Comments
 (0)