Пример #1
0
        public IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options)
        {
            try
            {
                Logger.LogSectionStart(_name);
                foreach (var element in _sequence)
                {
                    if (element is LocalOperation)
                    {
                        Logger.LogSectionStart(element.GetType().Name);
                        ((LocalOperation)element).Execute(status, config, options);
                        Logger.LogSectionEnd(element.GetType().Name);
                    }
                    else if (element is RemoteSequence)
                    {
                        ((RemoteSequence)element).Execute(status, options);
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }

                    if (status.HasErrors)
                    {
                        return(status);
                    }
                }
                return(status);
            }
            finally
            {
                Logger.LogSectionEnd(_name);
            }
        }
Пример #2
0
        public void TestThatExecutionSequenceIsValid()
        {
            var config = new ConDepConfig {
                EnvironmentName = "bogusEnv"
            };
            var server = new ServerConfig {
                Name = "jat-web03"
            };

            config.Servers = new[] { server };

            var infrastructureSequence = new InfrastructureSequence();
            var preOpsSequence         = new PreOpsSequence(new WebDeployHandlerMock());

            var webDeploy             = new WebDeployHandlerMock();
            var infrastructureBuilder = new InfrastructureBuilder(infrastructureSequence, webDeploy);

            _infra.Configure(infrastructureBuilder, config);

            var local = new LocalOperationsBuilder(_sequenceManager.NewLocalSequence("Test"), infrastructureSequence, preOpsSequence, config.Servers, webDeploy);

            _app.Configure(local, config);

            var notification = new Notification();

            Assert.That(_sequenceManager.IsValid(notification));
        }
Пример #3
0
        public void TestThatRoundRobinLoadBlancingWithOneServerAndManuelTestWorks()
        {
            var config = new ConDepConfig {
                EnvironmentName = "bogusEnv"
            };
            var server1 = new ServerConfig {
                Name = "jat-web01"
            };

            config.Servers = new[] { server1 };

            var infrastructureSequence = new InfrastructureSequence();
            var preOpsSequence         = new PreOpsSequence(new WebDeployHandlerMock());
            var loadBalancer           = new MockLoadBalancer {
                Mode = LbMode.RoundRobin
            };

            var remoteSequence = new RemoteSequence(infrastructureSequence, preOpsSequence, config.Servers, loadBalancer);

            var status = new StatusReporter();

            remoteSequence.Execute(status, new ConDepOptions(false, "", false, true, true, false, null));

            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"));
        }
Пример #4
0
        public override IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options)
        {
            var configFilePath    = Path.Combine(_configDirPath, _configName);
            var transformFilePath = Path.Combine(_configDirPath, _transformName);
            var backupPath        = "";

            if (ConDepConfigBackupExist(_configDirPath, _configName))
            {
                Logger.Info("Using [{0}] as configuration file to transform", _configDirPath + CONDEP_CONFIG_EXTENSION);
                backupPath = Path.Combine(_configDirPath, _configName + CONDEP_CONFIG_EXTENSION);
            }
            else
            {
                BackupConfigFile(_configDirPath, _configName);
            }

            Logger.Info("Transforming [{0}] using [{1}]", configFilePath, transformFilePath);
            var trans = new SlowCheetah.Tasks.TransformXml
            {
                BuildEngine = new TransformConfigBuildEngine(),
                Source      = string.IsNullOrWhiteSpace(backupPath) ? configFilePath : backupPath,
                Transform   = transformFilePath,
                Destination = configFilePath
            };

            var success = trans.Execute();

            if (!success)
            {
                throw new CondepWebConfigTransformException(string.Format("Failed to transform [{0}] file.", _configName));
            }

            return(status);
        }
Пример #5
0
        public void Setup()
        {
            var memStream      = new MemoryStream(Encoding.UTF8.GetBytes(_json));
            var tiersMemStream = new MemoryStream(Encoding.UTF8.GetBytes(_tiersJson));

            var parser = new EnvConfigParser();

            _config      = parser.GetEnvConfig(memStream);
            _tiersConfig = parser.GetEnvConfig(tiersMemStream);
        }
Пример #6
0
 public IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options)
 {
     foreach (var localSequence in _sequence)
     {
         localSequence.Execute(status, config, options);
         if (status.HasErrors)
         {
             return(status);
         }
     }
     return(status);
 }
