public void Setup() { var app = new OnlyIfTestApp(); var config = new ConDepEnvConfig { EnvironmentName = "bogusEnv" }; var server = new ServerConfig { Name = "bogusHost" }; config.Servers = new[] { server }; _sequenceManager = new ExecutionSequenceManager(config.Servers, new DefaultLoadBalancer()); var settings = new ConDepSettings { Config = config }; var local = new LocalOperationsBuilder(_sequenceManager.NewLocalSequence("Test")); app.Configure(local, settings); _serverInfo = new ServerInfo {OperatingSystem = new OperatingSystemInfo {Name = "Windows Server 2012"}}; }
public void TestThatExecutionSequenceIsValid() { var config = new ConDepEnvConfig {EnvironmentName = "bogusEnv"}; var server = new ServerConfig { Name = "jat-web03" }; config.Servers = new[] { server }; var sequenceManager = new ExecutionSequenceManager(config.Servers, new DefaultLoadBalancer()); var settings = new ConDepSettings(); settings.Config = config; var local = new LocalOperationsBuilder(sequenceManager.NewLocalSequence("Test")); //Configure.LocalOperations = local; _app.Configure(local, settings); var notification = new Notification(); Assert.That(sequenceManager.IsValid(notification)); }
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); }
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); }