Пример #1
0
        public void TestThatRoundRobinLoadBlancingWithOneServerWorks()
        {
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };

            _settingsDefault.Config.Servers = new[] { server1 };

            var loadBalancer = new MockLoadBalancer {
                Mode = LbMode.RoundRobin
            };

            var sequnceManager = new ExecutionSequenceManager(_settingsDefault.Config.Servers, loadBalancer);

            sequnceManager.NewRemoteSequence("Test");

            var status = new StatusReporter();

            //remoteSequence.Execute(status, _settingsDefault, _token);
            sequnceManager.Execute(status, _settingsDefault, _token);

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(2));

            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[1].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[1].Item2, Is.EqualTo("online"));
        }
Пример #2
0
        public void TestThatStickyLoadBlancingWithOneServerAndManuelTestWorks()
        {
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };

            _settingsStopAfterMarkedServer.Config.Servers = new[] { server1 };

            var loadBalancer = new MockLoadBalancer {
                Mode = LbMode.Sticky
            };

            var sequnceManager = new ExecutionSequenceManager(_settingsStopAfterMarkedServer.Config.Servers, loadBalancer);

            sequnceManager.NewRemoteSequence("Test");

            var status = new StatusReporter();

            sequnceManager.Execute(status, _settingsStopAfterMarkedServer, _token);

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(1));

            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item2, Is.EqualTo("offline"));
        }
Пример #3
0
        public void TestThatStickyWithContinueAfterManualTestExecutesOnCorrectServers()
        {
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };
            var server2 = new ServerConfig {
                Name = "jat-web02"
            };
            var server3 = new ServerConfig {
                Name = "jat-web03"
            };
            var server4 = new ServerConfig {
                Name = "jat-web04"
            };
            var server5 = new ServerConfig {
                Name = "jat-web05"
            };

            _settingsContinueAfterMarkedServer.Config.Servers = new[] { server1, server2, server3, server4, server5 };

            var loadBalancer = new MockLoadBalancer {
                Mode = LbMode.Sticky
            };

            var sequnceManager = new ExecutionSequenceManager(_settingsContinueAfterMarkedServer.Config.Servers, loadBalancer);

            sequnceManager.NewRemoteSequence("Test");

            var status = new StatusReporter();

            //remoteSequence.Execute(status, _settingsContinueAfterMarkedServer, _token);
            sequnceManager.Execute(status, _settingsContinueAfterMarkedServer, _token);

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(((_settingsContinueAfterMarkedServer.Config.Servers.Count - 1) * 2) + 1));

            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item2, Is.EqualTo("online"));

            var serverNumber = 2;

            for (int i = 1; i < loadBalancer.OnlineOfflineSequence.Count; i += 2)
            {
                Assert.That(loadBalancer.OnlineOfflineSequence[i].Item1, Is.EqualTo("jat-web0" + serverNumber));
                Assert.That(loadBalancer.OnlineOfflineSequence[i].Item2, Is.EqualTo("offline"));

                Assert.That(loadBalancer.OnlineOfflineSequence[i + 1].Item1, Is.EqualTo("jat-web0" + serverNumber));
                Assert.That(loadBalancer.OnlineOfflineSequence[i + 1].Item2, Is.EqualTo("online"));
                serverNumber++;
            }
        }
Пример #4
0
        public void TestThatStickyLoadBalancingGoesOnlineOfflineInCorrectOrder()
        {
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };
            var server2 = new ServerConfig {
                Name = "jat-web02"
            };
            var server3 = new ServerConfig {
                Name = "jat-web03"
            };
            var server4 = new ServerConfig {
                Name = "jat-web04"
            };
            var server5 = new ServerConfig {
                Name = "jat-web05"
            };

            _settingsDefault.Config.Servers = new[] { server1, server2, server3, server4, server5 };

            var loadBalancer = new MockLoadBalancer {
                Mode = LbMode.Sticky
            };

            var sequnceManager = new ExecutionSequenceManager(_settingsDefault.Config.Servers, loadBalancer);

            sequnceManager.NewRemoteSequence("Test");

            var status = new StatusReporter();

            //remoteSequence.Execute(status, _settingsDefault, _token);
            sequnceManager.Execute(status, _settingsDefault, _token);

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(_settingsDefault.Config.Servers.Count * 2));

            var serverNumber = 1;

            for (int i = 0; i < loadBalancer.OnlineOfflineSequence.Count; i += 2)
            {
                Assert.That(loadBalancer.OnlineOfflineSequence[i].Item1, Is.EqualTo("jat-web0" + serverNumber));
                Assert.That(loadBalancer.OnlineOfflineSequence[i].Item2, Is.EqualTo("offline"));

                Assert.That(loadBalancer.OnlineOfflineSequence[i + 1].Item1, Is.EqualTo("jat-web0" + serverNumber));
                Assert.That(loadBalancer.OnlineOfflineSequence[i + 1].Item2, Is.EqualTo("online"));
                serverNumber++;
            }
        }
