Esempio n. 1
0
        public Task TestZipDeployWithMetadata()
        {
            var author      = "testAuthor";
            var authorEmail = "*****@*****.**";
            var deployer    = "testDeployer";
            var message     = "Test message for deployment";

            return(ApplicationManager.RunAsync("TestSimpleZipDeployment", async appManager =>
            {
                var files = DeploymentTestHelper.CreateRandomFilesForZip(10);
                var response = await DeployZip(appManager, files, new ZipDeployMetadata
                {
                    Author = author,
                    AuthorEmail = authorEmail,
                    Deployer = deployer,
                    Message = message
                });
                response.EnsureSuccessStatusCode();
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");
                var result = await appManager.DeploymentManager.GetResultAsync("latest");

                Assert.Equal(author, result.Author);
                Assert.Equal(authorEmail, result.AuthorEmail);
                Assert.Equal(deployer, result.Deployer);
                Assert.Equal(message, result.Message);
            }));
        }
Esempio n. 2
0
        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");
                }
            }));
        }
Esempio n. 3
0
        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");
            });
        }
Esempio n. 4
0
        public Task EnsureConflictResultOnSimultaneousSyncRequest()
        {
            return(ApplicationManager.RunAsync("EnsureConflictResultOnSimultaneousSyncRequest", async appManager =>
            {
                // Big enough to run for a few seconds
                var files = DeploymentTestHelper.CreateRandomFilesForZip(1000);
                var response = await DeployZip(appManager, files, new ZipDeployMetadata {
                    IsAsync = true
                });
                response.EnsureSuccessStatusCode();

                // Immediately try another deployment
                var response2 = await DeployZip(appManager, new TestFile[0], new ZipDeployMetadata());

                Assert.Equal(HttpStatusCode.Conflict, response2.StatusCode);

                DeployResult result;
                do
                {
                    result = await appManager.DeploymentManager.GetResultAsync("latest");
                    Assert.Equal(GetZipDeployer(), result.Deployer);
                    await Task.Delay(TimeSpan.FromSeconds(2));
                } while (!new[] { DeployStatus.Failed, DeployStatus.Success }.Contains(result.Status));

                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");
            }));
        }
Esempio n. 5
0
        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");
                }
            }));
        }
Esempio n. 6
0
        public Task TestSideBySideWithGitRepo()
        {
            return(ApplicationManager.RunAsync("TestSimpleZipDeployment", async appManager =>
            {
                using (var repo = Git.Init(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())))
                {
                    // First deploy zip
                    var files = DeploymentTestHelper.CreateRandomFilesForZip(10);
                    var response = await DeployZip(appManager, files, new ZipDeployMetadata());
                    response.EnsureSuccessStatusCode();
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");

                    await appManager.SettingsManager.SetValue(SettingsKeys.ScmType, "LocalGit");

                    // Push-deploy git repo
                    var gitFilePath = Path.Combine(repo.PhysicalPath, Path.GetRandomFileName());
                    File.WriteAllText(gitFilePath, Guid.NewGuid().ToString("N"));
                    Git.Commit(repo.PhysicalPath, "Initial commit");
                    var gitResult = appManager.GitDeploy(repo.PhysicalPath);
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, Directory.GetFiles(repo.PhysicalPath).Select(f => Path.GetFileName(f)).ToArray(), "site/wwwroot");

                    // Deploy new zip
                    var files2 = DeploymentTestHelper.CreateRandomFilesForZip(10);
                    var response2 = await DeployZip(appManager, files2, new ZipDeployMetadata());
                    response2.EnsureSuccessStatusCode();
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files2.Select(f => f.Filename).ToArray(), "site/wwwroot");

                    // Redeploy git deployment
                    var id = Git.Id(repo.PhysicalPath);
                    var response3 = await appManager.DeploymentManager.DeployAsync(id);
                    response3.EnsureSuccessStatusCode();
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, Directory.GetFiles(repo.PhysicalPath).Select(f => Path.GetFileName(f)).ToArray(), "site/wwwroot");
                }
            }));
        }
Esempio n. 7
0
        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");
                }
            }));
        }
