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!"); }
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 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!"); })); }
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); }
private static async Task DeployZippedArtifact(ApplicationManager applicationManager, RemotePushDeploymentManager deploymentManager, TestFile[] files, string type, string path, bool isAsync) { TestTracer.Trace("Deploying zip"); using (var zipStream = DeploymentTestHelper.CreateZipStream(files)) { IList<KeyValuePair<string, string>> queryParams = GetOneDeployQueryParams(type, path, isAsync); var response = await deploymentManager.PushDeployFromStream(zipStream, new ZipDeployMetadata(), queryParams); response.EnsureSuccessStatusCode(); if (isAsync) { await DeploymentTestHelper.WaitForDeploymentCompletionAsync(applicationManager, deployer); } } }