public void TestFallbackToDefaultNodeJsVersionWithServerJsAndEmptyPackageJson() { // Arrange string appName = "FallbackToDefaultNodeJsVersionWithServerJsAndEmptyPackageJson"; using (var repo = Git.Clone("VersionPinnedNodeJsApp")) { 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); }); } }
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); }); } }
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); }); } }
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 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.")); }); } }
public void TestNodeCustomStartScriptFromPackageJson() { // Arrange string appName = "TestCustomStartScriptFromPackageJson"; using (var repo = Git.Clone("NodeWithCustomStartScript")) { ApplicationManager.Run(appName, appManager => { // Act GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath); var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList(); // Assert deployment success Assert.Equal(1, results.Count); Assert.Equal(DeployStatus.Success, results[0].Status); // Verify log output Assert.Contains("Using start-up script app/app.js", deployResult.GitTrace); Assert.Contains("Updating iisnode.yml", deployResult.GitTrace); // Verify app works. KuduAssert.VerifyUrl(appManager.SiteUrl, "Hello Main App!"); // Verify that node-inspector works KuduAssert.VerifyUrl(appManager.SiteUrl + "/app/app.js/debug", "node-inspector"); }); } }
public void TestFallbackToDefaultNodeJsVersionWithServerJsOnly() { // Arrange string appName = "FallbackToDefaultNodeJsVersionWithServerJsOnly"; using (var repo = Git.Clone("VersionPinnedNodeJsApp")) { repo.DeleteFile("iisnode.yml"); 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 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"); }); } }
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"); }); } }
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"); }); } }
public virtual void GitVerify(GitDeploymentResult result, Setting setting) { Assert.Contains(BuilderTrace, result.GitTrace); foreach (string text in setting.ContainStrings) { Assert.Contains(text, result.GitTrace); } foreach (string text in setting.NotContainStrings) { Assert.DoesNotContain(text, result.GitTrace); } }
public void TestPositiveMatch() { // Arrange string appName = "VersionPinnedNodeJsApp"; using (var repo = Git.Clone("VersionPinnedNodeJsApp")) { 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, "v0.8.2"); }); } }