public async Task VerifyReplicationProcess() { var replicationInfo = testManager.SetupReplication(); var arguments = new List <ReplicationProgress>(); manager.Progress.Subscribe( item => { arguments.Add(item); }); await manager.Open().ConfigureAwait(false); Assert.AreEqual(0, arguments.Count); timer.OnNext(1); Assert.IsFalse(arguments[0].IsActive); replicationInfo.Setup(item => item.MasterReplOffset).Returns(2000); replicationInfo.Setup(item => item.Slaves).Returns(new[] { SlaveInformation.Parse("ip=127.0.0.1,port=6666,state=online,offset=239,lag=0") }); timer.OnNext(1); Assert.AreEqual(2, arguments.Count); Assert.IsTrue(arguments[1].IsActive); Assert.IsFalse(arguments[1].InSync); replicationInfo.Setup(item => item.Slaves).Returns(new[] { SlaveInformation.Parse("ip=127.0.0.1,port=6666,state=online,offset=2000,lag=0") }); timer.OnNext(1); Assert.AreEqual(3, arguments.Count); Assert.IsTrue(arguments[2].IsActive); Assert.IsTrue(arguments[2].InSync); }
public void Parse() { var information = SlaveInformation.Parse("ip=127.0.0.1,port=6027,state=online,offset=239,lag=0"); Assert.AreEqual(IPAddress.Parse("127.0.0.1"), information.EndPoint.Address); Assert.AreEqual(6027, information.EndPoint.Port); Assert.AreEqual("online", information.State); Assert.AreEqual(239, information.Offset); Assert.AreEqual(0, information.Lag); }
public void Replicate() { var master = new DnsEndPoint("Master", 1); var slave = new DnsEndPoint("Slave", 2); var replicationInfo = SetupReplication(); var task = instance.Replicate(master, slave, CancellationToken.None); var ticks = TimeSpan.FromSeconds(1).Ticks; scheduler.AdvanceBy(ticks); Thread.Sleep(100); Assert.IsFalse(task.IsCompleted); replicationInfo.Setup(item => item.Slaves).Returns(new[] { SlaveInformation.Parse("ip=127.0.0.1,port=6666,state=online,offset=2000,lag=0") }); scheduler.AdvanceBy(ticks); Thread.Sleep(100); Assert.IsTrue(task.IsCompleted); }
public void ParseInvalid() { Assert.Throws <ArgumentException>(() => SlaveInformation.Parse(null)); Assert.Throws <ArgumentOutOfRangeException>(() => SlaveInformation.Parse("ip=127.0.0.1,port=6027,state=online")); }