public void Trigger_Simple_Deployment_And_Check_AppPool_And_Website_Test() { var client = GetClient(); var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_Simple", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\integrationtests", RuntimeVersion = RuntimeVersion.Version40, }; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); using (var manager = new ServerManager()) { Assert.IsNotNull(manager.ApplicationPools[request.AppPoolName]); Assert.AreEqual(request.AppPoolName, manager.ApplicationPools[request.AppPoolName].Name); Assert.AreEqual(request.AppPoolUser, manager.ApplicationPools[request.AppPoolName].ProcessModel.UserName); Assert.AreEqual(request.AppPoolPassword, manager.ApplicationPools[request.AppPoolName].ProcessModel.Password); Assert.IsNotNull(manager.Sites[request.WebsiteName]); Assert.AreEqual(Path.Combine(request.WebsitePhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion)), manager.Sites[request.WebsiteName].Applications["/"].VirtualDirectories["/"].PhysicalPath); } IISManagerTestBuddy.DeleteAppPool(request.AppPoolName); IISManagerTestBuddy.DeleteWebsite(request.WebsiteName); }
public void Trigger_Deployment_With_App_Virtual_Dir_And_Check_AppPool_And_Website_Test() { var client = GetClient(); var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_VDIR", AppRoot = "/sub1/sub2", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\www", WebsitePort = 8000, RuntimeVersion = RuntimeVersion.Version40, AppName = "App", AppPhysicalPath = @"c:\temp\int-app", }; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); using (var manager = new ServerManager()) { Assert.IsNotNull(manager.ApplicationPools[request.AppPoolName]); Assert.AreEqual(request.AppPoolName, manager.ApplicationPools[request.AppPoolName].Name); Assert.AreEqual(request.AppPoolUser, manager.ApplicationPools[request.AppPoolName].ProcessModel.UserName); Assert.AreEqual(request.AppPoolPassword, manager.ApplicationPools[request.AppPoolName].ProcessModel.Password); Assert.IsNotNull(manager.Sites[request.WebsiteName]); Assert.AreEqual(@"{0}\{1}_v{2}".Fmt(request.AppPhysicalPath, request.PackageId, request.PackageVersion), manager.Sites[request.WebsiteName].Applications["{0}/{1}".Fmt(request.AppRoot.TrimEnd('/'), request.AppName)].VirtualDirectories["/"].PhysicalPath); } }
public void Rollback_Website_Test() { var client = GetClient(); var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_Simple", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\integrationtests", RuntimeVersion = RuntimeVersion.Version40, WebsitePort = 2000, }; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); request.PackageVersion = "1.3.3.8"; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); var rollbackRequest = new RollbackDeployment() { WebsiteName = request.WebsiteName, RollbackTarget = "{0}_v{1}".Fmt(request.PackageId, "1.3.3.7") }; client.Post(rollbackRequest); IISManagerTestBuddy.AssertWebsite(request.WebsiteName, Path.Combine(request.WebsitePhysicalPath, rollbackRequest.RollbackTarget), request.WebsitePort, request.AppPoolName); IISManagerTestBuddy.DeleteAppPool(request.AppPoolName); IISManagerTestBuddy.DeleteWebsite(request.WebsiteName); }
public void List_Deployed_Folders_For_a_Website_Test() { var client = GetClient(); const string version1 = "1.3.3.7"; const string version2 = "1.3.3.8"; var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = version1, WebsitePhysicalPath = @"C:\temp\test", RuntimeVersion = RuntimeVersion.Version40, }; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); request.PackageVersion = version2; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); var response = client.Get(new QueryDeployments() { WebsiteName = request.WebsiteName }); response.PrintDump(); Assert.IsTrue(response.Any(r => r.Name.Contains(version1))); Assert.IsTrue(response.Any(r => r.Name.Contains(version2))); }
public void List_Deployed_Folders_For_a_Website_Test() { var client = GetClient(); const string version1 = "1.3.3.7"; const string version2 = "1.3.3.8"; var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = version1, WebsitePhysicalPath = @"C:\temp\test", RuntimeVersion = RuntimeVersion.Version40, }; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); request.PackageVersion = version2; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); var response = client.Get(new QueryDeployments() { WebsiteName = request.WebsiteName }); response.PrintDump(); Assert.IsTrue(response.Any(r => r.Name.Contains(version1))); Assert.IsTrue(response.Any(r => r.Name.Contains(version2))); }
public object Post(TriggerDeployment request) { if (Request.Files.Length != 1) { throw new HttpError(HttpStatusCode.BadRequest, "Please add one (and just one) file to deploy."); } IISManager.CreateAppPool(request.AppPoolName, request.AppPoolUser, request.AppPoolPassword, request.RuntimeVersion, request.Overwrite); IISManager.CreateWebsite(request.WebsiteName, request.WebsitePhysicalPath, request.WebsitePort, request.AppPoolName, request.Overwrite); var uploadedPackageZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "package.zip"); Request.Files[0].SaveTo(uploadedPackageZip); if (string.IsNullOrEmpty(request.AppRoot) || request.AppRoot == "/") { var targetPath = Path.Combine(request.WebsitePhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion)); using (var zip = ZipFile.Read(uploadedPackageZip)) { zip.ForEach(z => z.Extract(targetPath, ExtractExistingFileAction.OverwriteSilently)); } // the package is unpacked to the new destination, remap the website to the new version IISManager.MapWebsitePhysicalPath(request.WebsiteName, targetPath); } else { ////this lets you access your application with for example http://your-host/sub1/sub2/app if (!Directory.Exists(request.AppPhysicalPath)) { Directory.CreateDirectory(request.AppPhysicalPath); } var appTargetPath = Path.Combine(request.AppPhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion)); using (var zip = ZipFile.Read(uploadedPackageZip)) { zip.ForEach(z => z.Extract(appTargetPath, ExtractExistingFileAction.OverwriteSilently)); } ////ApplyBackupRetentionPolicy(request.AppPhysicalPath, request.AppName); var appFolderInWebsite = Path.Combine(request.WebsitePhysicalPath, request.AppRoot.Trim('/')); var appPath = "{0}/{1}".Fmt(request.AppRoot.TrimEnd('/'), request.AppName); if (!Directory.Exists(appFolderInWebsite)) { Directory.CreateDirectory(appFolderInWebsite); } IISManager.CreateApplication(request.WebsiteName, appPath, appTargetPath); } return(new TriggerDeploymentResponse { Status = "OK" }); }
public TriggerDeploymentResponse Post(TriggerDeployment request) { using (var session = DocumentStore.OpenSession()) { var environment = session.Query <Environment>().FirstOrDefault(e => e.Name == request.Environment); if (environment == null) { throw HttpError.NotFound("Environment {0} not found.".Fmt(request.Environment)); } var deploymentInfo = new Deployment() { EnvironmentId = "environments/" + environment.Id, RequestedAt = DateTime.UtcNow, }; var packageInfo = session.Load <Package>("packages/{0}/{1}".Fmt(request.PackageId, request.Version)); deploymentInfo.Package = packageInfo; deploymentInfo.Status = DeployStatus.Deploying; session.Store(deploymentInfo); session.SaveChanges(); using (var workspace = new Workspace(FileSystem, ServerSettings)) { var neutralPackagePath = PackageDownloader.Downloaad(request.PackageId, request.Version, workspace.TempWorkDir); workspace.UpdateSources(); var packageManager = new PackageManager(workspace.EnviornmentPath); var configuredPackage = packageManager.ConfigurePackageByEnvironment(neutralPackagePath, request.Environment, workspace.TempWorkDir); packageManager.DeployPackage(configuredPackage); deploymentInfo.FinishedAt = DateTime.UtcNow; deploymentInfo.Status = DeployStatus.Successful; session.SaveChanges(); return(new TriggerDeploymentResponse()); } } }
public TriggerDeploymentResponse Post(TriggerDeployment request) { using (var session = DocumentStore.OpenSession()) { var environment = session.Query<Environment>().FirstOrDefault(e => e.Name == request.Environment); if (environment == null) { throw HttpError.NotFound("Environment {0} not found.".Fmt(request.Environment)); } var deploymentInfo = new Deployment() { EnvironmentId = "environments/" + environment.Id, RequestedAt = DateTime.UtcNow, }; var packageInfo = session.Load<Package>("packages/{0}/{1}".Fmt(request.PackageId, request.Version)); deploymentInfo.Package = packageInfo; deploymentInfo.Status = DeployStatus.Deploying; session.Store(deploymentInfo); session.SaveChanges(); using (var workspace = new Workspace(FileSystem, ServerSettings)) { var neutralPackagePath = PackageDownloader.Downloaad(request.PackageId, request.Version, workspace.TempWorkDir); workspace.UpdateSources(); var packageManager = new PackageManager(workspace.EnviornmentPath); var configuredPackage = packageManager.ConfigurePackageByEnvironment(neutralPackagePath, request.Environment, workspace.TempWorkDir); packageManager.DeployPackage(configuredPackage); deploymentInfo.FinishedAt = DateTime.UtcNow; deploymentInfo.Status = DeployStatus.Successful; session.SaveChanges(); return new TriggerDeploymentResponse(); } } }
public void Rollback_Website_with_VDIR_Test() { var client = GetClient(); const string version1 = "1.3.3.7"; const string version2 = "1.3.3.8"; var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_VDIR", AppRoot = "/sub1/sub2", PackageId = "IntegrationTest", PackageVersion = version1, WebsitePhysicalPath = @"C:\temp\www", WebsitePort = 8000, RuntimeVersion = RuntimeVersion.Version40, AppName = "App", AppPhysicalPath = @"c:\temp\int-app", }; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); request.PackageVersion = version2; client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); var rollbackRequest = new RollbackDeployment() { WebsiteName = request.WebsiteName, RollbackTarget = "{0}_v{1}".Fmt(request.PackageId, version1), AppName = request.AppName, AppRoot = request.AppRoot, }; client.Post(rollbackRequest); var actual = new IISManager().GetApplicationPath(request.WebsiteName, request.AppRoot, request.AppName); Assert.AreEqual(@"{0}\{1}_v{2}".Fmt(request.AppPhysicalPath, request.PackageId, version1), actual); }
public bool Deploy(ZipPackage package, ILog logger) { var options = package.GetPackageOptions<WebOptions>(); logger.Info("Deploying iis package to {0}:{1} using {2}".Fmt(options.WebsiteName, options.WebsitePort, options.DeployService)); var client = new JsonServiceClient(options.DeployService); // todo var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_Simple", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\integrationtests", RuntimeVersion = RuntimeVersion.Version40, }; var response = client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("package.zip"), request); return true; }
public bool Deploy(ZipPackage package, ILog logger) { var options = package.GetPackageOptions <WebOptions>(); logger.Info("Deploying iis package to {0}:{1} using {2}".Fmt(options.WebsiteName, options.WebsitePort, options.DeployService)); var client = new JsonServiceClient(options.DeployService); // todo var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_Simple", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\integrationtests", RuntimeVersion = RuntimeVersion.Version40, }; var response = client.PostFileWithRequest <TriggerDeploymentResponse>("/deployments", new FileInfo("package.zip"), request); return(true); }
public object Post(TriggerDeployment request) { if (Request.Files.Length != 1) { throw new HttpError(HttpStatusCode.BadRequest, "Please add one (and just one) file to deploy."); } IISManager.CreateAppPool(request.AppPoolName, request.AppPoolUser, request.AppPoolPassword, request.RuntimeVersion, request.Overwrite); IISManager.CreateWebsite(request.WebsiteName, request.WebsitePhysicalPath, request.WebsitePort, request.AppPoolName, request.Overwrite); var uploadedPackageZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "package.zip"); Request.Files[0].SaveTo(uploadedPackageZip); if (string.IsNullOrEmpty(request.AppRoot) || request.AppRoot == "/") { var targetPath = Path.Combine(request.WebsitePhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion)); using (var zip = ZipFile.Read(uploadedPackageZip)) { zip.ForEach(z => z.Extract(targetPath, ExtractExistingFileAction.OverwriteSilently)); } // the package is unpacked to the new destination, remap the website to the new version IISManager.MapWebsitePhysicalPath(request.WebsiteName, targetPath); } else { ////this lets you access your application with for example http://your-host/sub1/sub2/app if (!Directory.Exists(request.AppPhysicalPath)) { Directory.CreateDirectory(request.AppPhysicalPath); } var appTargetPath = Path.Combine(request.AppPhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion)); using (var zip = ZipFile.Read(uploadedPackageZip)) { zip.ForEach(z => z.Extract(appTargetPath, ExtractExistingFileAction.OverwriteSilently)); } ////ApplyBackupRetentionPolicy(request.AppPhysicalPath, request.AppName); var appFolderInWebsite = Path.Combine(request.WebsitePhysicalPath, request.AppRoot.Trim('/')); var appPath = "{0}/{1}".Fmt(request.AppRoot.TrimEnd('/'), request.AppName); if (!Directory.Exists(appFolderInWebsite)) { Directory.CreateDirectory(appFolderInWebsite); } IISManager.CreateApplication(request.WebsiteName, appPath, appTargetPath); } return new TriggerDeploymentResponse { Status = "OK" }; }
public void Trigger_Simple_Deployment_And_Check_AppPool_And_Website_Test() { var client = GetClient(); var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_Simple", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\integrationtests", RuntimeVersion = RuntimeVersion.Version40, }; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); using (var manager = new ServerManager()) { Assert.IsNotNull(manager.ApplicationPools[request.AppPoolName]); Assert.AreEqual(request.AppPoolName, manager.ApplicationPools[request.AppPoolName].Name); Assert.AreEqual(request.AppPoolUser, manager.ApplicationPools[request.AppPoolName].ProcessModel.UserName); Assert.AreEqual(request.AppPoolPassword, manager.ApplicationPools[request.AppPoolName].ProcessModel.Password); Assert.IsNotNull(manager.Sites[request.WebsiteName]); Assert.AreEqual(Path.Combine(request.WebsitePhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion)), manager.Sites[request.WebsiteName].Applications["/"].VirtualDirectories["/"].PhysicalPath); } IISManagerTestBuddy.DeleteAppPool(request.AppPoolName); IISManagerTestBuddy.DeleteWebsite(request.WebsiteName); }
public void Trigger_Deployment_With_App_Virtual_Dir_And_Check_AppPool_And_Website_Test() { var client = GetClient(); var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_VDIR", AppRoot = "/sub1/sub2", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\www", WebsitePort = 8000, RuntimeVersion = RuntimeVersion.Version40, AppName = "App", AppPhysicalPath = @"c:\temp\int-app", }; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); using (var manager = new ServerManager()) { Assert.IsNotNull(manager.ApplicationPools[request.AppPoolName]); Assert.AreEqual(request.AppPoolName, manager.ApplicationPools[request.AppPoolName].Name); Assert.AreEqual(request.AppPoolUser, manager.ApplicationPools[request.AppPoolName].ProcessModel.UserName); Assert.AreEqual(request.AppPoolPassword, manager.ApplicationPools[request.AppPoolName].ProcessModel.Password); Assert.IsNotNull(manager.Sites[request.WebsiteName]); Assert.AreEqual(@"{0}\{1}_v{2}".Fmt(request.AppPhysicalPath, request.PackageId, request.PackageVersion), manager.Sites[request.WebsiteName].Applications["{0}/{1}".Fmt(request.AppRoot.TrimEnd('/'), request.AppName)].VirtualDirectories["/"].PhysicalPath); } }
public void Rollback_Website_with_VDIR_Test() { var client = GetClient(); const string version1 = "1.3.3.7"; const string version2 = "1.3.3.8"; var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_VDIR", AppRoot = "/sub1/sub2", PackageId = "IntegrationTest", PackageVersion = version1, WebsitePhysicalPath = @"C:\temp\www", WebsitePort = 8000, RuntimeVersion = RuntimeVersion.Version40, AppName = "App", AppPhysicalPath = @"c:\temp\int-app", }; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); request.PackageVersion = version2; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); var rollbackRequest = new RollbackDeployment() { WebsiteName = request.WebsiteName, RollbackTarget = "{0}_v{1}".Fmt(request.PackageId, version1), AppName = request.AppName, AppRoot = request.AppRoot, }; client.Post(rollbackRequest); var actual = new IISManager().GetApplicationPath(request.WebsiteName, request.AppRoot, request.AppName); Assert.AreEqual(@"{0}\{1}_v{2}".Fmt(request.AppPhysicalPath, request.PackageId, version1), actual); }
public void Rollback_Website_Test() { var client = GetClient(); var request = new TriggerDeployment() { AppPoolName = "ZZZ_Integration_PoolName", AppPoolUser = "******", AppPoolPassword = "******", WebsiteName = "ZZZ_Integration_Website_Simple", AppRoot = "/", PackageId = "IntegrationTest", PackageVersion = "1.3.3.7", WebsitePhysicalPath = @"C:\temp\integrationtests", RuntimeVersion = RuntimeVersion.Version40, WebsitePort = 2000, }; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); request.PackageVersion = "1.3.3.8"; client.PostFileWithRequest<TriggerDeploymentResponse>("/deployments", new FileInfo("src/PowerDeploy.IISDeployService.Tests/Files/package.zip".MapVcsRoot()), request).PrintDump(); var rollbackRequest = new RollbackDeployment() { WebsiteName = request.WebsiteName, RollbackTarget = "{0}_v{1}".Fmt(request.PackageId, "1.3.3.7") }; client.Post(rollbackRequest); IISManagerTestBuddy.AssertWebsite(request.WebsiteName, Path.Combine(request.WebsitePhysicalPath, rollbackRequest.RollbackTarget), request.WebsitePort, request.AppPoolName); IISManagerTestBuddy.DeleteAppPool(request.AppPoolName); IISManagerTestBuddy.DeleteWebsite(request.WebsiteName); }