diff --git a/tests/StackExchange.Redis.Tests/ConnectingFailDetection.cs b/tests/StackExchange.Redis.Tests/ConnectingFailDetection.cs index 7b33df000..2aa994807 100644 --- a/tests/StackExchange.Redis.Tests/ConnectingFailDetection.cs +++ b/tests/StackExchange.Redis.Tests/ConnectingFailDetection.cs @@ -123,12 +123,16 @@ public async Task Issue922_ReconnectRaised() Assert.Equal(0, Volatile.Read(ref restoreCount)); var server = muxer.GetServer(TestConfig.Current.MasterServerAndPort); - server.SimulateConnectionFailure(SimulatedFailureType.InteractiveInbound | SimulatedFailureType.InteractiveOutbound); + server.SimulateConnectionFailure(SimulatedFailureType.All); + + await UntilCondition(TimeSpan.FromSeconds(10), () => Volatile.Read(ref failCount) >= 2 && Volatile.Read(ref restoreCount) >= 2); - await UntilCondition(TimeSpan.FromSeconds(10), () => Volatile.Read(ref failCount) + Volatile.Read(ref restoreCount) == 4); // interactive+subscriber = 2 - Assert.Equal(2, Volatile.Read(ref failCount)); - Assert.Equal(2, Volatile.Read(ref restoreCount)); + var failCountSnapshot = Volatile.Read(ref failCount); + Assert.True(failCountSnapshot >= 2, $"failCount {failCountSnapshot} >= 2"); + + var restoreCountSnapshot = Volatile.Read(ref restoreCount); + Assert.True(restoreCountSnapshot >= 2, $"restoreCount ({restoreCountSnapshot}) >= 2"); } } diff --git a/tests/StackExchange.Redis.Tests/ExceptionFactoryTests.cs b/tests/StackExchange.Redis.Tests/ExceptionFactoryTests.cs index 63c6ff2dc..494c688d6 100644 --- a/tests/StackExchange.Redis.Tests/ExceptionFactoryTests.cs +++ b/tests/StackExchange.Redis.Tests/ExceptionFactoryTests.cs @@ -151,7 +151,7 @@ public void NoConnectionException(bool abortOnConnect, int connCount, int comple var options = new ConfigurationOptions() { AbortOnConnectFail = abortOnConnect, - ConnectTimeout = 500, + ConnectTimeout = 1000, SyncTimeout = 500, KeepAlive = 5000 }; diff --git a/tests/StackExchange.Redis.Tests/Issues/SO24807536.cs b/tests/StackExchange.Redis.Tests/Issues/SO24807536.cs index c795927eb..66b16ce7d 100644 --- a/tests/StackExchange.Redis.Tests/Issues/SO24807536.cs +++ b/tests/StackExchange.Redis.Tests/Issues/SO24807536.cs @@ -20,7 +20,7 @@ public async Task Exec() // setup some data cache.KeyDelete(key, CommandFlags.FireAndForget); cache.HashSet(key, "full", "some value", flags: CommandFlags.FireAndForget); - cache.KeyExpire(key, TimeSpan.FromSeconds(2), CommandFlags.FireAndForget); + cache.KeyExpire(key, TimeSpan.FromSeconds(4), CommandFlags.FireAndForget); // test while exists var keyExists = cache.KeyExists(key); diff --git a/tests/StackExchange.Redis.Tests/Locking.cs b/tests/StackExchange.Redis.Tests/Locking.cs index 7089a6972..9053d2956 100644 --- a/tests/StackExchange.Redis.Tests/Locking.cs +++ b/tests/StackExchange.Redis.Tests/Locking.cs @@ -69,7 +69,7 @@ void cb(object obj) [Fact] public void TestOpCountByVersionLocal_UpLevel() { - using (var conn = Create()) + using (var conn = Create(shared: false)) { TestLockOpCountByVersion(conn, 1, false); TestLockOpCountByVersion(conn, 1, true); @@ -99,7 +99,7 @@ private void TestLockOpCountByVersion(IConnectionMultiplexer conn, int expectedO Assert.Equal(!existFirst, taken); Assert.Equal(expectedVal, valAfter); - Assert.Equal(expectedOps, countAfter - countBefore); + Assert.True(expectedOps >= countAfter - countBefore, $"{expectedOps} >= ({countAfter} - {countBefore})"); // note we get a ping from GetCounters }