Unverified Commit afc4ec1f authored by Nick Craver's avatar Nick Craver Committed by GitHub

Remove Unspecified/ from errors and test tweaks (#1385)

In going through issues, I see many users confused by `Unspecified/` and it really serves no purpose. Let's get a quick win (and add a test for it).

Also, WSL2 it appears has clock jitter - we can accommodate that while having a valid test, fixing that local case.
parent f4a3d964
...@@ -271,7 +271,7 @@ void add(string lk, string sk, string v) ...@@ -271,7 +271,7 @@ void add(string lk, string sk, string v)
if (string.IsNullOrWhiteSpace(log)) Interlocked.Exchange(ref mutiplexer.haveStormLog, 0); if (string.IsNullOrWhiteSpace(log)) Interlocked.Exchange(ref mutiplexer.haveStormLog, 0);
else Interlocked.Exchange(ref mutiplexer.stormLogSnapshot, log); else Interlocked.Exchange(ref mutiplexer.stormLogSnapshot, log);
} }
add("Server-Endpoint", "serverEndpoint", server.EndPoint.ToString()); add("Server-Endpoint", "serverEndpoint", server.EndPoint.ToString().Replace("Unspecified/",""));
} }
add("Manager", "mgr", mutiplexer.SocketManager?.GetState()); add("Manager", "mgr", mutiplexer.SocketManager?.GetState());
......
...@@ -108,5 +108,37 @@ public void NullInnerExceptionForMultipleEndpointsWithNoLastException() ...@@ -108,5 +108,37 @@ public void NullInnerExceptionForMultipleEndpointsWithNoLastException()
ClearAmbientFailures(); ClearAmbientFailures();
} }
} }
[Fact]
public void TimeoutException()
{
try
{
using (var muxer = Create(keepAlive: 1, connectTimeout: 10000, allowAdmin: true, shared: false) as ConnectionMultiplexer)
{
var conn = muxer.GetDatabase();
var server = GetServer(muxer);
muxer.AllowConnect = false;
var msg = Message.Create(-1, CommandFlags.None, RedisCommand.PING);
var rawEx = ExceptionFactory.Timeout(muxer, "Test Timeout", msg, new ServerEndPoint(muxer, server.EndPoint));
var ex = Assert.IsType<RedisTimeoutException>(rawEx);
Writer.WriteLine("Exception: " + ex.Message);
// Example format: "Test Timeout, command=PING, inst: 0, qu: 0, qs: 0, aw: False, in: 0, in-pipe: 0, out-pipe: 0, serverEndpoint: 127.0.0.1:6379, mgr: 10 of 10 available, clientName: TimeoutException, IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=2,Free=2045,Min=8,Max=2047), v: 2.1.0 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)";
Assert.StartsWith("Test Timeout, command=PING", ex.Message);
Assert.Contains("clientName: " + nameof(TimeoutException), ex.Message);
// Ensure our pipe numbers are in place
Assert.Contains("inst: 0, qu: 0, qs: 0, aw: False, in: 0, in-pipe: 0, out-pipe: 0", ex.Message);
Assert.Contains("serverEndpoint: " + server.EndPoint.ToString(), ex.Message);
Assert.DoesNotContain("Unspecified/", ex.Message);
Assert.EndsWith(" (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)", ex.Message);
Assert.Null(ex.InnerException);
}
}
finally
{
ClearAmbientFailures();
}
}
} }
} }
...@@ -82,12 +82,12 @@ public async Task TestBasicExpiryDateTime(bool disablePTimes, bool utc) ...@@ -82,12 +82,12 @@ public async Task TestBasicExpiryDateTime(bool disablePTimes, bool utc)
Assert.NotNull(time); Assert.NotNull(time);
Log("Time: {0}, Expected: {1}-{2}", time, TimeSpan.FromMinutes(59), TimeSpan.FromMinutes(60)); Log("Time: {0}, Expected: {1}-{2}", time, TimeSpan.FromMinutes(59), TimeSpan.FromMinutes(60));
Assert.True(time >= TimeSpan.FromMinutes(59)); Assert.True(time >= TimeSpan.FromMinutes(59));
Assert.True(time <= TimeSpan.FromMinutes(60)); Assert.True(time <= TimeSpan.FromMinutes(60.1));
Assert.Null(await c); Assert.Null(await c);
time = await d; time = await d;
Assert.NotNull(time); Assert.NotNull(time);
Assert.True(time >= TimeSpan.FromMinutes(89)); Assert.True(time >= TimeSpan.FromMinutes(89));
Assert.True(time <= TimeSpan.FromMinutes(90)); Assert.True(time <= TimeSpan.FromMinutes(90.1));
Assert.Null(await e); Assert.Null(await e);
Assert.Null(await f); Assert.Null(await f);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment