Esempio n. 1
0
        public void DeletesToRepositoryArePropagatedForWaps()
        {
            string repositoryName = "Mvc3Application";
            string appName        = KuduUtils.GetRandomWebsiteName("DeletesToRepoForWaps");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    string deletePath  = Path.Combine(repo.PhysicalPath, @"Mvc3Application\Controllers\AccountController.cs");
                    string projectPath = Path.Combine(repo.PhysicalPath, @"Mvc3Application\Mvc3Application.csproj");

                    // Act
                    appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl + "Account/LogOn", statusCode: HttpStatusCode.OK);

                    File.Delete(deletePath);
                    File.WriteAllText(projectPath, File.ReadAllText(projectPath).Replace(@"<Compile Include=""Controllers\AccountController.cs"" />", ""));
                    Git.Commit(repo.PhysicalPath, "Deleted the filez");
                    appManager.GitDeploy(repo.PhysicalPath);
                    results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(2, results.Count);
                    Assert.Equal(DeployStatus.Success, results[1].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl + "Account/LogOn", statusCode: HttpStatusCode.NotFound);
                });
            }
        }
Esempio n. 2
0
        public void TestTurningAutomaticVersionSelectionOffWithIisnodeYmlWithNodeProcessCommandLine()
        {
            // Arrange
            string repositoryName = "TurningAutomaticVersionSelectionOffWithIisnodeYml";
            string appName        = KuduUtils.GetRandomWebsiteName("TurningAutomaticVersionSelectionOffWithIisnodeYml");
            string cloneUrl       = "https://github.com/KuduApps/VersionPinnedNodeJsApp.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                repo.WriteFile("iisnode.yml", "nodeProcessCommandLine: bar");
                Git.Commit(repo.PhysicalPath, "Changes");

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    Assert.Contains("The iisnode.yml file explicitly sets nodeProcessCommandLine", deployResult.GitTrace);
                });
            }
        }
Esempio n. 3
0
        public void PullApiTestGenericFormat()
        {
            string payload = @"{ ""oldRef"": ""0000000000000000000"", ""newRef"": ""7e2a599e2d28665047ec347ab36731c905c95e8b"", ""url"": ""https://github.com/KuduApps/SimpleWebApplication.git"", ""deployer"" : ""me!"" }";
            string appName = KuduUtils.GetRandomWebsiteName("PullApiTestGenericFormat");

            ApplicationManager.Run(appName, appManager =>
            {
                var handler = new HttpClientHandler
                {
                    Credentials = appManager.DeploymentManager.Credentials
                };

                var client = new HttpClient(handler)
                {
                    BaseAddress = new Uri(appManager.ServiceUrl),
                    Timeout     = TimeSpan.FromMinutes(5)
                };

                var post = new Dictionary <string, string>
                {
                    { "payload", payload }
                };

                client.PostAsync("deploy", new FormUrlEncodedContent(post)).Wait();

                var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
                Assert.Equal(1, results.Count);
                Assert.Equal(DeployStatus.Success, results[0].Status);
                KuduAssert.VerifyUrl(appManager.SiteUrl, "Welcome to ASP.NET!");
                Assert.Equal("me!", results[0].Deployer);
            });
        }
