Skip to content
This repository

Fix for several site generator issues #281

Merged
merged 3 commits into from over 1 year ago

2 participants

Amit Apple Suwat Ch
Amit Apple
Collaborator

There were some bug fixes in azure-cli in the deployment script generator part that we need for the site generator, in order to get them I've cloned azure-cli and put all fixes in a branch called "latest" there.

So now we can use this branch when we create the kudu installation, this way we remove the dependency we have on azure-cli schedule (specifically for the kudu service).

Amit Apple amitapl Change script to install azure-cli from a private branch, so we have …
…the latest fixes (not dependant on azure-cli schedule for them).
d40dea3
amitapl added some commits
Amit Apple amitapl Moved selectNodeVersion to run after the deployment script and output…
… the generated file to wwwroot directory.

This is since there was an issue with current logic, we generated the file in the repo, the problem is that the file will always remain there, so next deployment it won't be regenerated (even if the value for it should be different).
The new logic fixes this issue.
01c3a91
Amit Apple amitapl Adding a new class to use for producing traces coming from tests, thi…
…s is to improve the ability to investigate issues just by looking at the test logs.

For now added in some tests the deployment log.
More test related traces will be added.
6ed9b0f
Amit Apple
Collaborator

Added more generator related fixes, mainly for SelectNodeVersion:

Moved selectNodeVersion to run after the deployment script and output the generated file to wwwroot directory.

This is since there was an issue with current logic, we generated the file in the repo, the problem is that the file will always remain there, so next deployment it won't be regenerated (even if the value for it should be different).
The new logic fixes this issue.

Suwat Ch
Owner

looks good.

Amit Apple amitapl merged commit 6ed9b0f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 3 unique commits by 1 author.

Dec 31, 2012
Amit Apple amitapl Change script to install azure-cli from a private branch, so we have …
…the latest fixes (not dependant on azure-cli schedule for them).
d40dea3
Jan 01, 2013
Amit Apple amitapl Moved selectNodeVersion to run after the deployment script and output…
… the generated file to wwwroot directory.

This is since there was an issue with current logic, we generated the file in the repo, the problem is that the file will always remain there, so next deployment it won't be regenerated (even if the value for it should be different).
The new logic fixes this issue.
01c3a91
Amit Apple amitapl Adding a new class to use for producing traces coming from tests, thi…
…s is to improve the ability to investigate issues just by looking at the test logs.

For now added in some tests the deployment log.
More test related traces will be added.
6ed9b0f
This page is out of date. Refresh to see the latest.
5 Kudu.Core/Deployment/Generator/GeneratorSiteBuilder.cs
@@ -33,9 +33,9 @@ public override Task Build(DeploymentContext context)
33 33
34 34 try
35 35 {
36   - PreBuild(context);
37 36 GenerateScript(context, buildLogger);
38 37 RunCommand(context, "deploy.cmd");
  38 + PostDeployScript(context);
39 39 tcs.SetResult(null);
40 40 }
41 41 catch (Exception ex)
@@ -47,7 +47,7 @@ public override Task Build(DeploymentContext context)
47 47 return tcs.Task;
48 48 }
49 49
50   - protected virtual void PreBuild(DeploymentContext context)
  50 + protected virtual void PostDeployScript(DeploymentContext context)
51 51 {
52 52 }
53 53
@@ -72,6 +72,7 @@ private void GenerateScript(DeploymentContext context, ILogger buildLogger)
72 72 scriptGenerator.SetHomePath(HomePath);
73 73
74 74 var scriptGeneratorCommand = String.Format(ScriptGeneratorCommandFormat, RepositoryPath, ScriptGeneratorCommandArguments);
  75 + buildLogger.Log(Resources.Log_DeploymentScriptGeneratorCommand, scriptGeneratorCommand);
