public RendezvousClusterTests() { configurationStorage = new Mock <IConfigurationStorage <RendezvousClusterConfiguration> >(); cluster = new RendezvousClusterConfiguration { Cluster = Randomizer.Int32(3, 6) .Produce(i => new RendezvousEndpoint($"tcp://*:808{i}", $"tcp://*:909{i}")) }; configurationStorage.Setup(m => m.Read()).Returns(cluster); rendezvousCluster = new RendezvousCluster(configurationStorage.Object); }
public void Setup() { configurationStorage = new Mock <IConfigurationStorage <RendezvousClusterConfiguration> >(); cluster = new RendezvousClusterConfiguration { Cluster = EnumerableExtensions.Produce(Randomizer.Int32(3, 6), i => new RendezvousEndpoint($"tcp://*:808{i}", $"tcp://*:909{i}")) }; configurationStorage.Setup(m => m.Read()).Returns(cluster); rendezvousCluster = new RendezvousCluster(configurationStorage.Object); }
public void Update_RemovesAllPreviousRendezvousEndpointsAndAddsNewOnes() { var config = new RendezvousClusterConfiguration { Cluster = Randomizer.Int32(3, 6) .Produce(i => new RendezvousEndpoint($"tcp://*:8{i}80", $"tcp://*:9{i}90")) }; initialConfiguration.Should().BeEquivalentTo(configStorage.Read().Cluster); // configStorage.Update(config); // config.Cluster.Should().BeEquivalentTo(configStorage.Read().Cluster); }
public void IfRendezvousClusterReconfigured_OldEndpointsRemovedAndNewAdded() { var newCluster = new RendezvousClusterConfiguration { Cluster = Randomizer.Int32(3, 6) .Produce(i => new RendezvousEndpoint($"tcp://*:8{i}8".ParseAddress().ToSocketAddress(), $"tcp://*:9{i}9".ParseAddress().ToSocketAddress())) }; configurationStorage.Setup(m => m.Read()).Returns(newCluster); // rendezvousCluster.Reconfigure(newCluster.Cluster); // foreach (var rendezvousEndpoint in newCluster.Cluster) { Assert.Equal(rendezvousEndpoint, rendezvousCluster.GetCurrentRendezvousServer()); rendezvousCluster.RotateRendezvousServers(); } foreach (var rendezvousEndpoint in cluster.Cluster) { Assert.NotEqual(rendezvousEndpoint, rendezvousCluster.GetCurrentRendezvousServer()); rendezvousCluster.RotateRendezvousServers(); } }