diff --git a/src/test/java/io/github/hectorvent/floci/services/swf/SwfServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/swf/SwfServiceTest.java index d2670b25be..f3b000a7bb 100644 --- a/src/test/java/io/github/hectorvent/floci/services/swf/SwfServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/swf/SwfServiceTest.java @@ -58,6 +58,8 @@ class SwfServiceTest { private static final String REGION = "us-east-1"; private static final String DOMAIN = "unit-domain"; + /** Upper bound for {@link #pollFor}; generous so a loaded CI runner cannot starve it. */ + private static final Duration POLL_TIMEOUT = Duration.ofSeconds(10); private MutableClock clock; private SwfService service; @@ -1199,9 +1201,15 @@ class SwfServiceTest { * *
Tolerates a transient empty poll so the concurrency tests can call this from * several threads: another thread may hold the task this caller wants at that instant. + * + *
Bounded by wall-clock time rather than an attempt count: with several pollers on
+ * one task list, a caller can repeatedly claim and release siblings' tasks, and those
+ * round trips take microseconds. A fixed attempt budget then burns out well before the
+ * wanted task becomes pollable under CI contention.
*/
private SwfDecisionTask pollFor(String workflowId) {
- for (int attempt = 0; attempt < 200; attempt++) {
+ long deadline = System.nanoTime() + POLL_TIMEOUT.toNanos();
+ while (System.nanoTime() < deadline) {
Optional