public async Task GetSentinelMasterConnectionFailoverAsyncTest() { var conn = Conn.GetSentinelMasterConnection(ServiceOptions); var endpoint = conn.currentSentinelMasterEndPoint.ToString(); try { Log("Failover attempted initiated"); await SentinelServerA.SentinelFailoverAsync(ServiceName).ForAwait(); Log(" Success!"); } catch (RedisServerException ex) when(ex.Message.Contains("NOGOODSLAVE")) { // Retry once Log(" Retry initiated"); await Task.Delay(1000).ForAwait(); await SentinelServerA.SentinelFailoverAsync(ServiceName).ForAwait(); Log(" Retry complete"); } // Try and complete ASAP await UntilCondition(TimeSpan.FromSeconds(10), () => { var checkConn = Conn.GetSentinelMasterConnection(ServiceOptions); return(endpoint != checkConn.currentSentinelMasterEndPoint.ToString()); }); // Post-check for validity var conn1 = Conn.GetSentinelMasterConnection(ServiceOptions); Assert.NotEqual(endpoint, conn1.currentSentinelMasterEndPoint.ToString()); }
public async Task GetSentinelMasterConnectionFailoverAsyncTest() { var conn = Conn.GetSentinelMasterConnection(new ConfigurationOptions { ServiceName = ServiceName }); var endpoint = conn.currentSentinelMasterEndPoint.ToString(); await SentinelServerA.SentinelFailoverAsync(ServiceName).ForAwait(); await Task.Delay(2000).ForAwait(); var conn1 = Conn.GetSentinelMasterConnection(new ConfigurationOptions { ServiceName = ServiceName }); var endpoint1 = conn1.currentSentinelMasterEndPoint.ToString(); Assert.NotEqual(endpoint, endpoint1); }