Esempio n. 4
0
        public void PullApiTestGitHubFormat()
        {
            string githubPayload = @"{ ""after"": ""7e2a599e2d28665047ec347ab36731c905c95e8b"", ""before"": ""7e2a599e2d28665047ec347ab36731c905c95e8b"", ""commits"": [], ""compare"": ""https://github.com/KuduApps/GitHookTest/compare/7e2a599e2d28...7e2a599e2d28"", ""created"": false, ""deleted"": false, ""forced"": false, ""head_commit"": { ""added"": [ "".gitignore"", ""SimpleWebApplication.sln"", ""SimpleWebApplication/About.aspx"", ""SimpleWebApplication/About.aspx.cs"", ""SimpleWebApplication/About.aspx.designer.cs"", ""SimpleWebApplication/Account/ChangePassword.aspx"", ""SimpleWebApplication/Account/ChangePassword.aspx.cs"", ""SimpleWebApplication/Account/ChangePassword.aspx.designer.cs"", ""SimpleWebApplication/Account/ChangePasswordSuccess.aspx"", ""SimpleWebApplication/Account/ChangePasswordSuccess.aspx.cs"", ""SimpleWebApplication/Account/ChangePasswordSuccess.aspx.designer.cs"", ""SimpleWebApplication/Account/Login.aspx"", ""SimpleWebApplication/Account/Login.aspx.cs"", ""SimpleWebApplication/Account/Login.aspx.designer.cs"", ""SimpleWebApplication/Account/Register.aspx"", ""SimpleWebApplication/Account/Register.aspx.cs"", ""SimpleWebApplication/Account/Register.aspx.designer.cs"", ""SimpleWebApplication/Account/Web.config"", ""SimpleWebApplication/Default.aspx"", ""SimpleWebApplication/Default.aspx.cs"", ""SimpleWebApplication/Default.aspx.designer.cs"", ""SimpleWebApplication/Global.asax"", ""SimpleWebApplication/Global.asax.cs"", ""SimpleWebApplication/Properties/AssemblyInfo.cs"", ""SimpleWebApplication/Scripts/jquery-1.4.1-vsdoc.js"", ""SimpleWebApplication/Scripts/jquery-1.4.1.js"", ""SimpleWebApplication/Scripts/jquery-1.4.1.min.js"", ""SimpleWebApplication/SimpleWebApplication.csproj"", ""SimpleWebApplication/Site.Master"", ""SimpleWebApplication/Site.Master.cs"", ""SimpleWebApplication/Site.Master.designer.cs"", ""SimpleWebApplication/Styles/Site.css"", ""SimpleWebApplication/Web.Debug.config"", ""SimpleWebApplication/Web.Release.config"", ""SimpleWebApplication/Web.config"" ], ""author"": { ""email"": ""*****@*****.**"", ""name"": ""davidebbo"", ""username"": ""davidebbo"" }, ""committer"": { ""email"": ""*****@*****.**"", ""name"": ""davidebbo"", ""username"": ""davidebbo"" }, ""distinct"": false, ""id"": ""7e2a599e2d28665047ec347ab36731c905c95e8b"", ""message"": ""Initial"", ""modified"": [], ""removed"": [], ""timestamp"": ""2011-11-21T23:07:42-08:00"", ""url"": ""https://github.com/KuduApps/GitHookTest/commit/7e2a599e2d28665047ec347ab36731c905c95e8b"" }, ""pusher"": { ""name"": ""none"" }, ""ref"": ""refs/heads/master"", ""repository"": { ""created_at"": ""2012-06-28T00:07:55-07:00"", ""description"": """", ""fork"": false, ""forks"": 1, ""has_downloads"": true, ""has_issues"": true, ""has_wiki"": true, ""language"": ""ASP"", ""name"": ""GitHookTest"", ""open_issues"": 0, ""organization"": ""KuduApps"", ""owner"": { ""email"": ""*****@*****.**"", ""name"": ""KuduApps"" }, ""private"": false, ""pushed_at"": ""2012-06-28T00:11:48-07:00"", ""size"": 188, ""url"": ""https://github.com/KuduApps/SimpleWebApplication"", ""watchers"": 1 } }";
            string appName       = KuduUtils.GetRandomWebsiteName("PullApiTestGitHubFormat");

            ApplicationManager.Run(appName, appManager =>
            {
                var handler = new HttpClientHandler
                {
                    Credentials = appManager.DeploymentManager.Credentials
                };

                var client = new HttpClient(handler)
                {
                    BaseAddress = new Uri(appManager.ServiceUrl),
                    Timeout     = TimeSpan.FromMinutes(5)
                };

                var post = new Dictionary <string, string>
                {
                    { "payload", githubPayload }
                };

                client.PostAsync("deploy", new FormUrlEncodedContent(post)).Wait();

                var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
                Assert.Equal(1, results.Count);
                Assert.Equal(DeployStatus.Success, results[0].Status);
                KuduAssert.VerifyUrl(appManager.SiteUrl, "Welcome to ASP.NET!");
            });
        }
Esempio n. 5
0
        public void PullApiTestBitbucketFormat()
        {
            string bitbucketPayload = @"{ ""canon_url"": ""https://github.com"", ""commits"": [ { ""author"": ""davidebbo"", ""branch"": ""master"", ""files"": [ { ""file"": ""Mvc3Application/Views/Home/Index.cshtml"", ""type"": ""modified"" } ], ""message"": ""Blah2\n"", ""node"": ""e550351c5188"", ""parents"": [ ""297fcc65308c"" ], ""raw_author"": ""davidebbo <*****@*****.**>"", ""raw_node"": ""e550351c5188681a9ed889e07bc1fbc0bd51a0f2"", ""revision"": null, ""size"": -1, ""timestamp"": ""2012-09-20 03:11:20"", ""utctimestamp"": ""2012-09-20 01:11:20+00:00"" } ], ""repository"": { ""absolute_url"": ""/KuduApps/SimpleWebApplication"", ""fork"": false, ""is_private"": false, ""name"": ""Mvc3Application"", ""owner"": ""davidebbo"", ""scm"": ""git"", ""slug"": ""mvc3application"", ""website"": """" }, ""user"": ""davidebbo"" }";
            string appName          = KuduUtils.GetRandomWebsiteName("PullApiTestBitbucketFormat");

            ApplicationManager.Run(appName, appManager =>
            {
                var handler = new HttpClientHandler
                {
                    Credentials = appManager.DeploymentManager.Credentials
                };

                var client = new HttpClient(handler)
                {
                    BaseAddress = new Uri(appManager.ServiceUrl),
                    Timeout     = TimeSpan.FromMinutes(5)
                };

                client.DefaultRequestHeaders.Add("User-Agent", "Bitbucket.org");

                var post = new Dictionary <string, string>
                {
                    { "payload", bitbucketPayload }
                };

                client.PostAsync("deploy", new FormUrlEncodedContent(post)).Wait();

                var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
                Assert.Equal(1, results.Count);
                Assert.Equal(DeployStatus.Success, results[0].Status);
                KuduAssert.VerifyUrl(appManager.SiteUrl, "Welcome to ASP.NET!");
            });
        }
        public void PushSimpleWapWithCustomDeploymentScript()
        {
            // Arrange
            string repositoryName = "WapWithCustomDeploymentScript";
            string appName        = KuduUtils.GetRandomWebsiteName("WapWithCustomDeploymentScript");
            string cloneUrl       = "https://github.com/KuduApps/CustomBuildScript.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                repo.WriteFile(".deployment", @"
[config]
command = deploy.cmd");
                Git.Commit(repo.PhysicalPath, "Custom build script added");

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl, "DEBUG");
                });
            }
        }
