public void DeployNew_should_not_run_instances_if_specified(int instances)
 {
     using (var ensemble = ZooKeeperEnsemble.DeployNew(instances, log, false))
     {
         ensemble.IsRunning.Should().BeFalse();
     }
 }
Ejemplo n.º 2
0
        public HerculesCluster Deploy()
        {
            Directory.CreateDirectory(baseDirectory);
            var downloader = new HerculesDownloader(baseDirectory, log);

            herculesBinariesPaths = downloader.GetLatestBinaries(ComponentNames.Values.ToArray());
            HerculesLoggerAppender.AppendLogger(downloader.GetLogger(), herculesBinariesPaths.Values, log);

            var cluster = new HerculesCluster();

            try
            {
                cluster.ZooKeeperEnsemble = ZooKeeperEnsemble.DeployNew(new ZooKeeperEnsembleSettings {
                    BaseDirectory = baseDirectory
                }, log);
                cluster.KafkaInstance = KafkaInstance.DeployNew(new KafkaSettings {
                    BaseDirectory = baseDirectory, ZooKeeperConnectionString = cluster.ZooKeeperEnsemble.ConnectionString
                }, log);

                DeployHercules(cluster);

                return(cluster);
            }
            catch (Exception error)
            {
                log.Error(error, "Error in deploy. Will try to cleanup.");
                cluster.Dispose();
                throw;
            }
        }
 public void DeployNew_should_run_instances(int instances)
 {
     using (var ensemble = ZooKeeperEnsemble.DeployNew(instances, log))
     {
         ensemble.IsRunning.Should().BeTrue();
     }
 }
        public void GetConnectedClient_should_reconnect_to_new_ensemble_after_timeout()
        {
            using (var ensemble1 = ZooKeeperEnsemble.DeployNew(10, 1, Log))
            {
                var connectionString = ensemble1.ConnectionString;
                // ReSharper disable once AccessToModifiedClosure
                var settings = new ZooKeeperClientSettings(() => connectionString)
                {
                    Timeout = DefaultTimeout
                };

                var holder = new ClientHolder(settings, Log);
                WaitForNewConnectedClient(holder);

                ensemble1.Dispose();
                WaitForDisconnectedState(holder);

                using (var ensemble2 = ZooKeeperEnsemble.DeployNew(11, 1, Log))
                {
                    ensemble2.ConnectionString.Should().NotBe(connectionString);
                    connectionString = ensemble2.ConnectionString;

                    Thread.Sleep(DefaultTimeout);

                    WaitForNewConnectedClient(holder);
                }
            }
        }
 public void DeployNew_should_use_from_index()
 {
     using (var ensemble1 = ZooKeeperEnsemble.DeployNew(1, 3, log))
         using (var ensemble2 = ZooKeeperEnsemble.DeployNew(10, 3, log))
         {
             ensemble1.IsRunning.Should().BeTrue();
             ensemble2.IsRunning.Should().BeTrue();
         }
 }
        public void DeployNew_should_run_multiple_times(int instances)
        {
            using (ZooKeeperEnsemble.DeployNew(instances, log))
            {
            }

            using (ZooKeeperEnsemble.DeployNew(instances, log))
            {
            }
        }
 public void Instances_should_be_stoppable_and_startable(int index)
 {
     using (var ensemble = ZooKeeperEnsemble.DeployNew(3, log))
     {
         ensemble.Instances[index].IsRunning.Should().BeTrue("Before stop.");
         ensemble.Instances[index].Stop();
         ensemble.Instances[index].IsRunning.Should().BeFalse("After stop.");
         ensemble.Instances[index].Start();
         ensemble.Instances[index].IsRunning.Should().BeTrue("After restart.");
     }
 }
Ejemplo n.º 8
0
        public void DeployNew_should_run_instances_on_specified_ports()
        {
            var port1 = FreeTcpPortFinder.GetFreePort();
            var port2 = FreeTcpPortFinder.GetFreePort();

            using (var ensemble = ZooKeeperEnsemble.DeployNew(
                       new ZooKeeperEnsembleSettings
            {
                Size = 2,
                InstancesPorts = new List <int> {
                    port1, port2
                }
            },
                       log))
            {
                ensemble.IsRunning.Should().BeTrue();
                ensemble.Instances.Count.Should().Be(2);
                ensemble.Instances[0].ClientPort.Should().Be(port1);
                ensemble.Instances[1].ClientPort.Should().Be(port2);
            }
        }
Ejemplo n.º 9
0
        public void DeployNew_should_fail_to_start_if_port_is_busy()
        {
            var port     = FreeTcpPortFinder.GetFreePort();
            var listener = new TcpListener(IPAddress.Loopback, port);

            try
            {
                listener.Start();
                Action deployment = () => ZooKeeperEnsemble.DeployNew(
                    new ZooKeeperEnsembleSettings
                {
                    InstancesPorts = new List <int> {
                        port
                    }
                },
                    log);

                deployment.Should().Throw <Exception>();
            }
            finally
            {
                listener.Stop();
            }
        }
        public void GetConnectedClient_should_reconnect_to_new_ensemble_after_connection_string_change(bool useUri)
        {
            using (var ensemble1 = ZooKeeperEnsemble.DeployNew(10, 1, Log))
            {
                var currentEnsemble = ensemble1;
                var settings        = useUri
                    ? new ZooKeeperClientSettings(() => currentEnsemble.Topology)
                {
                    Timeout = DefaultTimeout
                }
                    : new ZooKeeperClientSettings(() => currentEnsemble.ConnectionString)
                {
                    Timeout = DefaultTimeout
                };

                var holder   = new ClientHolder(settings, Log);
                var observer = GetObserver(holder);

                WaitForNewConnectedClient(holder);
                var sid1 = holder.SessionId;

                using (var ensemble2 = ZooKeeperEnsemble.DeployNew(11, 1, Log))
                {
                    currentEnsemble = ensemble2;

                    WaitForNewConnectedClient(holder);
                    ensemble1.Stop();
                    WaitForNewConnectedClient(holder);

                    var sid2 = holder.SessionId;
                    sid2.Should().NotBe(sid1);
                }

                VerifyObserverMessages(observer, ConnectionState.Disconnected, ConnectionState.Connected, ConnectionState.Disconnected, ConnectionState.Connected);
            }
        }
Ejemplo n.º 11
0
 public void OneTimeSetUp()
 {
     Ensemble = ZooKeeperEnsemble.DeployNew(1, Log);
 }
 public void OneTimeSetUpBase()
 {
     ensemble = ZooKeeperEnsemble.DeployNew(1, log);
 }
Ejemplo n.º 13
0
 public void OneTimeSetUp()
 {
     EventsQueue     = new ActionsQueue(Log);
     Ensemble        = ZooKeeperEnsemble.DeployNew(1, Log);
     ZooKeeperClient = GetZooKeeperClient();
 }
Ejemplo n.º 14
0
 private ZooKeeperEnsemble DeployZooKeeper()
 {
     return(ZooKeeperEnsemble.DeployNew(1, log));
 }