public void Execute_NoPreviousBackup_CreatesZippedFileWithNameCreatedFromLastDir() { string zippedBackupFileName = Path.Combine(Environment.CurrentDirectory, string.Format("{0}\\{1}.bak.000.zip", _workingDir, DstSubDir)); var backupFilesDeploymentStep = new BackupFilesDeploymentStep(_dstDir); backupFilesDeploymentStep.Prepare(); backupFilesDeploymentStep.Execute(); var fileInfo = new FileInfo(zippedBackupFileName); Assert.IsTrue(fileInfo.Exists); }
public void Execute_PreviousBackupExistAndFilesRotationOn_CreatesNewBackupAndMovingOldOne() { const int maxBackupCount = 4; var backupFilesDeploymentStep = new BackupFilesDeploymentStep(_dstDir, maxBackupCount); backupFilesDeploymentStep.Prepare(); for (int i = 0; i < maxBackupCount + 1; i++) { backupFilesDeploymentStep.Execute(); Thread.Sleep(50); } string[] files = Directory.GetFiles(_workingDir); Array.Sort(files); for (int fileIndex = 0; fileIndex < files.Length - 2; fileIndex++) { Assert.Greater(new FileInfo(files[fileIndex]).LastWriteTime, new FileInfo(files[fileIndex + 1]).LastWriteTime); } Assert.AreEqual(4, files.Length); }
protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); // create a step for downloading the artifacts var downloadArtifactsDeploymentStep = new DownloadArtifactsDeploymentStep( _artifactsRepository, _projectInfo, _projectConfigurationName, _projectConfigurationBuildId, GetTempDirPath()); AddSubTask(downloadArtifactsDeploymentStep); // create a step for extracting the artifacts var extractArtifactsDeploymentStep = new ExtractArtifactsDeploymentStep( environmentInfo, _projectInfo, _projectConfigurationName, _projectConfigurationBuildId, downloadArtifactsDeploymentStep.ArtifactsFilePath, GetTempDirPath()); AddSubTask(extractArtifactsDeploymentStep); if (_projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } foreach (string webServerMachineName in environmentInfo.WebServerMachineNames) { string webApplicationPhysicalPath = _iisManager.GetWebApplicationPath( webServerMachineName, string.Format("{0}/{1}", _projectInfo.IisSiteName, _projectInfo.WebAppName)); if (!string.IsNullOrEmpty(webApplicationPhysicalPath)) { string webApplicationNetworkPath = string.Format( "\\\\{0}\\{1}${2}", webServerMachineName, webApplicationPhysicalPath[0], webApplicationPhysicalPath.Substring(2)); if (Directory.Exists(webApplicationNetworkPath)) { var backupFilesDeploymentStep = new BackupFilesDeploymentStep(webApplicationNetworkPath); AddSubTask(backupFilesDeploymentStep); } } // create a step for creating a WebDeploy package // TODO IMM HI: add possibility to specify physical path on the target machine var createWebDeployPackageDeploymentStep = new CreateWebDeployPackageDeploymentStep( _msDeploy, extractArtifactsDeploymentStep.BinariesDirPath, _projectInfo.IisSiteName, _projectInfo.WebAppName); AddSubTask(createWebDeployPackageDeploymentStep); // create a step for deploying the WebDeploy package to the target machine var deployWebDeployPackageDeploymentStep = new DeployWebDeployPackageDeploymentStep( _msDeploy, createWebDeployPackageDeploymentStep.PackageFilePath, webServerMachineName); AddSubTask(deployWebDeployPackageDeploymentStep); // check if the app pool exists on the target machine if (!_iisManager.AppPoolExists(webServerMachineName, _projectInfo.AppPool.Name)) { // create a step for creating a new app pool var createAppPoolDeploymentStep = new CreateAppPoolDeploymentStep( _iisManager, webServerMachineName, _projectInfo.AppPool); AddSubTask(createAppPoolDeploymentStep); } // create a step for assigning the app pool to the web application var setAppPoolDeploymentStep = new SetAppPoolDeploymentStep( _iisManager, webServerMachineName, _projectInfo.IisSiteName, _projectInfo.WebAppName, _projectInfo.AppPool); AddSubTask(setAppPoolDeploymentStep); } }