Пример #5
0
        public void TestThatRoundRobinWithContinueAfterManuelTestOnSpecificServerExecuteCorrectServers()
        {
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };
            var server2 = new ServerConfig {
                Name = "jat-web02"
            };
            var server3 = new ServerConfig {
                Name = "jat-web03", StopServer = true
            };
            var server4 = new ServerConfig {
                Name = "jat-web04"
            };
            var server5 = new ServerConfig {
                Name = "jat-web05"
            };

            _settingsStopAfterMarkedServer.Config.Servers = new[] { server1, server2, server3, server4, server5 };

            var loadBalancer = new MockLoadBalancer {
                Mode = LbMode.RoundRobin
            };

            var sequnceManager = new ExecutionSequenceManager(_settingsStopAfterMarkedServer.Config.Servers, loadBalancer);

            sequnceManager.NewRemoteSequence("Test");

            var status = new StatusReporter();

            sequnceManager.Execute(status, _settingsStopAfterMarkedServer, _token);

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(1));

            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item1, Is.EqualTo("jat-web03"));
            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item2, Is.EqualTo("offline"));
        }
Пример #6
0
        public void TestThatStickyWithContinueAfterManualTestOnSpecificServerExecutesOnCorrectServers()
        {
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };
            var server2 = new ServerConfig {
                Name = "jat-web02"
            };
            var server3 = new ServerConfig {
                Name = "jat-web03", StopServer = true
            };
            var server4 = new ServerConfig {
                Name = "jat-web04"
            };
            var server5 = new ServerConfig {
                Name = "jat-web05"
            };

            _settingsContinueAfterMarkedServer.Config.Servers = new[] { server1, server2, server3, server4, server5 };

            var loadBalancer = new MockLoadBalancer {
                Mode = LbMode.Sticky
            };

            var sequnceManager = new ExecutionSequenceManager(_settingsContinueAfterMarkedServer.Config.Servers, loadBalancer);

            sequnceManager.NewRemoteSequence("Test");

            var status = new StatusReporter();

            //remoteSequence.Execute(status, _settingsContinueAfterMarkedServer, _token);
            sequnceManager.Execute(status, _settingsContinueAfterMarkedServer, _token);

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(((_settingsContinueAfterMarkedServer.Config.Servers.Count - 1) * 2) + 1));

            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item1, Is.EqualTo("jat-web03"));
            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[1].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[1].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[2].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[2].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[3].Item1, Is.EqualTo("jat-web02"));
            Assert.That(loadBalancer.OnlineOfflineSequence[3].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[4].Item1, Is.EqualTo("jat-web02"));
            Assert.That(loadBalancer.OnlineOfflineSequence[4].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[5].Item1, Is.EqualTo("jat-web04"));
            Assert.That(loadBalancer.OnlineOfflineSequence[5].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[6].Item1, Is.EqualTo("jat-web04"));
            Assert.That(loadBalancer.OnlineOfflineSequence[6].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[7].Item1, Is.EqualTo("jat-web05"));
            Assert.That(loadBalancer.OnlineOfflineSequence[7].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[8].Item1, Is.EqualTo("jat-web05"));
            Assert.That(loadBalancer.OnlineOfflineSequence[8].Item2, Is.EqualTo("online"));
        }
Пример #7
0
        public void TestThatRoundRobinLoadBalancingGoesOnlineOfflineInCorrectOrder()
        {
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };
            var server2 = new ServerConfig {
                Name = "jat-web02"
            };
            var server3 = new ServerConfig {
                Name = "jat-web03"
            };
            var server4 = new ServerConfig {
                Name = "jat-web04"
            };
            var server5 = new ServerConfig {
                Name = "jat-web05"
            };

            _settingsDefault.Config.Servers = new[] { server1, server2, server3, server4, server5 };

            var loadBalancer = new MockLoadBalancer {
                Mode = LbMode.RoundRobin
            };

            var sequnceManager = new ExecutionSequenceManager(_settingsDefault.Config.Servers, loadBalancer);

            sequnceManager.NewRemoteSequence("Test");

            var status = new StatusReporter();

            //remoteSequence.Execute(status, _settingsDefault, _token);
            sequnceManager.Execute(status, _settingsDefault, _token);


            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(_settingsDefault.Config.Servers.Count * 2));

            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[0].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[1].Item1, Is.EqualTo("jat-web02"));
            Assert.That(loadBalancer.OnlineOfflineSequence[1].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[2].Item1, Is.EqualTo("jat-web03"));
            Assert.That(loadBalancer.OnlineOfflineSequence[2].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[3].Item1, Is.EqualTo("jat-web01"));
            Assert.That(loadBalancer.OnlineOfflineSequence[3].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[4].Item1, Is.EqualTo("jat-web02"));
            Assert.That(loadBalancer.OnlineOfflineSequence[4].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[5].Item1, Is.EqualTo("jat-web03"));
            Assert.That(loadBalancer.OnlineOfflineSequence[5].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[6].Item1, Is.EqualTo("jat-web04"));
            Assert.That(loadBalancer.OnlineOfflineSequence[6].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[7].Item1, Is.EqualTo("jat-web05"));
            Assert.That(loadBalancer.OnlineOfflineSequence[7].Item2, Is.EqualTo("offline"));

            Assert.That(loadBalancer.OnlineOfflineSequence[8].Item1, Is.EqualTo("jat-web04"));
            Assert.That(loadBalancer.OnlineOfflineSequence[8].Item2, Is.EqualTo("online"));

            Assert.That(loadBalancer.OnlineOfflineSequence[9].Item1, Is.EqualTo("jat-web05"));
            Assert.That(loadBalancer.OnlineOfflineSequence[9].Item2, Is.EqualTo("online"));
        }
