Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Issue992 & ExceptionFactory tests #1952

Merged
merged 6 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions tests/StackExchange.Redis.Tests/ConnectingFailDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/StackExchange.Redis.Tests/ExceptionFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion tests/StackExchange.Redis.Tests/Issues/SO24807536.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/StackExchange.Redis.Tests/Locking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}

Expand Down