Commit bad71238 authored by Marc Gravell's avatar Marc Gravell

investigate #922

parent 2b16da45
......@@ -111,5 +111,37 @@ public void ConnectsWhenBeginConnectCompletesSynchronously()
ClearAmbientFailures();
}
}
[Fact]
public void Issue922_ReconnectRaised()
{
var config = ConfigurationOptions.Parse(TestConfig.Current.MasterServerAndPort);
config.AbortOnConnectFail = true;
config.KeepAlive = 10;
config.SyncTimeout = 1000;
config.ReconnectRetryPolicy = new ExponentialRetry(5000);
config.AllowAdmin = true;
int failCount = 0, restoreCount = 0;
using (var muxer = ConnectionMultiplexer.Connect(config))
{
muxer.ConnectionFailed += delegate { Interlocked.Increment(ref failCount); };
muxer.ConnectionRestored += delegate { Interlocked.Increment(ref restoreCount); };
var db = muxer.GetDatabase();
db.Ping();
Assert.Equal(0, Volatile.Read(ref failCount));
Assert.Equal(0, Volatile.Read(ref restoreCount));
var server = muxer.GetServer(TestConfig.Current.MasterServerAndPort);
server.SimulateConnectionFailure();
Thread.Sleep(1000);
db.Ping(); // interactive+subscriber = 2
Assert.Equal(2, Volatile.Read(ref failCount));
Assert.Equal(2, Volatile.Read(ref restoreCount));
}
}
}
}
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