public void FailedConnectionDelayTest() { var isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsFalse(isConnDelayed.Result); _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed); isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsTrue(isConnDelayed.Result); Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason); var task = Task.Delay(100); task.Wait(); isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsFalse(isConnDelayed.Result); }
public async Task FailedConnectionDelayTest() { _nodeStats = new NodeStatsLight(_node); var isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsFalse(isConnDelayed.Result, "before failure"); _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed); isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsTrue(isConnDelayed.Result, "just after failure"); Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason); await Task.Delay(125); isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsFalse(isConnDelayed.Result, "125ms after failure"); }
public void FailedConnectionDelayTest(bool useLight) { _nodeStats = useLight ? new NodeStatsLight(_node, _config) : (INodeStats) new NodeStats(_node, _config); var isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsFalse(isConnDelayed.Result, "before failure"); _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed); isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsTrue(isConnDelayed.Result, "just after failure"); Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason); var task = Task.Delay(125); task.Wait(); isConnDelayed = _nodeStats.IsConnectionDelayed(); Assert.IsFalse(isConnDelayed.Result, "125ms after failure"); }
public void ReportEvent(Node node, NodeStatsEventType eventType) { INodeStats stats = GetOrAdd(node); stats.AddNodeStatsEvent(eventType); }