Esempio n. 1
0
        public void Should_use_default_replica_builder()
        {
            CreateEnvironmentNode("default");

            using (var beacon = new ServiceBeacon(ZooKeeperClient))
            {
                beacon.Start();
                beacon.WaitForInitialRegistrationAsync().ShouldCompleteIn(DefaultTimeout);

                var builder = ReplicaInfoBuilder.Build(null, true);
                var path    = new ServiceDiscoveryPathHelper(new ServiceBeaconSettings().ZooKeeperNodesPrefix, ZooKeeperPathEscaper.Instance)
                              .BuildReplicaPath(builder.Environment, builder.Application, builder.Replica);
                var data = ZooKeeperClient.GetData(path).Data;
                var dict = ReplicaNodeDataSerializer.Deserialize(builder.Environment, builder.Application, builder.Replica, data).Properties;

                dict[ReplicaInfoKeys.Application].Should().Be(builder.Application);
            }
        }
Esempio n. 2
0
        public void Should_not_throw_if_someone_else_dispose_zookeeper_client_after_start()
        {
            var disposedClient = GetZooKeeperClient();

            var replica = new ReplicaInfo("default", "vostok", "https://github.com/vostok");

            CreateEnvironmentNode(replica.Environment);

            using (var beacon = new ServiceBeacon(disposedClient, replica, null, Log))
            {
                ReplicaRegistered(replica).Should().BeFalse();

                beacon.Start();
                beacon.WaitForInitialRegistrationAsync().ShouldCompleteIn(DefaultTimeout);
                ReplicaRegistered(replica).Should().BeTrue();

                disposedClient.Dispose();

                beacon.Stop();
            }
        }
Esempio n. 3
0
        public void Should_use_replica_builder()
        {
            var url = "https://github.com/vostok";

            CreateEnvironmentNode("default");

            using (var beacon = new ServiceBeacon(
                       ZooKeeperClient,
                       setup => setup.SetUrl(new Uri(url)).SetApplication("test")))
            {
                beacon.Start();
                beacon.WaitForInitialRegistrationAsync().ShouldCompleteIn(DefaultTimeout);

                var path = new ServiceDiscoveryPathHelper(new ServiceBeaconSettings().ZooKeeperNodesPrefix, ZooKeeperPathEscaper.Instance)
                           .BuildReplicaPath("default", "test", url);
                var data = ZooKeeperClient.GetData(path).Data;
                var dict = ReplicaNodeDataSerializer.Deserialize("default", "test", url, data).Properties;

                dict[ReplicaInfoKeys.Replica].Should().Be(url);
                dict[ReplicaInfoKeys.Application].Should().Be("test");
            }
        }