75 76
76 77 scriptGenerator.ExecuteWithProgressWriter(buildLogger, context.Tracer, _ => false, scriptGeneratorCommand);
77 78 }
6 Kudu.Core/Deployment/Generator/NodeSiteBuilder.cs
@@ -12,9 +12,9 @@ public NodeSiteBuilder(IEnvironment environment, IDeploymentSettingsManager sett
12 12 {
13 13 }
14 14
15   - protected override void PreBuild(DeploymentContext context)
  15 + protected override void PostDeployScript(DeploymentContext context)
16 16 {
17   - base.PreBuild(context);
  17 + base.PostDeployScript(context);
18 18 SelectNodeVersion(context);
19 19 }
20 20
@@ -27,7 +27,7 @@ private void SelectNodeVersion(DeploymentContext context)
27 27 try
28 28 {
29 29 string sourcePath = String.IsNullOrEmpty(ProjectPath) ? RepositoryPath : ProjectPath;
30   - string log = NodeSiteEnabler.SelectNodeVersion(fileSystem, Environment.ScriptPath, sourcePath, context.Tracer);
  30 + string log = NodeSiteEnabler.SelectNodeVersion(fileSystem, Environment.ScriptPath, sourcePath, context.OutputPath, context.Tracer);
31 31
32 32 innerLogger.Log(log);
33 33 }
7 Kudu.Core/Deployment/Generator/NodeSiteEnabler.cs
@@ -25,7 +25,7 @@ public static bool LooksLikeNode(IFileSystem fileSystem, string siteFolder)
25 25 return false;
26 26 }
27 27
28   - public static string SelectNodeVersion(IFileSystem fileSystem, string scriptPath, string sourcePath, ITracer tracer)
  28 + public static string SelectNodeVersion(IFileSystem fileSystem, string scriptPath, string sourcePath, string destinationPath, ITracer tracer)
29 29 {
30 30 // The node.js version selection logic is implemented in selectNodeVersion.js.
31 31
@@ -35,9 +35,10 @@ public static string SelectNodeVersion(IFileSystem fileSystem, string scriptPath
35 35 {
36 36 return executor.ExecuteWithConsoleOutput(
37 37 tracer,
38   - "\"{0}\\selectNodeVersion.js\" \"{1}\" \"{1}\"",
  38 + "\"{0}\\selectNodeVersion.js\" \"{1}\" \"{2}\"",
39 39 scriptPath,
40   - sourcePath).Item1;
  40 + sourcePath,
  41 + destinationPath).Item1;
41 42 }
42 43 catch (Exception e)
43 44 {
9 Kudu.Core/Resources.Designer.cs
@@ -245,6 +245,15 @@ internal class Resources {
245 245 }
246 246
247 247 /// <summary>
  248 + /// Looks up a localized string similar to Using the following command to generate deployment script: &apos;azure {0}&apos;..
  249 + /// </summary>
  250 + internal static string Log_DeploymentScriptGeneratorCommand {
  251 + get {
  252 + return ResourceManager.GetString("Log_DeploymentScriptGeneratorCommand", resourceCulture);
  253 + }
  254 + }
  255 +
  256 + /// <summary>
248 257 /// Looks up a localized string similar to Deployment successful..
249 258 /// </summary>
250 259 internal static string Log_DeploymentSuccessful {
3  Kudu.Core/Resources.resx
@@ -199,6 +199,9 @@
199 199 <data name="Log_DeploymentAlreadyActive" xml:space="preserve">
200 200 <value>Deployment '{0}' already active.</value>
201 201 </data>
  202 + <data name="Log_DeploymentScriptGeneratorCommand" xml:space="preserve">
  203 + <value>Using the following command to generate deployment script: 'azure {0}'.</value>
  204 + </data>
202 205 <data name="Log_DeploymentSuccessful" xml:space="preserve">
203 206 <value>Deployment successful.</value>
204 207 </data>
19 Kudu.FunctionalTests/GitDeploymentTests.cs
@@ -106,13 +106,20 @@ public void CustomDeploymentScriptShouldHaveDeploymentSetting()
106 106 }
107 107 var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
108 108
109   - // Assert
110   - Assert.Equal(1, results.Count);
111   - Assert.Equal(DeployStatus.Success, results[0].Status);
112   - KuduAssert.VerifyUrl(appManager.SiteUrl, verificationText, expectedResponseCode);
113   - if (!String.IsNullOrEmpty(verificationLogText))
  109 + try
  110 + {
  111 + // Assert
  112 + Assert.Equal(1, results.Count);
  113 + Assert.Equal(DeployStatus.Success, results[0].Status);
  114 + KuduAssert.VerifyUrl(appManager.SiteUrl, verificationText, expectedResponseCode);
  115 + if (!String.IsNullOrEmpty(verificationLogText))
  116 + {
  117 + KuduAssert.VerifyLogOutput(appManager, results[0].Id, verificationLogText.Trim());
  118 + }
  119 + }
  120 + finally
114 121 {
115   - KuduAssert.VerifyLogOutput(appManager, results[0].Id, verificationLogText.Trim());
  122 + TestTracer.TraceDeploymentLog(appManager, results[0].Id);
116 123 }
117 124 });
118 125 }
4 Kudu.Services.Web/updateNodeModules.cmd
@@ -3,9 +3,9 @@
3 3 pushd %1
4 4
5 5 if exist %1\node_modules\azure-cli\bin\azure (
6   - cmd /c npm update azure-cli
  6 + cmd /c npm update https://github.com/amitapl/azure-sdk-tools-xplat/tarball/latest
7 7 ) else (
8   - cmd /c npm install azure-cli
  8 + cmd /c npm install https://github.com/amitapl/azure-sdk-tools-xplat/tarball/latest
9 9 )
10 10
11 11 IF %ERRORLEVEL% NEQ 0 goto error
1  Kudu.TestHarness/Kudu.TestHarness.csproj
@@ -59,6 +59,7 @@
59 59 <ItemGroup>
60 60 <Compile Include="ApplicationManager.cs" />
61 61 <Compile Include="ApplicationManagerExtensions.cs" />
  62 + <Compile Include="TestTracer.cs" />
