public Task TestManifestPropagatedCorrectly() { return ApplicationManager.RunAsync("TestManifestPropagatedCorrectly", async appManager => { // We run this test in 3 steps: Zipdeploy, then OneDeploy, and then ZipDeploy again // And then we check if the second ZipDeploy works as expected // STEP 1a: Upload a zip using ZipDeploy var files1 = DeploymentTestHelper.CreateRandomFilesForZip(10); await DeployZippedArtifact(appManager, appManager.ZipDeploymentManager, files1, type: "", path: "", isAsync: false); // STEP 1b: Validate the ZipDeploy result var expectedFiles1 = files1.Select(f => f.Filename).ToList(); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles1.ToArray(), "site/wwwroot"); // STEP 2a: Upload a text file using OneDeploy await DeployNonZippedArtifact(appManager, "static", "site/wwwroot/staticfiletest.txt", isAsync: false); // STEP 2b: Validate the OneDeploy result expectedFiles1.Add("staticfiletest.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles1.ToArray(), "site/wwwroot"); // STEP 3a: Upload a zip using ZipDeploy var files2 = DeploymentTestHelper.CreateRandomFilesForZip(10); await DeployZippedArtifact(appManager, appManager.ZipDeploymentManager, files2, type: "", path: "", isAsync: false); // STEP 3b: Validate the ZipDeploy result // Specifically, we want to make sure that the files deployed by the first // ZipDeploy are wiped out but the file deployed by OneDeploy is left untouched // If this happens, we can assume that OneDeploy does not interfere with ZipDeploy var expectedFiles2 = files2.Select(f => f.Filename).ToList(); expectedFiles2.Add("staticfiletest.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles2.ToArray(), "site/wwwroot"); }); }
public Task TestLegacyWarDeployment(bool isAsync) { return(ApplicationManager.RunAsync("TestLegacyWarDeployment", async appManager => { var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager); // Incremental deployment - NOT supported, will be ignored { var files1 = DeploymentTestHelper.CreateRandomFilesForZip(10); await DeployZippedArtifact(appManager, appManager.OneDeployManager, files1, "war", "webapps/ROOT", isAsync, isClean: false); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { initialFileName, "ROOT", "ROOT2" }, "site/wwwroot/webapps"); var expectedFiles1 = files1.Select(file => file.Filename).ToList(); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles1.ToArray(), "site/wwwroot/webapps/ROOT"); } // Default deployment - clean { var files1 = DeploymentTestHelper.CreateRandomFilesForZip(10); await DeployZippedArtifact(appManager, appManager.OneDeployManager, files1, "war", "webapps/ROOT2", isAsync); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { initialFileName, "ROOT", "ROOT2" }, "site/wwwroot/webapps"); var expectedFiles1 = files1.Select(file => file.Filename).ToList(); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles1.ToArray(), "site/wwwroot/webapps/ROOT2"); } })); }
public Task TestLibDeployment(bool isAsync) { return(ApplicationManager.RunAsync("TestLibDeployment", async appManager => { var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager); // Default deployment - incremental { await DeployNonZippedArtifact(appManager, "lib", "library1.jar", isAsync, null, "site/libs/library1.jar"); await DeployNonZippedArtifact(appManager, "lib", "library2.jar", isAsync, null, "site/libs/library2.jar"); await DeployNonZippedArtifact(appManager, "lib", "dir1/dir2/library3.jar", isAsync, null, "site/libs/dir1/dir2/library3.jar"); await DeployNonZippedArtifact(appManager, "lib", "dir1/dir2/library4.jar", isAsync, null, "site/libs/dir1/dir2/library4.jar"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { initialFileName, "library1.jar", "library2.jar", "dir1" }, "site/libs"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "library3.jar", "library4.jar" }, "site/libs/dir1/dir2"); } // Clean deployment { await DeployNonZippedArtifact(appManager, "lib", "dir/library.jar", isAsync, true, "site/libs/dir/library.jar"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "dir" }, "site/libs"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "library.jar" }, "site/libs/dir"); await DeployNonZippedArtifact(appManager, "lib", "library.jar", isAsync, true, "site/libs/library.jar"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "library.jar" }, "site/libs"); } })); }
private static async Task DeployZippedArtifact(ApplicationManager applicationManager, RemotePushDeploymentManager deploymentManager, TestFile[] files, string type, string path, bool isAsync, bool?isClean = null, bool expectedSuccess = true) { TestTracer.Trace($"Deploying zip type={type} path={path} isAsync={isAsync} isClean={isClean} expectedSuccess={expectedSuccess}"); using (var zipStream = DeploymentTestHelper.CreateZipStream(files)) { IList <KeyValuePair <string, string> > queryParams = GetOneDeployQueryParams(type, path, isAsync, isClean); var response = await deploymentManager.PushDeployFromStream(zipStream, new ZipDeployMetadata(), queryParams); TestTracer.Trace($"Response code={response.StatusCode}"); if (expectedSuccess) { response.EnsureSuccessStatusCode(); } else { Assert.True(response.StatusCode == System.Net.HttpStatusCode.BadRequest, $"This test is expected to fail with status code == 400. Observed status code == {response.StatusCode}"); } if (isAsync) { await DeploymentTestHelper.WaitForDeploymentCompletionAsync(applicationManager, deployer); } } TestTracer.Trace($"Validation successful!"); }
public Task TestStaticFileDeployment(bool isAsync) { return(ApplicationManager.RunAsync("TestStaticFileDeployment", async appManager => { var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager); // Default deployment - incremental { await DeployNonZippedArtifact(appManager, "static", "a.txt", isAsync, false, "site/wwwroot/a.txt"); await DeployNonZippedArtifact(appManager, "static", "b.txt", isAsync, false, "site/wwwroot/b.txt"); await DeployNonZippedArtifact(appManager, "static", "dir1/dir1a.txt", isAsync, false, "site/wwwroot/dir1/dir1a.txt"); await DeployNonZippedArtifact(appManager, "static", "dir1/dir1b.txt", isAsync, false, "site/wwwroot/dir1/dir1b.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { initialFileName, "webapps", "a.txt", "b.txt", "dir1", "hostingstart.html" }, "site/wwwroot"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "dir1a.txt", "dir1b.txt" }, "site/wwwroot/dir1"); } // Clean deployment { await DeployNonZippedArtifact(appManager, "static", "dir2/dir2a.txt", isAsync, true, "site/wwwroot/dir2/dir2a.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "dir2" }, "site/wwwroot"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "dir2a.txt" }, "site/wwwroot/dir2"); await DeployNonZippedArtifact(appManager, "static", "c.txt", isAsync, true, "site/wwwroot/c.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "c.txt", }, "site/wwwroot"); } })); }
public Task TestScriptDeployment(bool isAsync) { return(ApplicationManager.RunAsync("TestScriptDeployment", async appManager => { var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager); // Default deployment - incremental { await DeployNonZippedArtifact(appManager, "script", "script1.txt", isAsync, null, "site/scripts/script1.txt"); await DeployNonZippedArtifact(appManager, "script", "dir1/script2.txt", isAsync, null, "site/scripts/dir1/script2.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { initialFileName, "dir1", "script1.txt" }, "site/scripts"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "script2.txt" }, "site/scripts/dir1"); } // Clean deployment { await DeployNonZippedArtifact(appManager, "script", "dir/script2.txt", isAsync, true, "site/scripts/dir/script2.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "dir" }, "site/scripts"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "script2.txt" }, "site/scripts/dir"); await DeployNonZippedArtifact(appManager, "script", "script2.txt", isAsync, true, "site/scripts/script2.txt"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "script2.txt" }, "site/scripts"); } })); }
private static async Task <string> DeployNonZippedArtifact( ApplicationManager appManager, string type, string path, bool isAsync, bool?isClean, string expectedDeployPath = null) { TestTracer.Trace("Deploying file"); var testFile = DeploymentTestHelper.CreateRandomTestFile(); using (var fileStream = DeploymentTestHelper.CreateFileStream(testFile)) { IList <KeyValuePair <string, string> > queryParams = GetOneDeployQueryParams(type, path, isAsync, isClean); var response = await appManager.OneDeployManager.PushDeployFromStream(fileStream, new ZipDeployMetadata(), queryParams); response.EnsureSuccessStatusCode(); if (isAsync) { await DeploymentTestHelper.WaitForDeploymentCompletionAsync(appManager, deployer); } } if (expectedDeployPath != null) { VerifyDeployedArtifact(appManager, testFile.Content, expectedDeployPath); } return(testFile.Content); }
public Task TestStaticFileDeployment(bool isAsync) { return ApplicationManager.RunAsync("TestStaticFileDeployment", async appManager => { await DeployNonZippedArtifact(appManager, "static", "site/wwwroot/statictestdir/statictestfile.txt", isAsync); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "statictestfile.txt" }, "site/wwwroot/statictestdir"); }); }
public Task TestIncrementalDeployment(bool isAsync) { return ApplicationManager.RunAsync("TestIterativeDeployment", async appManager => { await DeployNonZippedArtifact(appManager, "static", "site/wwwroot/staticfiletest1.txt", isAsync); await DeployNonZippedArtifact(appManager, "static", "site/wwwroot/staticfiletest2.txt", isAsync); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "hostingstart.html", "staticfiletest1.txt", "staticfiletest2.txt" }, "site/wwwroot"); }); }
public Task TestLibDeployment(bool isAsync) { return ApplicationManager.RunAsync("TestLibDeployment", async appManager => { ConfigureSiteAsJavaSESite(appManager); await DeployNonZippedArtifact(appManager, "lib", "site/wwwroot/dir1/dir2/library.jar", isAsync); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "library.jar" }, "site/wwwroot/dir1/dir2"); }); }
public Task TestAppDotEarDeployment(bool isAsync) { return ApplicationManager.RunAsync("TestAppDotEarDeployment", async appManager => { ConfigureSiteAsJbossEapSite(appManager); await DeployNonZippedArtifact(appManager, "ear", null, isAsync); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "hostingstart.html", "app.ear" }, "site/wwwroot"); }); }
public Task TestZipDeployment(bool isAsync) { return ApplicationManager.RunAsync("TestZipDeployment", async appManager => { var files = DeploymentTestHelper.CreateRandomFilesForZip(10); await DeployZippedArtifact(appManager, appManager.OneDeployManager, files, "zip", null, isAsync); var expectedFiles = files.Select(f => f.Filename).ToList(); expectedFiles.Add("hostingstart.html"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles.ToArray(), "site/wwwroot"); }); }
public Task TestURLBasedDeployment(bool isAsync, bool isArmRequest) { return(ApplicationManager.RunAsync("TestURLDeployment", async appManager => { var client = appManager.OneDeployManager.Client; var requestUri = isArmRequest ? $"{client.BaseAddress}" : $"{client.BaseAddress}?type=static&restart=false&path=NOTICE.txt&async={isAsync}"; using (var request = new HttpRequestMessage(HttpMethod.Put, requestUri)) { var packageUri = "https://github.com/projectkudu/kudu/blob/master/NOTICE.txt?raw=true"; if (isArmRequest) { var payload = new { properties = new { packageUri = packageUri, type = "static", restart = false, path = "NOTICE.txt", async = isAsync, ignorestack = "true", } }; request.Content = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json"); request.Headers.Referrer = new Uri("https://management.azure.com/subscriptions/sub-id/resourcegroups/rg-name/providers/Microsoft.Web/sites/site-name/extensions/publish?api-version=2016-03-01"); request.Headers.Add("x-ms-geo-location", "westus"); } else { var payload = new { packageUri = packageUri }; request.Content = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json"); } var response = await client.SendAsync(request); TestTracer.Trace($"Response code={response.StatusCode}"); response.EnsureSuccessStatusCode(); if (isAsync || isArmRequest) { await DeploymentTestHelper.WaitForDeploymentCompletionAsync(appManager, deployer); } await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "hostingstart.html", "NOTICE.txt" }, "site/wwwroot"); } TestTracer.Trace($"Validation successful!"); })); }
public Task TestAsyncZipDeployment() { return(ApplicationManager.RunAsync("TestAsyncZipDeployment", async appManager => { // Big enough to require at least a couple polls for status until success var files = DeploymentTestHelper.CreateRandomFilesForZip(1000); var response = await DeployZip(appManager, files, new ZipDeployMetadata { IsAsync = true }); response.EnsureSuccessStatusCode(); TestTracer.Trace("Confirming deployment is in progress"); await AssertSuccesfulAsyncDeployment(appManager, files, "site/wwwroot"); })); }
public Task TestAppDotEarDeployment(bool isAsync) { return(ApplicationManager.RunAsync("TestAppDotEarDeployment", async appManager => { var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager); // Default deployment mode - overwrite app.ear { await DeployNonZippedArtifact(appManager, "ear", null, isAsync, null, "site/wwwroot/app.ear"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { initialFileName, "webapps", "hostingstart.html", "app.ear" }, "site/wwwroot"); } // Clean Deployment { await DeployNonZippedArtifact(appManager, "ear", null, isAsync, true, "site/wwwroot/app.ear"); await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { "app.ear" }, "site/wwwroot"); } })); }
private static async Task <string> DeployNonZippedArtifact( ApplicationManager appManager, string type, string path, bool isAsync, bool?isClean, string expectedDeployPath = null, bool expectedSuccess = true) { TestTracer.Trace($"Deploying file type={type} path={path} isAsync={isAsync} isClean={isClean} expectedDeployPath={expectedDeployPath} expectedSuccess={expectedSuccess}"); var testFile = DeploymentTestHelper.CreateRandomTestFile(); using (var fileStream = DeploymentTestHelper.CreateFileStream(testFile)) { IList <KeyValuePair <string, string> > queryParams = GetOneDeployQueryParams(type, path, isAsync, isClean); var response = await appManager.OneDeployManager.PushDeployFromStream(fileStream, new ZipDeployMetadata(), queryParams); TestTracer.Trace($"Response code={response.StatusCode}"); if (expectedSuccess) { response.EnsureSuccessStatusCode(); } else { Assert.True(response.StatusCode == System.Net.HttpStatusCode.BadRequest, $"This test is expected to fail with status code == 400. Observed status code == {response.StatusCode}"); } if (isAsync) { await DeploymentTestHelper.WaitForDeploymentCompletionAsync(appManager, deployer); } } if (expectedDeployPath != null) { VerifyDeployedArtifact(appManager, testFile.Content, expectedDeployPath); } TestTracer.Trace($"Validation successful!"); return(testFile.Content); }