public void GetSentinelMasterConnectionWriteReadFailover() { var conn = Conn.GetSentinelMasterConnection(new ConfigurationOptions { ServiceName = ServiceName }); var s = conn.currentSentinelMasterEndPoint.ToString(); IDatabase db = conn.GetDatabase(); var expected = DateTime.Now.Ticks.ToString(); db.StringSet("beforeFailOverValue", expected); Server26379.SentinelFailover(ServiceName); Thread.Sleep(3000); var conn1 = Conn.GetSentinelMasterConnection(new ConfigurationOptions { ServiceName = ServiceName }); var s1 = conn1.currentSentinelMasterEndPoint.ToString(); var db1 = conn1.GetDatabase(); var actual = db1.StringGet("beforeFailOverValue"); Assert.NotNull(s); Assert.NotNull(s1); Assert.NotEmpty(s); Assert.NotEmpty(s1); Assert.NotEqual(s, s1); Assert.Equal(expected, actual); }
public void GetSentinelMasterConnectionFailoverTest() { var conn = Conn.GetSentinelMasterConnection(new ConfigurationOptions { ServiceName = ServiceName }); var endpoint = conn.currentSentinelMasterEndPoint.ToString(); Server26379.SentinelFailover(ServiceName); Thread.Sleep(3000); var conn1 = Conn.GetSentinelMasterConnection(new ConfigurationOptions { ServiceName = ServiceName }); var endpoint1 = conn1.currentSentinelMasterEndPoint.ToString(); Assert.NotEqual(endpoint, endpoint1); }