From 59d6c279a4cad25ed30bd1e7f0f1e35087673876 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 16 May 2018 13:08:43 -0400 Subject: [PATCH] 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** --- .../RedisLockRegistryLeaderInitiatorTests.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java index 7011f8d86f..86a8d2640b 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/leader/RedisLockRegistryLeaderInitiatorTests.java @@ -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));