Esempio n. 8
0
        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");
                }
            }));
        }
Esempio n. 9
0
        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");
            });
        }
Esempio n. 10
0
        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");
            });
        }
Esempio n. 11
0
 public Task TestSimpleZipDeployment()
 {
     return(ApplicationManager.RunAsync("TestSimpleZipDeployment", async appManager =>
     {
         var files = DeploymentTestHelper.CreateRandomFilesForZip(10);
         var response = await DeployZip(appManager, files, new ZipDeployMetadata());
         response.EnsureSuccessStatusCode();
         await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");
     }));
 }
Esempio n. 12
0
 public Task TestSimpleWarDeploymentWithCustomAppName()
 {
     return(ApplicationManager.RunAsync("TestSimpleWarDeploymentPerformsCleanDeployment", async appManager =>
     {
         var files = DeploymentTestHelper.CreateRandomFilesForZip(10);
         var response = await DeployWar(appManager, files, new ZipDeployMetadata(), "testappname");
         response.EnsureSuccessStatusCode();
         await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot/webapps/testappname");
     }));
 }
Esempio n. 13
0
        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");
            });
        }
Esempio n. 14
0
        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");
            });
        }
Esempio n. 15
0
        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");
            });
        }
Esempio n. 16
0
        private async Task AssertSuccesfulAsyncDeployment(ApplicationManager appManager, TestFile[] files, string path = null)
        {
            DeployResult result;

            do
            {
                result = await appManager.DeploymentManager.GetResultAsync("latest");

                Assert.Equal(GetZipDeployer(), result.Deployer);
                await Task.Delay(TimeSpan.FromSeconds(2));
            } while (!new[] { DeployStatus.Failed, DeployStatus.Success }.Contains(result.Status));

            await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), path);
        }
Esempio n. 17
0
        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!");
            }));
        }
Esempio n. 18
0
        public Task TestSimpleZipUrlDeployment(bool isArmRequest, bool isAsync)
        {
            var testName   = isArmRequest ? "TestSimpleZipUrlARMDeployment" : "TestSimpleZipUrlDeployment";
            var packageUri = "https://raw.githubusercontent.com/KuduApps/ZipDeployArtifacts/master/HelloKudu.zip";

            return(ApplicationManager.RunAsync(testName, async appManager =>
            {
                var client = appManager.ZipDeploymentManager.Client;
                var requestUri = client.BaseAddress;
                if (!isArmRequest && isAsync)
                {
                    requestUri = new Uri(string.Format("{0}?isAsync=true", requestUri));
                }

                using (var request = new HttpRequestMessage(HttpMethod.Put, requestUri))
                {
                    if (isArmRequest)
                    {
                        var payload = new { properties = new { packageUri = packageUri } };
                        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/zipdeploy?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");
                    }

                    using (var response = await client.SendAsync(request))
                    {
                        if (isAsync || isArmRequest)
                        {
                            Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
                            await AssertSuccessfulDeployment(appManager, timeoutSecs: 10);
                        }
                        else
                        {
                            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                        }

                        await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new[] { "host.json", "images", "index.htm" }, "site/wwwroot");
                        await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new[] { "picture1.jpg", "picture2.jpg" }, path: "site/wwwroot/images");
                    }
                }
            }));
        }
Esempio n. 19
0
        public Task TestSimpleWarDeploymentPerformsCleanDeployment()
        {
            return(ApplicationManager.RunAsync("TestSimpleWarDeploymentPerformsCleanDeployment", async appManager =>
            {
                // STEP 1: create a file before doing a wardeploy. We expect wardeploy to remove this file
                var fileName = "file-before-wardeployment-" + Guid.NewGuid().ToString("N");
                appManager.VfsWebRootManager.WriteAllText("webapps/ROOT/" + fileName, "some content");
                var deployedFiles = appManager.VfsWebRootManager.ListAsync("webapps/ROOT/").Result.ToList();
                Assert.Equal(1, deployedFiles.Count);
                Assert.Equal(fileName, deployedFiles[0].Name);

                // STEP 2: Perform wardeploy and check files deployed by wardeploy are the only ones that exist now
                // (in other words, check that the file created in step 1 is removed by wardeploy)
                var files = DeploymentTestHelper.CreateRandomFilesForZip(10);
                var response = await DeployWar(appManager, files, new ZipDeployMetadata());
                response.EnsureSuccessStatusCode();
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot/webapps/ROOT");
            }));
        }
