private void RunDeployment(IConf conf, IDeployEvents callback, DeployContext context, byte[] files) { using (var session = _dsFactory.CreateSessionObj(conf, _user)) { _logger.Info(string.Format("Session for '{0}' is opened", _sessionKey)); var deploySteps = new List <IDeployer>(); var failedValidators = new List <IValidator>(); var exceptionHandler = _dsFactory.CreateDeployExHandlerObj(callback, conf, _logger, session); try { conf.PackageManager.BytesToZip(files, conf.PackagePaths.Survey); _logger.Info(string.Format("Zip files was unpacked to '{0}'", conf.PackagePaths.Survey)); DeployExecutor.Validate(_dsFactory.CreateValidatorsList(conf), failedValidators, callback, conf.Survey.DeployMode); _logger.Info(string.Format("Validation process is complete. Found '{0}' error(s)", failedValidators.Count)); if (failedValidators.Any()) { throw new ValidationException("Validation at " + String.Join(", ", failedValidators.Select(v => v.Name).ToArray()) + " failed."); } DeployExecutor.Deploy(_dsFactory.CreateDeployersList(conf), deploySteps, callback, conf.Survey.DeployMode); _logger.Info(string.Format("Deploy is finished for '{0}'", _sessionKey)); session.Commit(); _logger.Info(string.Format("Session for '{0}' is commited successfully", _sessionKey)); } catch (ValidationException exception) { exceptionHandler.HandleValidation(exception, callback); } catch (DeployException exception) { exceptionHandler.HandleDeploy(exception, callback, deploySteps, GetRollbackAction(context)); } catch (Exception exception) { exceptionHandler.HandleUnknown(exception, callback); } } }
public void Setup() { scriptStore = new FakeScriptStore(); schemaHistory = new FakeSchemaHistory(); database = new FakeDatabase(); clock = new AutoIncrementClock(now); feedback = new FakeFeedback(); deployer = new DeployExecutor(scriptStore, schemaHistory, database, clock, feedback); }