Пример #8
0
        internal ConDepExecutionResult Execute(ConDepSettings settings, IValidateClient clientValidator, IValidateServer serverValidator, ExecutionSequenceManager execManager, CancellationToken token)
        {
            if (settings == null)
            {
                throw new ArgumentException("settings");
            }
            if (settings.Config == null)
            {
                throw new ArgumentException("settings.Config");
            }
            if (settings.Options == null)
            {
                throw new ArgumentException("settings.Options");
            }
            if (clientValidator == null)
            {
                throw new ArgumentException("clientValidator");
            }
            if (serverValidator == null)
            {
                throw new ArgumentException("serverValidator");
            }
            if (execManager == null)
            {
                throw new ArgumentException("execManager");
            }

            ServicePointManager.ServerCertificateValidationCallback = ValidateConDepNodeServerCert;

            var status = new StatusReporter();

            try
            {
                Validate(clientValidator, serverValidator);

                ExecutePreOps(settings, status, token);
                _serverNodeInstalled = true;

                //Todo: Result of merge. Not sure if this is correct.
                token.Register(() => Cancel(settings, status, token));

                var notification = new Notification();
                if (!execManager.IsValid(notification))
                {
                    notification.Throw();
                }

                execManager.Execute(status, settings, token);
                return(new ConDepExecutionResult(true));
            }
            catch (OperationCanceledException)
            {
                Cancel(settings, status, token);
                return(new ConDepExecutionResult(false)
                {
                    Cancelled = true
                });
            }
            catch (AggregateException aggEx)
            {
                var result = new ConDepExecutionResult(false);
                aggEx.Handle(inner =>
                {
                    if (inner is OperationCanceledException)
                    {
                        Cancel(settings, status, token);
                        result.Cancelled = true;
                        Logger.Warn("ConDep execution cancelled.");
                    }
                    else
                    {
                        result.AddException(inner);
                        Logger.Error("ConDep execution failed.", inner);
                    }

                    return(true);
                });
                return(result);
            }
            catch (Exception ex)
            {
                var result = new ConDepExecutionResult(false);
                result.AddException(ex);
                Logger.Error("ConDep execution failed.", ex);
                return(result);
            }
            finally
            {
                if (!_cancelled)
                {
                    ExecutePostOps(settings, status, token);
                }
            }
        }
Пример #9
0
        private void Execute(Assembly assembly, ConDepConfig envConfig, ConDepOptions options, IReportStatus status)
        {
            if (assembly == null)
            {
                throw new ArgumentException("assembly");
            }
            if (envConfig == null)
            {
                throw new ArgumentException("envSettings");
            }
            if (options == null)
            {
                throw new ArgumentException("options");
            }
            if (status == null)
            {
                throw new ArgumentException("status");
            }

            var applications = CreateApplicationArtifacts(options, assembly);

            if (!options.WebDeployExist)
            {
                var serverValidator = new RemoteServerValidator(envConfig.Servers);
                if (!serverValidator.IsValid())
                {
                    Logger.Error("Not all servers fulfill ConDep's requirements. Aborting execution.");
                    return;
                }
            }

            var webDeploy = new WebDeployHandler();
            var lbLookup  = new LoadBalancerLookup(envConfig.LoadBalancer);

            var sequenceManager = new ExecutionSequenceManager(lbLookup.GetLoadBalancer());

            var notification = new Notification();
            var postOpSeq    = new PostOpsSequence();

            foreach (var application in applications)
            {
                var infrastructureSequence = new InfrastructureSequence();
                var preOpsSequence         = new PreOpsSequence(webDeploy);
                if (!options.DeployOnly)
                {
                    var infrastructureBuilder = new InfrastructureBuilder(infrastructureSequence, webDeploy);
                    Configure.InfrastructureOperations = infrastructureBuilder;

                    if (HasInfrastructureDefined(application))
                    {
                        var infrastructureInstance = GetInfrastructureArtifactForApplication(assembly, application);
                        if (!infrastructureSequence.IsValid(notification))
                        {
                            notification.Throw();
                        }
                        infrastructureInstance.Configure(infrastructureBuilder, envConfig);
                    }
                }

                var local = new LocalOperationsBuilder(sequenceManager.NewLocalSequence(application.GetType().Name), infrastructureSequence, preOpsSequence, envConfig.Servers, webDeploy);
                Configure.LocalOperations = local;

                application.Configure(local, envConfig);
            }

            if (!sequenceManager.IsValid(notification))
            {
                notification.Throw();
            }

            sequenceManager.Execute(status, envConfig, options);
            postOpSeq.Execute(status, options);
        }