Esempio n. 7
0
        public void DeleteKuduSiteCleansEverything()
        {
            // Arrange
            string repositoryName = "Mvc3Application";
            string appName        = KuduUtils.GetRandomWebsiteName("DeleteKuduSiteCleansEverything");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    Assert.NotNull(results[0].LastSuccessEndTime);

                    appManager.RepositoryManager.Delete().Wait();
                    results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    Assert.Equal(0, results.Count);
                });
            }
        }
        public void PushSimpleWapWithInlineCommand()
        {
            // Arrange
            string repositoryName = "PushSimpleWapWithInlineCommand";
            string appName        = KuduUtils.GetRandomWebsiteName("PushSimpleWapWithInlineCommand");
            string cloneUrl       = "https://github.com/KuduApps/CustomBuildScript.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                repo.WriteFile(".deployment", @"
[config]
command = msbuild SimpleWebApplication/SimpleWebApplication.csproj /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir=""%DEPLOYMENT_TARGET%"";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Debug;SolutionDir=""%DEPLOYMENT_SOURCE%""");
                Git.Commit(repo.PhysicalPath, "Custom build command added");

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl, "DEBUG");
                });
            }
        }
Esempio n. 9
0
        public void TestFallbackToDefaultNodeJsVersionWithIisnodeYmlLackingNodeProcessCommandLine()
        {
            // Arrange
            string repositoryName = "FallbackToDefaultNodeJsVersionWithIisnodeYmlLacking";
            string appName        = KuduUtils.GetRandomWebsiteName("FallbackToDefaultNodeJsVersionWithIisnodeYmlLacking");
            string cloneUrl       = "https://github.com/KuduApps/VersionPinnedNodeJsApp.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                repo.WriteFile("iisnode.yml", "foo: bar");
                repo.DeleteFile("package.json");
                Git.Commit(repo.PhysicalPath, "Changes");

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    Assert.Contains("The package.json file is not present", deployResult.GitTrace);
                });
            }
        }
        public void PushSimpleWapWithFailingCustomDeploymentScript()
        {
            // Arrange
            string repositoryName = "WapWithFailingCustomDeploymentScript";
            string appName        = KuduUtils.GetRandomWebsiteName("WapWithFailingCustomDeploymentScript");
            string cloneUrl       = "https://github.com/KuduApps/CustomBuildScript.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                repo.WriteFile(".deployment", @"
[config]
command = deploy.cmd");
                repo.WriteFile("deploy.cmd", "bogus");
                Git.Commit(repo.PhysicalPath, "Updated the deploy file.");

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Failed, results[0].Status);
                    KuduAssert.VerifyLogOutput(appManager, results[0].Id, ">bogus");
                    KuduAssert.VerifyLogOutput(appManager, results[0].Id, "'bogus' is not recognized as an internal or external command");
                });
            }
        }
Esempio n. 11
0
        public void DeployingBranchThatExists()
        {
            string payload = @"{ ""oldRef"": ""0000000000000000000"", ""newRef"": ""ad21595c668f3de813463df17c04a3b23065fedc"", ""url"": ""https://github.com/KuduApps/RepoWithMultipleBranches.git"", ""deployer"" : ""me!"", branch: ""test"" }";
            string appName = KuduUtils.GetRandomWebsiteName("DeployingBranchThatExists");

            ApplicationManager.Run(appName, appManager =>
            {
                var handler = new HttpClientHandler
                {
                    Credentials = appManager.DeploymentManager.Credentials
                };

                var client = new HttpClient(handler)
                {
                    BaseAddress = new Uri(appManager.ServiceUrl),
                    Timeout     = TimeSpan.FromMinutes(5)
                };

                var post = new Dictionary <string, string>
                {
                    { "payload", payload }
                };

                client.PostAsync("deploy", new FormUrlEncodedContent(post)).Wait();

                var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
                Assert.Equal(1, results.Count);
                Assert.Equal(DeployStatus.Success, results[0].Status);
                KuduAssert.VerifyUrl(appManager.SiteUrl, "Master branch");
                Assert.Equal("me!", results[0].Deployer);
            });
        }
Esempio n. 12
0
        public async Task InPlaceDeploymentBasicTests(IScenario scenario)
        {
            var appName = KuduUtils.GetRandomWebsiteName(scenario.Name);
            await ApplicationManager.RunAsync(appName, async appManager =>
            {
                await appManager.SettingsManager.SetValue(SettingsKeys.RepositoryPath, "wwwroot");

                using (TestRepository testRepository = Git.Clone(scenario.Name, scenario.CloneUrl))
                {
                    var result = appManager.GitDeploy(testRepository.PhysicalPath);

                    // Inplace should not do KuduSync
                    Assert.DoesNotContain("KuduSync", result.GitTrace);

                    // Repository path should not exist
                    Assert.False(appManager.VfsManager.Exists(@"site\repository\.git"), @"Should not have site\repository\.git folder");

                    // Validate builder
                    Assert.Contains(scenario.BuilderTrace, result.GitTrace);
                }

                // Validate deployment status
                var results = (await appManager.DeploymentManager.GetResultsAsync()).ToList();
                Assert.Equal(1, results.Count);
                Assert.Equal(DeployStatus.Success, results[0].Status);

                // Validate site
                scenario.Verify(appManager);
            });
        }
Esempio n. 13
0
        public void DeploymentApisReturn404IfDeploymentIdDoesntExist()
        {
            string appName = KuduUtils.GetRandomWebsiteName("Rtn404IfDeployIdNotExist");

            ApplicationManager.Run(appName, appManager =>
            {
                string id = "foo";
                var ex    = KuduAssert.ThrowsUnwrapped <HttpRequestException>(() => appManager.DeploymentManager.DeleteAsync(id).Wait());
                Assert.Equal("Response status code does not indicate success: 404 (Not Found).", ex.Message);

                ex = KuduAssert.ThrowsUnwrapped <HttpRequestException>(() => appManager.DeploymentManager.DeployAsync(id).Wait());
                Assert.Equal("Response status code does not indicate success: 404 (Not Found).", ex.Message);

                ex = KuduAssert.ThrowsUnwrapped <HttpRequestException>(() => appManager.DeploymentManager.DeployAsync(id, clean: true).Wait());
                Assert.Equal("Response status code does not indicate success: 404 (Not Found).", ex.Message);

                ex = KuduAssert.ThrowsUnwrapped <HttpRequestException>(() => appManager.DeploymentManager.GetLogEntriesAsync(id).Wait());
                Assert.Equal("Response status code does not indicate success: 404 (Not Found).", ex.Message);

                ex = KuduAssert.ThrowsUnwrapped <HttpRequestException>(() => appManager.DeploymentManager.GetResultAsync(id).Wait());
                Assert.Equal("Response status code does not indicate success: 404 (Not Found).", ex.Message);

                ex = KuduAssert.ThrowsUnwrapped <HttpRequestException>(() => appManager.DeploymentManager.GetLogEntryDetailsAsync(id, "fakeId").Wait());
                Assert.Equal("Response status code does not indicate success: 404 (Not Found).", ex.Message);
            });
        }
Esempio n. 14
0
        public void PushAndDeployApps(string name, string repoName,
                                      string repoUrl, string repoCloneUrl,
                                      string defaultBranchName, string verificationText,
                                      HttpStatusCode expectedResponseCode, bool skip, string verificationLogText = null)
        {
            if (!skip)
            {
                string randomTestName = KuduUtils.GetRandomWebsiteName(repoName);
                using (var repo = Git.Clone(randomTestName, repoCloneUrl))
                {
                    ApplicationManager.Run(randomTestName, appManager =>
                    {
                        // Act
                        appManager.GitDeploy(repo.PhysicalPath, defaultBranchName);
                        var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                        // Assert
                        Assert.Equal(1, results.Count);
                        Assert.Equal(DeployStatus.Success, results[0].Status);
                        KuduAssert.VerifyUrl(appManager.SiteUrl, verificationText, expectedResponseCode);
                        if (!String.IsNullOrEmpty(verificationLogText.Trim()))
                        {
                            KuduAssert.VerifyLogOutput(appManager, results[0].Id, verificationLogText.Trim());
                        }
                    });
                }
                Debug.Write(String.Format("Test completed: {0}\n", name));
            }
            else
            {
                Debug.Write(String.Format("Test skipped: {0}\n", name));
            }
        }
Esempio n. 15
0
        public void WarningsAsErrors()
        {
            // Arrange
            string repositoryName = "WarningsAsErrors";
            string appName        = KuduUtils.GetRandomWebsiteName("WarningsAsErrors");
            string cloneUrl       = "https://github.com/KuduApps/WarningsAsErrors.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Failed, results[0].Status);
                    Assert.Null(results[0].LastSuccessEndTime);
                    KuduAssert.VerifyLogOutput(appManager, results[0].Id, "Warning as Error: The variable 'x' is declared but never used");
                    Assert.True(deployResult.GitTrace.Contains("Warning as Error: The variable 'x' is declared but never used"));
                    Assert.True(deployResult.GitTrace.Contains("Error - Changes committed to remote repository but your website not updated."));
                });
            }
        }
Esempio n. 16
0
        private void VerifyDeploymentConfiguration(string siteName, string targetProject, string expectedText, DeployStatus expectedStatus = DeployStatus.Success, string expectedLog = null)
        {
            string name     = KuduUtils.GetRandomWebsiteName(siteName);
            string cloneUrl = "https://github.com/KuduApps/SpecificDeploymentConfiguration.git";

            using (var repo = Git.Clone(name, cloneUrl))
            {
                ApplicationManager.Run(name, appManager =>
                {
                    string deploymentFile = Path.Combine(repo.PhysicalPath, @".deployment");
                    File.WriteAllText(deploymentFile, String.Format(@"[config]
project = {0}", targetProject));
                    Git.Commit(name, "Updated configuration");

                    // Act
                    appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(expectedStatus, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl, expectedText);
                    if (!String.IsNullOrEmpty(expectedLog))
                    {
                        KuduAssert.VerifyLogOutput(appManager, results[0].Id, expectedLog);
                    }
                });
            }
        }
Esempio n. 17
0
        public void FirstPushDeletesPriorContent()
        {
            string repositoryName = "Bakery10";
            string appName        = KuduUtils.GetRandomWebsiteName("FirstPushDelPrior");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    appManager.ProjectSystem.WriteAllText("foo.txt", "This is a test file");
                    string url = appManager.SiteUrl + "/foo.txt";

                    Thread.Sleep(500);

                    KuduAssert.VerifyUrl(url, "This is a test file");

                    // Act
                    appManager.GitDeploy(repo.PhysicalPath);

                    // Assert
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl);
                    KuduAssert.VerifyUrl(url, statusCode: HttpStatusCode.NotFound);
                });
            }
        }
Esempio n. 18
0
        public void TestFallbackToDefaultNodeJsVersionWithServerJsAndEmptyPackageJson()
        {
            // Arrange
            string repositoryName = "FallbackToDefaultNodeJsVersionWithServerJs";
            string appName        = KuduUtils.GetRandomWebsiteName("FallbackToDefaultNodeJsVersionWithServerJsAndEmptyPackageJson");
            string cloneUrl       = "https://github.com/KuduApps/VersionPinnedNodeJsApp.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                repo.DeleteFile("iisnode.yml");
                repo.WriteFile("package.json", @"{ ""name"" : ""foo"", ""version"": ""1.0.0"" }");

                Git.Commit(repo.PhysicalPath, "Changes");

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    Assert.Contains("The package.json file does not specify node.js engine version constraints", deployResult.GitTrace);
                });
            }
        }
Esempio n. 19
0
        public void DeletesToRepositoryArePropagatedForNonWaps()
        {
            string repositoryName = "Bakery10";
            string appName        = KuduUtils.GetRandomWebsiteName("DeleteForNonWaps");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    string deletePath = Path.Combine(repo.PhysicalPath, @"Styles");

                    // Act
                    appManager.GitDeploy(repo.PhysicalPath);

                    // Assert
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl + "Styles/Site.css", statusCode: HttpStatusCode.OK);


                    Directory.Delete(deletePath, recursive: true);
                    Git.Commit(repo.PhysicalPath, "Deleted all styles");

                    appManager.GitDeploy(repo.PhysicalPath);
                    results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(2, results.Count);
                    Assert.Equal(DeployStatus.Success, results[1].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl + "Styles/Site.css", statusCode: HttpStatusCode.NotFound);
                });
            }
        }
Esempio n. 20
0
        public void SetGetDeleteValue()
        {
            // Arrange
            string repositoryName = "Mvc3Application";
            string appName        = KuduUtils.GetRandomWebsiteName("SetValue");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    appManager.SettingsManager.SetValue("x", "1").Wait();

                    // Assert
                    string result = appManager.SettingsManager.GetValue("x").Result;

                    Assert.Equal("1", result);

                    appManager.SettingsManager.Delete("x").Wait();

                    // Act
                    var ex = KuduAssert.ThrowsUnwrapped <HttpRequestException>(() => appManager.SettingsManager.GetValue("x").Wait());

                    // Assert
                    Assert.Equal("Response status code does not indicate success: 404 (Not Found).", ex.Message);
                });
            }
        }
Esempio n. 21
0
        public void GetAllValues()
        {
            // Arrange
            string repositoryName = "Mvc3Application";
            string appName        = KuduUtils.GetRandomWebsiteName("SetValue");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    appManager.SettingsManager.SetValue("x", "1").Wait();
                    appManager.SettingsManager.SetValue("y", "2").Wait();
                    appManager.SettingsManager.SetValue("z", "3").Wait();

                    // Assert
                    NameValueCollection results = appManager.SettingsManager.GetValues().Result;

                    // Default
                    Assert.Equal("master", results[SettingsKeys.Branch]);
                    Assert.Equal("", results[SettingsKeys.BuildArgs]);
                    Assert.Equal("0", results[SettingsKeys.TraceLevel]);

                    Assert.Equal("1", results["x"]);
                    Assert.Equal("2", results["y"]);
                    Assert.Equal("3", results["z"]);
                });
            }
        }
Esempio n. 22
0
        public void TestMismatchBetweenAvailableVersionsAndRequestedVersions()
        {
            // Arrange
            string repositoryName = "TestMismatchBetweenVersions";
            string appName        = KuduUtils.GetRandomWebsiteName("TestMismatchBetweenAvailableVersionsAndRequestedVersions");
            string cloneUrl       = "https://github.com/KuduApps/VersionPinnedNodeJsApp.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                repo.Replace("package.json", "0.8.2", "0.1.0");
                Git.Commit(repo.PhysicalPath, "Changes");

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    Assert.Equal(DeployStatus.Failed, results[0].Status);
                    Assert.Contains("No available node.js version matches application's version constraint of '0.1.0'", deployResult.GitTrace);
                });
            }
        }
Esempio n. 23
0
        public void TestLogStreamNotFound()
        {
            string appName = KuduUtils.GetRandomWebsiteName("TestLogStreamNotFound");

            ApplicationManager.Run(appName, appManager =>
            {
                RemoteLogStreamManager manager = new RemoteLogStreamManager(appManager.ServiceUrl + "/logstream/notfound");
                var ex = KuduAssert.ThrowsUnwrapped <WebException>(() => manager.GetStream().Wait());
                Assert.Equal(((HttpWebResponse)ex.Response).StatusCode, HttpStatusCode.NotFound);
            });
        }
Esempio n. 24
0
        public void ClonesInParallel()
        {
            string appName = KuduUtils.GetRandomWebsiteName("ClonesInParallel");

            ApplicationManager.Run(appName, appManager =>
            {
                var t1 = Task.Factory.StartNew(() => DoClone("PClone1", appManager));
                var t2 = Task.Factory.StartNew(() => DoClone("PClone2", appManager));
                var t3 = Task.Factory.StartNew(() => DoClone("PClone3", appManager));
                Task.WaitAll(t1, t2, t3);
            });
        }
Esempio n. 25
0
        public void CloneFromNewRepoShouldHaveBeEmpty()
        {
            string repositoryName = "CloneFromNewRepoShouldHaveFile";
            string appName        = KuduUtils.GetRandomWebsiteName("CloneNew");

            ApplicationManager.Run(appName, appManager =>
            {
                using (var repo = Git.Clone(repositoryName, appManager.GitUrl, createDirectory: true))
                {
                    Assert.False(repo.FileExists("index.html"));
                }
            });
        }
Esempio n. 26
0
        public void PullApiTestConsecutivePushesGetQueued()
        {
            string payload = @"{ ""oldRef"": ""0000000000000000000"", ""newRef"": ""ad21595c668f3de813463df17c04a3b23065fedc"", ""url"": ""https://github.com/KuduApps/RepoWithMultipleBranches.git"", ""deployer"" : ""me!"", branch: ""test"" }";
            string appName = KuduUtils.GetRandomWebsiteName("PullApiTestPushesGetQueued");

            ApplicationManager.Run(appName, appManager =>
            {
                var handler = new HttpClientHandler
                {
                    Credentials = appManager.DeploymentManager.Credentials
                };

                var client = new HttpClient(handler)
                {
                    BaseAddress = new Uri(appManager.ServiceUrl),
                    Timeout     = TimeSpan.FromMinutes(5)
                };

                var post = new Dictionary <string, string>
                {
                    { "payload", payload }
                };

                Task <HttpResponseMessage> responseTask = null;

                // Do another post in parallel a second after
                new Thread(() =>
                {
                    Thread.Sleep(1000);

                    // Ideally we'd push something else to github but at least this exercises the code path
                    responseTask = client.PostAsync("deploy", new FormUrlEncodedContent(post));
                }).Start();

                client.PostAsync("deploy", new FormUrlEncodedContent(post)).Wait();

                var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
                Assert.NotNull(responseTask);
                Assert.Equal(HttpStatusCode.Conflict, responseTask.Result.StatusCode);
                Assert.Equal(1, results.Count);
                Assert.Equal(DeployStatus.Success, results[0].Status);
                KuduAssert.VerifyUrl(appManager.SiteUrl, "Master branch");
                Assert.Equal("me!", results[0].Deployer);
            });
        }
Esempio n. 27
0
        public void GoingBackInTimeShouldOverwriteModifiedFilesInRepo()
        {
            // Arrange
            string repositoryName   = "Mvc3Application";
            string appName          = KuduUtils.GetRandomWebsiteName("GoBackOverwriteModified");
            string verificationText = "Welcome to ASP.NET MVC!";

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                string id = repo.CurrentId;

                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    appManager.GitDeploy(repositoryName);

                    KuduAssert.VerifyUrl(appManager.SiteUrl, verificationText);

                    repo.AppendFile(@"Mvc3Application\Views\Home\Index.cshtml", "Say Whattttt!");

                    // Make a small changes and commit them to the local repo
                    Git.Commit(repositoryName, "This is a small changes");

                    // Push those changes
                    appManager.GitDeploy(repositoryName);

                    // Make a server site change and verify it shows up
                    appManager.ProjectSystem.WriteAllText("Views/Home/Index.cshtml", "Hello world!");

                    Thread.Sleep(500);

                    KuduAssert.VerifyUrl(appManager.SiteUrl, "Hello world!");

                    // Now go back in time
                    appManager.DeploymentManager.DeployAsync(id).Wait();

                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(2, results.Count);
                    Assert.Equal(DeployStatus.Success, results[0].Status);
                    KuduAssert.VerifyUrl(appManager.SiteUrl, verificationText);
                });
            }
        }
        public void PushThenClone()
        {
            string repositoryName = "Bakery10";
            string appName        = KuduUtils.GetRandomWebsiteName("PushThenClone");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    appManager.GitDeploy(repo.PhysicalPath);

                    using (var clonedRepo = Git.Clone(repositoryName, appManager.GitUrl, createDirectory: true))
                    {
                        Assert.True(clonedRepo.FileExists("Default.cshtml"));
                    }
                });
            }
        }
Esempio n. 29
0
        public void SetGetValue()
        {
            // Arrange
            string repositoryName = "Mvc3Application";
            string appName        = KuduUtils.GetRandomWebsiteName("SetValue");

            using (var repo = Git.CreateLocalRepository(repositoryName))
            {
                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    appManager.SettingsManager.SetValue("x", "1").Wait();

                    // Assert
                    string result = appManager.SettingsManager.GetValue("x").Result;

                    Assert.Equal("1", result);
                });
            }
        }
Esempio n. 30
0
        public void PushingNonMasterBranchToMasterBranchShouldDeploy()
        {
            string repositoryName = "PushingNonMasterBranchToMasterBranchShouldDeploy";
            string appName        = KuduUtils.GetRandomWebsiteName("PushNonMasterToMaster");
            string cloneUrl       = "https://github.com/KuduApps/RepoWithMultipleBranches.git";

            using (var repo = Git.Clone(repositoryName, cloneUrl))
            {
                Git.CheckOut(repo.PhysicalPath, "test");
                ApplicationManager.Run(appName, appManager =>
                {
                    // Act
                    appManager.GitDeploy(repo.PhysicalPath, "test", "master");
                    var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();

                    // Assert
                    Assert.Equal(1, results.Count);
                    KuduAssert.VerifyUrl(appManager.SiteUrl, "Test branch");
                });
            }
        }