Пример #7
0
        public void TestThatStickyWithContinueAfterManualTestExecutesOnCorrectServers()
        {
            var config = new ConDepConfig {
                EnvironmentName = "bogusEnv"
            };
            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"
            };

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

            var infrastructureSequence = new InfrastructureSequence();
            var preOpsSequence         = new PreOpsSequence(new WebDeployHandlerMock());
            var loadBalancer           = new MockLoadBalancer {
                Mode = LbMode.Sticky
            };

            var remoteSequence = new RemoteSequence(infrastructureSequence, preOpsSequence, config.Servers, loadBalancer);

            var status = new StatusReporter();

            remoteSequence.Execute(status, new ConDepOptions(false, "", false, true, false, true, null));

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(((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++;
            }
        }
Пример #8
0
        public override IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options)
        {
            try
            {
                if (Directory.Exists(_preCompileOutputpath))
                {
                    Directory.Delete(_preCompileOutputpath, true);
                }

                _buildManager.PrecompileApplication(new PreCompileCallback());
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                throw;
            }
            return(status);
        }
Пример #9
0
        public void TestThatRoundRobinWithContinueAfterManuelTestOnSpecificServerExecuteCorrectServers()
        {
            var config = new ConDepConfig {
                EnvironmentName = "bogusEnv"
            };
            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"
            };

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

            var infrastructureSequence = new InfrastructureSequence();
            var preOpsSequence         = new PreOpsSequence(new WebDeployHandlerMock());
            var loadBalancer           = new MockLoadBalancer {
                Mode = LbMode.RoundRobin
            };

            var remoteSequence = new RemoteSequence(infrastructureSequence, preOpsSequence, config.Servers, loadBalancer);

            var status = new StatusReporter();

            remoteSequence.Execute(status, new ConDepOptions(false, "", false, true, true, false, null));

            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"));
        }
Пример #10
0
        public override IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options)
        {
            var webRequest = System.Net.WebRequest.Create(_url);

            webRequest.Method        = "GET";
            webRequest.ContentLength = 0;
            webRequest.ContentType   = "application/x-www-form-urlencoded";

            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

            HttpStatusCode statusCode = ((HttpWebResponse)webRequest.GetResponse()).StatusCode;

            if (statusCode == HttpStatusCode.OK)
            {
                Logger.Info("HTTP {0} Succeeded: {1}", "GET", _url);
            }
            else
            {
                throw new WebException(string.Format("GET request did not return with 200 (OK), but {0} ({1})", (int)statusCode, statusCode));
            }

            return(status);
        }
Пример #11
0
        public void TestThatRoundRobinLoadBalancingGoesOnlineOfflineInCorrectOrder()
        {
            var config = new ConDepConfig {
                EnvironmentName = "bogusEnv"
            };
            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"
            };

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

            var infrastructureSequence = new InfrastructureSequence();
            var preOpsSequence         = new PreOpsSequence(new WebDeployHandlerMock());
            var loadBalancer           = new MockLoadBalancer {
                Mode = LbMode.RoundRobin
            };

            var remoteSequence = new RemoteSequence(infrastructureSequence, preOpsSequence, config.Servers, loadBalancer);

            var status = new StatusReporter();

            remoteSequence.Execute(status, new ConDepOptions(false, "", false, true, false, false, null));

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(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"));
        }
Пример #12
0
 public override void Configure(IOfferInfrastructure require, ConDepConfig config)
 {
     require.IIS();
 }
Пример #13
0
 public override void Configure(IOfferLocalOperations local, ConDepConfig config)
 {
     local.HttpGet("http://www.con-dep.net");
     local.ToEachServer(server => server.ExecuteRemote.PowerShell("ipconfig"));
     local.HttpGet("http://blog.torresdal.net");
 }
Пример #14
0
 public static void ExecuteFromAssembly(Assembly assembly, ConDepConfig envSettings, ConDepOptions options, IReportStatus status)
 {
     new ConDepConfigurationExecutor().Execute(assembly, envSettings, options, status);
 }
Пример #15
0
 public abstract void Configure(IOfferLocalOperations onLocalMachine, ConDepConfig config);
Пример #16
0
 public abstract void Configure(IOfferInfrastructure require, ConDepConfig config);
Пример #17
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);
        }
Пример #18
0
 public abstract IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options);