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**
This commit is contained in:
Artem Bilan
2018-05-16 13:08:43 -04:00
parent 454ad96189
commit 59d6c279a4

View File

@@ -108,23 +108,23 @@ public class RedisLockRegistryLeaderInitiatorTests extends RedisAvailableTests {
initiator2.setLeaderEventPublisher(new CountingPublisher(granted2, revoked2, acquireLockFailed2));
// It's hard to see round-robin election, so let's make the yielding initiator to sleep long before restarting
initiator1.setBusyWaitMillis(5000);
initiator1.setBusyWaitMillis(1000);
initiator1.getContext().yield();
assertThat(revoked1.await(10, TimeUnit.SECONDS), is(true));
assertThat(granted2.await(10, TimeUnit.SECONDS), is(true));
assertThat(revoked1.await(20, TimeUnit.SECONDS), is(true));
assertThat(granted2.await(20, TimeUnit.SECONDS), is(true));
assertThat(initiator2.getContext().isLeader(), is(true));
assertThat(initiator1.getContext().isLeader(), is(false));
initiator1.setBusyWaitMillis(LockRegistryLeaderInitiator.DEFAULT_BUSY_WAIT_TIME);
initiator2.setBusyWaitMillis(5000);
initiator2.setBusyWaitMillis(1000);
initiator2.getContext().yield();
assertThat(revoked2.await(10, TimeUnit.SECONDS), is(true));
assertThat(granted1.await(10, TimeUnit.SECONDS), is(true));
assertThat(revoked2.await(20, TimeUnit.SECONDS), is(true));
assertThat(granted1.await(20, TimeUnit.SECONDS), is(true));
assertThat(initiator1.getContext().isLeader(), is(true));
assertThat(initiator2.getContext().isLeader(), is(false));