Ejemplo n.º 1
0
 public override void Configure(IOfferInfrastructure require, ConDepConfig config)
 {
     require.IIS();
     require
         .IIS()
         .IISAppPool("Bogus", options => options
             .Enable32Bit(false)
             .IdleTimeoutInMinutes(0)
             .LoadUserProfile(true)
             .ManagedPipeline(ManagedPipeline.Integrated)
             .NetFrameworkVersion(NetFrameworkVersion.Net4_0)
             .RecycleTimeInMinutes(0)
         )
         .SslCertificate.FromFile(@"C:\somecert.pfx", "12345", certOpt => certOpt.AddPrivateKeyPermission("torresdal\\condeptest"))
         //.SslCertificate.FromStore(X509FindType.FindByThumbprint, "cb 5f 27 74 dc 0a 00 65 ba 5a ab 23 b4 63 ab 3f 9c 48 8e 5c", certOpt => certOpt.AddPrivateKeyPermission("z63\\__104171dep"))
         .IISWebSite("ConDepWebSite55", 5, opt => opt
                                                      .AddHttpBinding(httpOpt => httpOpt
                                                          .HostName("www.con-dep.net")
                                                          .Port(80))
                                                      .AddHttpsBinding(
                                                         X509FindType.FindByThumbprint,
                                                         "cb 5f 27 74 dc 0a 00 65 ba 5a ab 23 b4 63 ab 3f 9c 48 8e 5c",
                                                         binding => binding.HostName("www.con-dep.net").Port(443)
                                                      )
                                                      .ApplicationPool("Bogus")
                                                      .WebApp("MyWebApp", webAppOpt => webAppOpt
                                                          .PhysicalPath(@"C:\temp\MyWebApp"))
             );
 }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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"));
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        public void TestThatRoundRobinLoadBlancingWithOneServerAndContinueWorks()
        {
            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, false, true, 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("online"));
        }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
0
        public override IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options)
        {
            var webRequest = System.Net.WebRequest.Create(_url);
            webRequest.Method = _method;
            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}", _method.ToUpper(), _url);
            }
            else
            {
                Logger.Error("HTTP {0} Failed with Status {1}: {2}", _method.ToUpper(), statusCode, _url);
            }

            return status;
        }
Ejemplo n.º 9
0
 public void Setup()
 {
     var memStream = new MemoryStream(Encoding.UTF8.GetBytes(_json));
     var parser = new EnvConfigParser();
     _config = parser.GetEnvConfig(memStream);
 }
Ejemplo n.º 10
0
 public abstract void Configure(IOfferLocalOperations local, ConDepConfig config);
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
 public static void ExecuteFromAssembly(Assembly assembly, ConDepConfig envSettings, ConDepOptions options, IReportStatus status)
 {
     new ConDepConfigurationExecutor().Execute(assembly, envSettings, options, status);
 }
Ejemplo n.º 13
0
 public abstract void Configure(IOfferLocalOperations onLocalMachine, ConDepConfig config);
Ejemplo n.º 14
0
 //private IOfferRemoteOperations CreateRemoteServers(TinyIoCContainer container, NamedParameterOverloads overloads)
 //{
 //    if(_remote == null)
 //    {
 //        //var webDeploy = container.Resolve<IOperateWebDeploy>();
 //        //_remote = new RemoteOperationsBuilder(_execSeq, _envConfig.Servers, webDeploy);
 //        _remote = new RemoteOperationsBuilder(new );
 //    }
 //    return _remote;
 //}
 public static void Bootstrap(ConDepConfig envSettings)
 {
     new IoCBootstrapper(envSettings).BootstrapTinyIoC();
 }
Ejemplo n.º 15
0
        public void TestThatStickyWithContinueAfterManualTestOnSpecificServerExecutesOnCorrectServers()
        {
            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.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-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"));
        }
Ejemplo n.º 16
0
        public void TestThatStickyLoadBalancingGoesOnlineOfflineInCorrectOrder()
        {
            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, false, null));

            Assert.That(loadBalancer.OnlineOfflineSequence.Count, Is.EqualTo(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++;
            }
        }
Ejemplo n.º 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 = new List<ApplicationArtifact>();
            if(options.HasContext())
            {
                var type = assembly.GetTypes().Where(t => typeof(ApplicationArtifact).IsAssignableFrom(t) && t.Name == options.Context).Single();
                if (type == null)
                {
                    throw new ConDepConfigurationTypeNotFoundException(string.Format("A class inheriting from [{0}] must be present in assembly [{1}] for ConDep to work.", typeof(ApplicationArtifact).FullName, assembly.FullName));
                }

                var application = assembly.CreateInstance(type.FullName) as ApplicationArtifact;
                if (application == null) throw new NullReferenceException(string.Format("Instance of application class [{0}] in assembly [{1}] is not found.", type.FullName, assembly.FullName));
                applications.Add(application);
            }
            else
            {
                var types = assembly.GetTypes().Where(t => typeof(ApplicationArtifact).IsAssignableFrom(t));
                foreach(var type in types)
                {
                    var application = assembly.CreateInstance(type.FullName) as ApplicationArtifact;
                    if (application == null) throw new NullReferenceException(string.Format("Instance of application class [{0}] in assembly [{1}] is not found.", type.FullName, assembly.FullName));
                    applications.Add(application);
                }
            }

            IoCBootstrapper.Bootstrap(envConfig);

            var webDeploy = new WebDeployHandler();
            var sequenceManager = new ExecutionSequenceManager();

            var notification = new Notification();
            foreach (var application in applications)
            {
                var infrastructureSequence = new InfrastructureSequence();
                if (!options.DeployOnly)
                {
                    var infrastructureBuilder = new InfrastructureBuilder(infrastructureSequence, webDeploy);

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

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

                if(!options.InfraOnly)
                {
                    application.Configure(local, envConfig);
                }
            }

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

            sequenceManager.Execute(status, envConfig, options);
        }
Ejemplo n.º 18
0
 public abstract void Configure(IOfferInfrastructure require, ConDepConfig config);
Ejemplo n.º 19
0
 public abstract IReportStatus Execute(IReportStatus status, ConDepConfig config, ConDepOptions options);
Ejemplo n.º 20
0
 private IoCBootstrapper(ConDepConfig envConfig)
 {
     _envConfig = envConfig;
     _execSeq = new ExecutionSequenceManager();
 }