Esempio n. 20
0
        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");
                }
            }));
        }
Esempio n. 21
0
        public Task EnsureBuildConfigBehavior()
        {
            return(ApplicationManager.RunAsync("EnsureProjectSettingHonored", async appManager =>
            {
                var files = new[]
                {
                    new TestFile {
                        Filename = "package.json", Content = simplePackageJsonWithDependencyContent
                    }
                };

                // Should do KuduSync copy only, no build (zip deployments are assumed to be complete by default)
                var response = await DeployZip(appManager, files, new ZipDeployMetadata());
                response.EnsureSuccessStatusCode();
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");

                var files2 = files.Concat(new[]
                {
                    new TestFile {
                        Filename = ".deployment", Content = "[config]\r\nSCM_DO_BUILD_DURING_DEPLOYMENT = true"
                    }
                }).ToArray();

                await appManager.SettingsManager.SetValue("SCM_DO_BUILD_DURING_DEPLOYMENT", "false");

                // Still won't build, since the site setting should override the .deployment. Note that we don't
                // expect .deployment to be copied to the site root.
                var response2 = await DeployZip(appManager, files2, new ZipDeployMetadata());
                response2.EnsureSuccessStatusCode();
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");

                await appManager.SettingsManager.Delete("SCM_DO_BUILD_DURING_DEPLOYMENT");

                // Deploy once more, now we expect a node build to occur
                var response3 = await DeployZip(appManager, files2, new ZipDeployMetadata());
                response3.EnsureSuccessStatusCode();

                var expected = files.Concat(new[] { new TestFile {
                                                        Filename = "node_modules"
                                                    } }).ToArray();
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expected.Select(f => f.Filename).ToArray(), "site/wwwroot");
            }));
        }
Esempio n. 22
0
        public Task EnsureProjectSettingHonored()
        {
            return(ApplicationManager.RunAsync("EnsureProjectSettingHonored", async appManager =>
            {
                await appManager.SettingsManager.SetValue("PROJECT", "subdir");

                var rootFile = new TestFile {
                    Filename = "should-not-be-deployed", Content = ""
                };
                var subdirFile = new TestFile {
                    Filename = "subdir/should-be-deployed", Content = ""
                };

                var files = new[] { rootFile, subdirFile };
                var response = await DeployZip(appManager, files, new ZipDeployMetadata());
                response.EnsureSuccessStatusCode();
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new[] { "should-be-deployed" }, "site/wwwroot");
            }));
        }
Esempio n. 23
0
        public Task TestStartupFileDeployment(bool isAsync)
        {
            return(ApplicationManager.RunAsync("TestStartupFileDeployment", async appManager =>
            {
                var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager);
                var startupFileName = KuduUtils.RunningAgainstLinuxKudu ? "startup.sh" : "startup.cmd";

                // Default deployment mode - overwrite previous startup file
                {
                    await DeployNonZippedArtifact(appManager, "startup", "invalid/path/to/test/that/it/is/ignored", isAsync, true, $"site/scripts/{startupFileName}");
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { startupFileName }, "site/scripts");
                }

                // Clean deployment
                {
                    await DeployNonZippedArtifact(appManager, "startup", "invalid/path/to/test/that/it/is/ignored", isAsync, true, $"site/scripts/{startupFileName}");
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string[] { startupFileName }, "site/scripts");
                }
            }));
        }
