Skip to content

Commit 59d6c27

Browse files
committed
Fix RedisLockLeaderInitiatorTests timing barrier
https://build.spring.io/browse/INT-FATS5IC-509 Looks like `busyWait` period as `5 secs` is too aggressive and may be two or more cycles pass until the election happens. At this time the waiting for the `granted` latch in `10 secs` may expire already, therefore we fail in the assertion * Decrease `busyWait` to the `1 secs` to let the election cycle to pass quickly * Increase latch wait time to the `20 secs` **Cherry-pick to 5.0.x**
1 parent 454ad96 commit 59d6c27

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,23 @@ public void testDistributedLeaderElection() throws Exception {
108108
initiator2.setLeaderEventPublisher(new CountingPublisher(granted2, revoked2, acquireLockFailed2));
109109

110110
// It's hard to see round-robin election, so let's make the yielding initiator to sleep long before restarting
111-
initiator1.setBusyWaitMillis(5000);
111+
initiator1.setBusyWaitMillis(1000);
112112

113113
initiator1.getContext().yield();
114114

115-
assertThat(revoked1.await(10, TimeUnit.SECONDS), is(true));
116-
assertThat(granted2.await(10, TimeUnit.SECONDS), is(true));
115+
assertThat(revoked1.await(20, TimeUnit.SECONDS), is(true));
116+
assertThat(granted2.await(20, TimeUnit.SECONDS), is(true));
117117

118118
assertThat(initiator2.getContext().isLeader(), is(true));
119119
assertThat(initiator1.getContext().isLeader(), is(false));
120120

121121
initiator1.setBusyWaitMillis(LockRegistryLeaderInitiator.DEFAULT_BUSY_WAIT_TIME);
122-
initiator2.setBusyWaitMillis(5000);
122+
initiator2.setBusyWaitMillis(1000);
123123

124124
initiator2.getContext().yield();
125125

126-
assertThat(revoked2.await(10, TimeUnit.SECONDS), is(true));
127-
assertThat(granted1.await(10, TimeUnit.SECONDS), is(true));
126+
assertThat(revoked2.await(20, TimeUnit.SECONDS), is(true));
127+
assertThat(granted1.await(20, TimeUnit.SECONDS), is(true));
128128

129129
assertThat(initiator1.getContext().isLeader(), is(true));
130130
assertThat(initiator2.getContext().isLeader(), is(false));

0 commit comments

Comments
 (0)