62 63 <Compile Include="HttpUtils.cs" />
63 64 <Compile Include="KuduUtils.cs" />
64 65 <Compile Include="DeploymentManagerExtensions.cs" />
40 Kudu.TestHarness/TestTracer.cs
... ... @@ -0,0 +1,40 @@
  1 +using System;
  2 +using System.Globalization;
  3 +using System.Linq;
  4 +
  5 +namespace Kudu.TestHarness
  6 +{
  7 + public static class TestTracer
  8 + {
  9 + public static void Trace(DateTime messageDateTime, string messageFormat, params object[] args)
  10 + {
  11 + string message;
  12 + if (args != null && args.Length > 0)
  13 + {
  14 + message = String.Format(CultureInfo.CurrentCulture, messageFormat, args);
  15 + }
  16 + else
  17 + {
  18 + message = messageFormat;
  19 + }
  20 + System.Diagnostics.Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "{0}: {1}", messageDateTime, message));
  21 + }
  22 +
  23 + public static void Trace(string messageFormat, params object[] args)
  24 + {
  25 + Trace(DateTime.Now, messageFormat, args);
  26 + }
  27 +
  28 + public static void TraceDeploymentLog(ApplicationManager appManager, string id)
  29 + {
  30 + var entries = appManager.DeploymentManager.GetLogEntriesAsync(id).Result.ToList();
  31 + var allDetails = entries.Where(e => e.DetailsUrl != null)
  32 + .SelectMany(e => appManager.DeploymentManager.GetLogEntryDetailsAsync(id, e.Id).Result).ToList();
  33 + var allEntries = entries.Concat(allDetails).ToList();
  34 + foreach (var entry in allEntries)
  35 + {
  36 + Trace(entry.LogTime, entry.Message);
  37 + }
  38 + }
  39 + }
  40 +}

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.