Esempio n. 24
0
        public Task TestLegacyWarDeployment(bool isAsync)
        {
            return ApplicationManager.RunAsync("TestLegacyWarDeployment", async appManager =>
            {
                ConfigureSiteAsTomcatSite(appManager);

                // STEP 1A: First legacy war deployment
                var files1 = DeploymentTestHelper.CreateRandomFilesForZip(10);
                await DeployZippedArtifact(appManager, appManager.OneDeployManager, files1, "war", "site/wwwroot/webapps/ROOT", isAsync);

                // STEP 1B: Validate the result of the first legacy war deployment
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files1.Select(f => f.Filename).ToArray(), "site/wwwroot/webapps/ROOT");


                // STEP 2A: Second legacy war deployment
                var files2 = DeploymentTestHelper.CreateRandomFilesForZip(10);
                await DeployZippedArtifact(appManager, appManager.OneDeployManager, files2, "war", "site/wwwroot/webapps/ROOT", isAsync);

                // STEP 2B: Validate that the second legacy war deployment cleans up the files deployes by the first deployment
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files2.Select(f => f.Filename).ToArray(), "site/wwwroot/webapps/ROOT");
            });
        }
Esempio n. 25
0
        public Task TestUpdateDeployStatusHeaderZipDeployment()
        {
            return(ApplicationManager.RunAsync("TestUpdateDeployStatusHeaderZipDeployment", async appManager =>
            {
                var files = DeploymentTestHelper.CreateRandomFilesForZip(10);
                var response = await DeployZip(appManager, files, new ZipDeployMetadata {
                    TrackDeploymentProgress = true, IsAsync = true
                });
                response.EnsureSuccessStatusCode();
                Assert.True(response.Headers.Contains(Constants.ScmDeploymentIdHeader));
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");

                // If TrackDeploymentProgress=false, the response header should not contain the ScmDeploymentId
                files = DeploymentTestHelper.CreateRandomFilesForZip(10);
                response = await DeployZip(appManager, files, new ZipDeployMetadata {
                    TrackDeploymentProgress = false, IsAsync = true
                });
                response.EnsureSuccessStatusCode();
                Assert.True(!response.Headers.Contains(Constants.ScmDeploymentIdHeader));
                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");
            }));
        }
Esempio n. 26
0
        public Task TestZipDeployment(bool isAsync)
        {
            return(ApplicationManager.RunAsync("TestZipDeployment", async appManager =>
            {
                // Incremental deployment - not the default mode
                {
                    var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager);

                    var files1 = DeploymentTestHelper.CreateRandomFilesForZip(10);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files1, "zip", null, isAsync, isClean: false);
                    var expectedFiles1 = files1.Select(f => f.Filename).ToList();
                    expectedFiles1.Add(initialFileName);
                    expectedFiles1.Add("webapps");
                    expectedFiles1.Add("hostingstart.html");
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles1.ToArray(), "site/wwwroot");
                }

                // Default deployment - clean
                {
                    var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager);

                    var files1 = DeploymentTestHelper.CreateRandomFilesForZip(10);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files1, "zip", null, isAsync);
                    var expectedFiles1 = files1.Select(f => f.Filename).ToList();
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles1.ToArray(), "site/wwwroot");
                }

                // Custom path
                {
                    var initialFileName = DeploymentTestHelper.DeployRandomFilesEverywhere(appManager);

                    var files1 = DeploymentTestHelper.CreateRandomFilesForZip(10);
                    await DeployZippedArtifact(appManager, appManager.OneDeployManager, files1, "zip", "dir1/dir2", isAsync);
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, new string [] { "dir1" }, "site/wwwroot");
                    var expectedFiles1 = files1.Select(f => f.Filename).ToList();
                    await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, expectedFiles1.ToArray(), "site/wwwroot/dir1/dir2");
                }
            }));
        }
Esempio n. 27
0
        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");

                DeployResult result;
                do
                {
                    result = await appManager.DeploymentManager.GetResultAsync("latest");
                    Assert.Equal(GetZipDeployer(), result.Deployer);
                    await Task.Delay(TimeSpan.FromSeconds(2));
                } while (!new[] { DeployStatus.Failed, DeployStatus.Success }.Contains(result.Status));

                await DeploymentTestHelper.AssertSuccessfulDeploymentByFilenames(appManager, files.Select(f => f.Filename).ToArray(), "site/wwwroot");
            }));
        }