public void UnpackZipByRulesTest(DeployMode deployMode) { var pathToSurvey = Path.Combine(_confSection.Settings.Paths.Surveys, _surveyDir); var updateRulesBuilder = new UpdateRulesBuilder(_confSection); _packageManager.UnpackZipIfOverwriteThrow(_pathToZipForInstall, pathToSurvey); _packageManager.UnpackZipByRules(_pathToZipForUpdate, pathToSurvey, updateRulesBuilder[deployMode]); Assert.True(File.Exists(Path.Combine(pathToSurvey, "web.config"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, "connectionstrings.config"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, @"bin\spssio32.dll"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, @"bin\win64\spssio64.dll"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, @"app_data\white.csv"))); Assert.False(Directory.Exists(Path.Combine(pathToSurvey, "common"))); Assert.False(Directory.Exists(Path.Combine(pathToSurvey, "data"))); var webConfText = File.ReadAllText(Path.Combine(pathToSurvey, "web.config")); if (deployMode == DeployMode.UpdateAll) { Assert.That(webConfText, Is.EqualTo("Test")); } else if (deployMode == DeployMode.UpdateAllExceptConf) { Assert.That(webConfText, Is.Not.EqualTo("Test")); } }
private IEnumerable <IUpdateRule> GetUpdateRulesFor(DeployMode deployMode) { var confSection = DeployerConfigurationSection.Instance; var updateRulesBuilder = new UpdateRulesBuilder(confSection); return(updateRulesBuilder[deployMode]); }
public void IfDeployThrowsExShouldBeHandled(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validator = new Mock <IValidator>(); validator.Setup(v => v.IsValidForInstall()).Returns(true); validator.Setup(v => v.IsValidForUpdate()).Returns(true); var correctDeployers = DefaultMocks.GetMockedDeployers(3).ToList(); var deployersWithEx = correctDeployers.ToList(); var deployerWithEx = new Mock <IDeployer>(); deployerWithEx.Setup(d => d.Name).Returns(string.Format("deployer-{0}", 4)); deployerWithEx.Setup(d => d.Install()).Throws(new DeployException("deploy ex install")); deployerWithEx.Setup(d => d.Update()).Throws(new DeployException("deploy ex update")); deployersWithEx.Add(deployerWithEx); var settingsMock = new Mock <IConf>(); settingsMock.Setup(s => s.SurveyPath).Returns(new SurveyPaths(_surveyPath, null)); settingsMock.Setup(s => s.Survey).Returns(new Survey(null, null, mode)); settingsMock.Setup(s => s.PackageManager).Returns(new PackageManagerStub()); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny <IDeployEvents>(), It.IsAny <IConf>(), It.IsAny <IServiceLogger>(), It.IsAny <ISession>())) .Returns(new DeployExceptionHandlerStub()); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny <IConf>())).Returns(new List <IValidator> { validator.Object }); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny <IConf>())).Returns(deployersWithEx.Select(d => d.Object)); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); if (mode == DeployMode.Install) { validator.Verify(v => v.IsValidForInstall(), Times.Once()); } else { validator.Verify(v => v.IsValidForUpdate(), Times.Once()); } foreach (var deployer in correctDeployers) { if (mode == DeployMode.Install) { deployer.Verify(d => d.Install(), Times.Once()); deployer.Verify(d => d.InstallRollback(), Times.Once()); } else { deployer.Verify(d => d.Update(), Times.Once()); deployer.Verify(d => d.UpdateRollback(), Times.Once()); } } }
private DeployContext GetDeployContext(DeployMode mode = DeployMode.Install) { return(new DeployContext { DatabaseName = _surveyName, DirectoryName = _surveyName, UriName = _surveyName, Mode = mode }); }
public static Mock <IConf> GetConf(DeployMode mode) { var confMock = new Mock <IConf>(); confMock.Setup(s => s.SurveyPath).Returns(new SurveyPaths(_surveyPath, null)); confMock.Setup(s => s.Survey).Returns(new Survey(null, null, mode)); confMock.Setup(s => s.PackageManager).Returns(new PackageManagerStub()); return(confMock); }
private void ConsumeService(IDeployService service, DeployMode mode) { if (!service.OpenSession(_surveyName)) { throw new InvalidOperationException("Session wasn't opened"); } foreach (var chunk in _files.Chunks) { service.SendFilesChunk(chunk); } service.Deploy(GetDeployContext(mode), MD5.Create().ComputeHash(_files.Bytes)); }
public ComputeNode(int n, int upperbound, DeployMode deployMode) { m_nodeSerial = n; if (deployMode == DeployMode.Debug || deployMode == DeployMode.UnitTest) HIdFactory = new ITCIdentityFactory(4, 4); else HIdFactory = new ITCIdentityFactory(); // TODO: merge-able ITC m_nodeRoot = HIdFactory.CreateFromRoot(upperbound).ElementAt(n); if (m_nodeSerial == 0) { m_vmstStandalone = new VMSpacetime(CreateHid(), HIdFactory); } }
public static Mock <IDeployServiceFactory> GetServiceFactory(DeployMode mode = DeployMode.Install) { var sessionMock = new Mock <ISession>(); sessionMock.Setup(s => s.Open()); sessionMock.Setup(s => s.Close()); var dsFactory = new Mock <IDeployServiceFactory>(); dsFactory.Setup(f => f.CreateLoggerObj()).Returns(_logger); dsFactory.Setup(f => f.CreateConfObj(It.IsAny <string>(), It.IsAny <DeployContext>(), It.IsAny <IConfFactory>())).Returns(GetConf(mode).Object); dsFactory.Setup(f => f.CreateSessionObj(It.IsAny <IConf>(), It.IsAny <string>())).Returns(sessionMock.Object); dsFactory.Setup(f => f.CreateCallbackObj()).Returns(_callback); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny <IDeployEvents>(), It.IsAny <IConf>(), It.IsAny <IServiceLogger>(), It.IsAny <ISession>())) .Returns(new Mock <IDeployExceptionHandler>().Object); return(dsFactory); }
public void IfValidationFailedHadleExAndDontCallDeployers(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validator = new Mock <IValidator>(); validator.Setup(v => v.IsValidForInstall()).Returns(false); validator.Setup(v => v.IsValidForUpdate()).Returns(false); var deployer = new Mock <IDeployer>(); deployer.Setup(d => d.Install()); deployer.Setup(d => d.Update()); var exceptionHandler = new Mock <IDeployExceptionHandler>(); exceptionHandler.Setup(e => e.HandleValidation(It.IsAny <ValidationException>(), It.IsAny <IDeployEvents>())); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny <IDeployEvents>(), It.IsAny <IConf>(), It.IsAny <IServiceLogger>(), It.IsAny <ISession>())) .Returns(exceptionHandler.Object); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny <IConf>())).Returns(new List <IValidator> { validator.Object }); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny <IConf>())).Returns(new List <IDeployer> { deployer.Object }); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); if (mode == DeployMode.Install) { validator.Verify(v => v.IsValidForInstall(), Times.Once()); } else { validator.Verify(v => v.IsValidForUpdate(), Times.Once()); } deployer.Verify(d => d.Install(), Times.Never()); deployer.Verify(d => d.Update(), Times.Never()); exceptionHandler.Verify(e => e.HandleValidation(It.IsAny <ValidationException>(), It.IsAny <IDeployEvents>()), Times.Once()); }
public void IfDeployThrowsExShouldBeHandled(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validator = new Mock<IValidator>(); validator.Setup(v => v.IsValidForInstall()).Returns(true); validator.Setup(v => v.IsValidForUpdate()).Returns(true); var correctDeployers = DefaultMocks.GetMockedDeployers(3).ToList(); var deployersWithEx = correctDeployers.ToList(); var deployerWithEx = new Mock<IDeployer>(); deployerWithEx.Setup(d => d.Name).Returns(string.Format("deployer-{0}", 4)); deployerWithEx.Setup(d => d.Install()).Throws(new DeployException("deploy ex install")); deployerWithEx.Setup(d => d.Update()).Throws(new DeployException("deploy ex update")); deployersWithEx.Add(deployerWithEx); var settingsMock = new Mock<IConf>(); settingsMock.Setup(s => s.SurveyPath).Returns(new SurveyPaths(_surveyPath, null)); settingsMock.Setup(s => s.Survey).Returns(new Survey(null, null, mode)); settingsMock.Setup(s => s.PackageManager).Returns(new PackageManagerStub()); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny<IDeployEvents>(), It.IsAny<IConf>(), It.IsAny<IServiceLogger>(), It.IsAny<ISession>())) .Returns(new DeployExceptionHandlerStub()); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny<IConf>())).Returns(new List<IValidator> { validator.Object }); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny<IConf>())).Returns(deployersWithEx.Select(d => d.Object)); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); if (mode == DeployMode.Install) validator.Verify(v => v.IsValidForInstall(), Times.Once()); else validator.Verify(v => v.IsValidForUpdate(), Times.Once()); foreach (var deployer in correctDeployers) if (mode == DeployMode.Install) { deployer.Verify(d => d.Install(), Times.Once()); deployer.Verify(d => d.InstallRollback(), Times.Once()); } else { deployer.Verify(d => d.Update(), Times.Once()); deployer.Verify(d => d.UpdateRollback(), Times.Once()); } }
public static void Initializer(DeployMode mode) { _mode = mode; if (mode == DeployMode.MODE_NORMAL) { if (service == null) { service = new Dictionary <string, StrObjectDict>(); } IList <StrObjectDict> list = DataServiceManager.Instance.ListSod <DataService>(null); foreach (var item in list) { //是否重复添加 tanjian - 2015/10/27 if (!service.ContainsKey(item["ID"].ToString())) { service.Add(item["ID"].ToString(), item); } } } }
public void ServiceShouldCallAllValidatorsAndDeployers(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validators = DefaultMocks.GetMockedValidators(3).ToList(); var deployers = DefaultMocks.GetMockedDeployers(3).ToList(); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny <IConf>())).Returns(validators.Select(v => v.Object)); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny <IConf>())).Returns(deployers.Select(v => v.Object)); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); foreach (var validator in validators) { if (mode == DeployMode.Install) { validator.Verify(v => v.IsValidForInstall(), Times.Once()); } else { validator.Verify(v => v.IsValidForUpdate(), Times.Once()); } } foreach (var deployer in deployers) { if (mode == DeployMode.Install) { deployer.Verify(d => d.Install(), Times.Once()); } else { deployer.Verify(d => d.Update(), Times.Once()); } } }
public void Show(DeployMode mode, bool skipThreatIncrease, bool isOptionalDeployment, Action a = null) { gameObject.SetActive(true); fader.color = new Color(0, 0, 0, 0); fader.DOFade(.95f, 1); cg.DOFade(1, .5f); transform.GetChild(1).localScale = new Vector3(.85f, .85f, .85f); transform.GetChild(1).DOScale(1, .5f).SetEase(Ease.OutExpo); calmPanel.SetActive(false); reinforcePanel.SetActive(false); landingPanel.SetActive(false); onslaughtPanel.SetActive(false); postAction = a; groupsToDeploy = new List <CardDescriptor>(); warning.gameObject.SetActive(false); //reset reinforce topPanel.SetActive(false); bottomPanel.SetActive(false); //reset landing topLanding.SetActive(false); bottomLanding.SetActive(false); //reset onslaught topOnslaught.SetActive(false); bottomOnslaught.SetActive(false); onR1Group.SetActive(false); onR2Group.SetActive(false); onslaughtRWarning.gameObject.SetActive(false); onslaughtDWarning.gameObject.SetActive(false); switch (mode) { case DeployMode.Calm: calmPanel.SetActive(true); depTypeText.text = DataStore.uiLanguage.uiMainApp.deployModeCalm; HandleCalm(); break; case DeployMode.Reinforcements: reinforcePanel.SetActive(true); depTypeText.text = DataStore.uiLanguage.uiMainApp.deployModeReinforcements; HandleReinforcements(); break; case DeployMode.Landing: landingPanel.SetActive(true); depTypeText.text = DataStore.uiLanguage.uiMainApp.deployModeLanding; if (isOptionalDeployment) { depTypeText.text = DataStore.uiLanguage.uiSetup.deploymentHeading; } HandleLanding(skipThreatIncrease, isOptionalDeployment); break; case DeployMode.Onslaught: onslaughtPanel.SetActive(true); depTypeText.text = DataStore.uiLanguage.uiMainApp.deployModeOnslaught; HandleOnslaught(skipThreatIncrease); break; } }
public static void Deploy(IEnumerable <IDeployer> deployers, List <IDeployer> installSteps, IDeployEvents callback, DeployMode mode) { var deployExecutor = new DeployExecutor(callback, mode); deployExecutor.Deploy(deployers, installSteps); }
public void ServiceShouldCallAllValidatorsAndDeployers(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validators = DefaultMocks.GetMockedValidators(3).ToList(); var deployers = DefaultMocks.GetMockedDeployers(3).ToList(); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny<IConf>())).Returns(validators.Select(v => v.Object)); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny<IConf>())).Returns(deployers.Select(v => v.Object)); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); foreach (var validator in validators) if (mode == DeployMode.Install) validator.Verify(v => v.IsValidForInstall(), Times.Once()); else validator.Verify(v => v.IsValidForUpdate(), Times.Once()); foreach (var deployer in deployers) if (mode == DeployMode.Install) deployer.Verify(d => d.Install(), Times.Once()); else deployer.Verify(d => d.Update(), Times.Once()); }
private DeployContext GetDeployContext(DeployMode mode = DeployMode.Install) { return new DeployContext { DatabaseName = _surveyName, DirectoryName = _surveyName, UriName = _surveyName, Mode = mode }; }
public void IfValidationFailedHadleExAndDontCallDeployers(DeployMode mode) { var cFactory = DefaultMocks.GetConfFactory(); var validator = new Mock<IValidator>(); validator.Setup(v => v.IsValidForInstall()).Returns(false); validator.Setup(v => v.IsValidForUpdate()).Returns(false); var deployer = new Mock<IDeployer>(); deployer.Setup(d => d.Install()); deployer.Setup(d => d.Update()); var exceptionHandler = new Mock<IDeployExceptionHandler>(); exceptionHandler.Setup(e => e.HandleValidation(It.IsAny<ValidationException>(), It.IsAny<IDeployEvents>())); var dsFactory = DefaultMocks.GetServiceFactory(mode); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny<IDeployEvents>(), It.IsAny<IConf>(), It.IsAny<IServiceLogger>(), It.IsAny<ISession>())) .Returns(exceptionHandler.Object); dsFactory.Setup(f => f.CreateValidatorsList(It.IsAny<IConf>())).Returns(new List<IValidator> {validator.Object}); dsFactory.Setup(f => f.CreateDeployersList(It.IsAny<IConf>())).Returns(new List<IDeployer> {deployer.Object}); using (var service = new DeployService(dsFactory.Object, cFactory.Object)) ConsumeService(service, mode); if (mode == DeployMode.Install) validator.Verify(v => v.IsValidForInstall(), Times.Once()); else validator.Verify(v => v.IsValidForUpdate(), Times.Once()); deployer.Verify(d => d.Install(), Times.Never()); deployer.Verify(d => d.Update(), Times.Never()); exceptionHandler.Verify(e => e.HandleValidation(It.IsAny<ValidationException>(), It.IsAny<IDeployEvents>()), Times.Once()); }
private IEnumerable<IUpdateRule> GetUpdateRulesFor(DeployMode deployMode) { var confSection = DeployerConfigurationSection.Instance; var updateRulesBuilder = new UpdateRulesBuilder(confSection); return updateRulesBuilder[deployMode]; }
public Survey(string name, string dbName, DeployMode deployMode) : this() { Name = name; DbName = dbName; DeployMode = deployMode; }
public IEnumerable<IUpdateRule> this[DeployMode deployMode] { get { return _rules[deployMode]; } }
public DeployExecutor(IDeployEvents callback, DeployMode mode) { _callback = callback; _mode = mode; }
public static void Validate(IEnumerable <IValidator> validators, List <IValidator> failedValidators, IDeployEvents callback, DeployMode mode) { var validationExecutor = new DeployExecutor(callback, mode); validationExecutor.Validate(validators, failedValidators); }
public static Mock<IDeployServiceFactory> GetServiceFactory(DeployMode mode = DeployMode.Install) { var sessionMock = new Mock<ISession>(); sessionMock.Setup(s => s.Open()); sessionMock.Setup(s => s.Close()); var dsFactory = new Mock<IDeployServiceFactory>(); dsFactory.Setup(f => f.CreateLoggerObj()).Returns(_logger); dsFactory.Setup(f => f.CreateConfObj(It.IsAny<string>(), It.IsAny<DeployContext>(), It.IsAny<IConfFactory>())).Returns(GetConf(mode).Object); dsFactory.Setup(f => f.CreateSessionObj(It.IsAny<IConf>(), It.IsAny<string>())).Returns(sessionMock.Object); dsFactory.Setup(f => f.CreateCallbackObj()).Returns(_callback); dsFactory.Setup(f => f.CreateDeployExHandlerObj(It.IsAny<IDeployEvents>(), It.IsAny<IConf>(), It.IsAny<IServiceLogger>(), It.IsAny<ISession>())) .Returns(new Mock<IDeployExceptionHandler>().Object); return dsFactory; }
public IEnumerable <IUpdateRule> this[DeployMode deployMode] { get { return(_rules[deployMode]); } }
public static void PreparePackageFor(DeployMode mode, string path) { File.Copy(_packages[mode], path, true); }
public static Mock<IConf> GetConf(DeployMode mode) { var confMock = new Mock<IConf>(); confMock.Setup(s => s.SurveyPath).Returns(new SurveyPaths(_surveyPath, null)); confMock.Setup(s => s.Survey).Returns(new Survey(null, null, mode)); confMock.Setup(s => s.PackageManager).Returns(new PackageManagerStub()); return confMock; }
private async Task <ConfigurationSettings> GetConfigurationSettings(IWebHostEnvironment env, DeployMode deployMode) { var configurationSettings = new ConfigurationSettings(deployMode); //Read from appsettings if exists var section = Configuration.GetSection("ConfigurationSettings"); //Bind pre-defined properties if (section.Exists()) { Configuration.Bind("ConfigurationSettings", configurationSettings); } else { //Read from environment variables configurationSettings.LoadVariables(); } await configurationSettings.SetFilePathsProperties(env); return(configurationSettings); }
private void ConsumeService(IDeployService service, DeployMode mode) { if (!service.OpenSession(_surveyName)) throw new InvalidOperationException("Session wasn't opened"); foreach (var chunk in _files.Chunks) service.SendFilesChunk(chunk); service.Deploy(GetDeployContext(mode), MD5.Create().ComputeHash(_files.Bytes)); }
public void UnpackZipByRulesTest(DeployMode deployMode) { var pathToSurvey = Path.Combine(_confSection.Settings.Paths.Surveys, _surveyDir); var updateRulesBuilder = new UpdateRulesBuilder(_confSection); _packageManager.UnpackZipIfOverwriteThrow(_pathToZipForInstall, pathToSurvey); _packageManager.UnpackZipByRules(_pathToZipForUpdate, pathToSurvey, updateRulesBuilder[deployMode]); Assert.True(File.Exists(Path.Combine(pathToSurvey, "web.config"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, "connectionstrings.config"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, @"bin\spssio32.dll"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, @"bin\win64\spssio64.dll"))); Assert.True(File.Exists(Path.Combine(pathToSurvey, @"app_data\white.csv"))); Assert.False(Directory.Exists(Path.Combine(pathToSurvey, "common"))); Assert.False(Directory.Exists(Path.Combine(pathToSurvey, "data"))); var webConfText = File.ReadAllText(Path.Combine(pathToSurvey, "web.config")); if (deployMode == DeployMode.UpdateAll) Assert.That(webConfText, Is.EqualTo("Test")); else if (deployMode == DeployMode.UpdateAllExceptConf) Assert.That(webConfText, Is.Not.EqualTo("Test")); }