Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added node16 execution handler #3861

Merged
merged 18 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/Agent.Worker/Handlers/NodeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.VisualStudio.Services.Agent.Worker.Handlers
[ServiceLocator(Default = typeof(NodeHandler))]
public interface INodeHandler : IHandler
{
// Data can be of these two types: NodeHandlerData and Node10HandlerData
// Data can be of these three types: NodeHandlerData, Node10HandlerData and Node16HandlerData
BaseNodeHandlerData Data { get; set; }
}

Expand Down Expand Up @@ -172,11 +172,22 @@ public string GetNodeLocation()
{
bool useNode10 = AgentKnobs.UseNode10.GetValue(ExecutionContext).AsBoolean();
bool taskHasNode10Data = Data is Node10HandlerData;
bool taskHasNode16Data = Data is Node16HandlerData;

string nodeFolder = "node";
if (taskHasNode10Data || useNode10)
if (taskHasNode16Data)
{
Trace.Info($"Task.json has node10 handler data: {taskHasNode10Data}, use node10 for node tasks: {useNode10}");
Trace.Info($"Task.json has node16 handler data: {taskHasNode16Data}");
AndreyIvanov42 marked this conversation as resolved.
Show resolved Hide resolved
nodeFolder = "node16";
}
else if (taskHasNode10Data)
{
Trace.Info($"Task.json has node10 handler data: {taskHasNode10Data}");
nodeFolder = "node10";
}
else if (useNode10)
{
Trace.Info($"Found UseNode10 knob, use node10 for node tasks: {useNode10}");
nodeFolder = "node10";
}
AndreyIvanov42 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
31 changes: 25 additions & 6 deletions src/Agent.Worker/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ public sealed class ExecutionData
private AzurePowerShellHandlerData _azurePowerShell;
private NodeHandlerData _node;
private Node10HandlerData _node10;
private Node16HandlerData _node16;
private PowerShellHandlerData _powerShell;
private PowerShell3HandlerData _powerShell3;
private PowerShellExeHandlerData _powerShellExe;
Expand Down Expand Up @@ -435,6 +436,20 @@ public Node10HandlerData Node10
}
}

public Node16HandlerData Node16
{
get
{
return _node16;
}

set
{
_node16 = value;
Add(value);
}
}

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public PowerShellHandlerData PowerShell
{
Expand Down Expand Up @@ -609,17 +624,21 @@ public string WorkingDirectory

public sealed class NodeHandlerData : BaseNodeHandlerData
{
public override int Priority => 2;
public override int Priority => 3;
}

public sealed class Node10HandlerData : BaseNodeHandlerData
{
public override int Priority => 2;
}
public sealed class Node16HandlerData : BaseNodeHandlerData
{
public override int Priority => 1;
}

public sealed class PowerShell3HandlerData : HandlerData
{
public override int Priority => 3;
public override int Priority => 4;
}

public sealed class PowerShellHandlerData : HandlerData
Expand All @@ -637,7 +656,7 @@ public string ArgumentFormat
}
}

public override int Priority => 4;
public override int Priority => 5;

public string WorkingDirectory
{
Expand Down Expand Up @@ -668,7 +687,7 @@ public string ArgumentFormat
}
}

public override int Priority => 5;
public override int Priority => 6;

public string WorkingDirectory
{
Expand Down Expand Up @@ -725,7 +744,7 @@ public string InlineScript
}
}

public override int Priority => 5;
public override int Priority => 6;

public string ScriptType
{
Expand Down Expand Up @@ -782,7 +801,7 @@ public string ModifyEnvironment
}
}

public override int Priority => 6;
public override int Priority => 7;

public string WorkingDirectory
{
Expand Down
9 changes: 9 additions & 0 deletions src/Misc/externals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONTAINER_URL=https://vstsagenttools.blob.core.windows.net/tools
NODE_URL=https://nodejs.org/dist
NODE_VERSION="6.17.1"
NODE10_VERSION="10.24.1"
NODE16_VERSION="16.15.1"
MINGIT_VERSION="2.36.1"
LFS_VERSION="2.13.3"

Expand Down Expand Up @@ -157,6 +158,8 @@ if [[ "$PACKAGERUNTIME" == "win-x64" ]]; then
fi
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/win-x64/node.exe" node10/bin
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/win-x64/node.lib" node10/bin
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/win-x64/node.exe" node16/bin
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/win-x64/node.lib" node16/bin
acquireExternalTool "https://dist.nuget.org/win-x86-commandline/v3.4.4/nuget.exe" nuget
fi

Expand All @@ -173,6 +176,8 @@ if [[ "$PACKAGERUNTIME" == "win-x86" ]]; then
fi
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/win-x86/node.exe" node10/bin
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/win-x86/node.lib" node10/bin
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/win-x86/node.exe" node16/bin
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/win-x86/node.lib" node16/bin
acquireExternalTool "https://dist.nuget.org/win-x86-commandline/v3.4.4/nuget.exe" nuget
fi

Expand All @@ -182,6 +187,7 @@ if [[ "$PACKAGERUNTIME" == "osx-x64" ]]; then
acquireExternalTool "$NODE_URL/v${NODE_VERSION}/node-v${NODE_VERSION}-darwin-x64.tar.gz" node fix_nested_dir
fi
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/node-v${NODE10_VERSION}-darwin-x64.tar.gz" node10 fix_nested_dir
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/node-v${NODE16_VERSION}-darwin-x64.tar.gz" node16 fix_nested_dir
fi

# Download the external tools common across OSX and Linux PACKAGERUNTIMEs.
Expand All @@ -195,20 +201,23 @@ if [[ "$PACKAGERUNTIME" == "linux-x64" || "$PACKAGERUNTIME" == "rhel.6-x64" ]];
acquireExternalTool "$NODE_URL/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz" node fix_nested_dir
fi
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/node-v${NODE10_VERSION}-linux-x64.tar.gz" node10 fix_nested_dir
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/node-v${NODE16_VERSION}-linux-x64.tar.gz" node16 fix_nested_dir
fi

if [[ "$PACKAGERUNTIME" == "linux-arm" ]]; then
if [[ "$INCLUDE_NODE6" == "true" ]]; then
acquireExternalTool "$NODE_URL/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-armv7l.tar.gz" node fix_nested_dir
fi
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/node-v${NODE10_VERSION}-linux-armv7l.tar.gz" node10 fix_nested_dir
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/node-v${NODE16_VERSION}-linux-armv7l.tar.gz" node16 fix_nested_dir
fi

if [[ "$PACKAGERUNTIME" == "linux-arm64" ]]; then
if [[ "$INCLUDE_NODE6" == "true" ]]; then
acquireExternalTool "$NODE_URL/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-arm64.tar.gz" node fix_nested_dir
fi
acquireExternalTool "$NODE_URL/v${NODE10_VERSION}/node-v${NODE10_VERSION}-linux-arm64.tar.gz" node10 fix_nested_dir
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/node-v${NODE16_VERSION}-linux-arm64.tar.gz" node16 fix_nested_dir
fi

if [[ "$PACKAGERUNTIME" != "win-x64" && "$PACKAGERUNTIME" != "win-x86" ]]; then
Expand Down
10 changes: 6 additions & 4 deletions src/Test/L0/NodeHandlerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public void UseNodeForNodeHandlerEnvVarNotSet()
}
}

[Fact]
[Theory]
[InlineData("node10")]
[InlineData("node16")]
[Trait("Level", "L0")]
[Trait("Category", "Common")]
public void UseNewNodeForNewNodeHandler()
public void UseNewNodeForNewNodeHandler(string nodeVersion)
{
using (TestHostContext thc = CreateTestHostContext())
{
Expand All @@ -56,11 +58,11 @@ public void UseNewNodeForNewNodeHandler()

nodeHandler.Initialize(thc);
nodeHandler.ExecutionContext = CreateTestExecutionContext(thc);
nodeHandler.Data = new Node10HandlerData();
nodeHandler.Data = nodeVersion == "node16" ? (BaseNodeHandlerData)new Node16HandlerData() : (BaseNodeHandlerData)new Node10HandlerData();

string actualLocation = nodeHandler.GetNodeLocation();
string expectedLocation = Path.Combine(thc.GetDirectory(WellKnownDirectory.Externals),
"node10",
nodeVersion,
"bin",
$"node{IOUtil.ExeExtension}");
Assert.Equal(expectedLocation, actualLocation);
Expand Down
15 changes: 12 additions & 3 deletions src/Test/L0/Worker/TaskManagerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ public void LoadsDefinition()
""target"": ""Some Node10 target"",
""extraNodeArg"": ""Extra node10 arg value""
},
""Node16"": {
""target"": ""Some Node16 target"",
""extraNodeArg"": ""Extra node16 arg value""
},
""Process"": {
""target"": ""Some process target"",
""argumentFormat"": ""Some process argument format"",
Expand Down Expand Up @@ -505,12 +509,12 @@ public void LoadsDefinition()
if (TestUtil.IsWindows())
{
// Process handler should only be deserialized on Windows.
Assert.Equal(3, definition.Data.Execution.All.Count);
Assert.Equal(4, definition.Data.Execution.All.Count);
}
else
{
// Only the Node handlers should be deserialized on non-Windows.
Assert.Equal(2, definition.Data.Execution.All.Count);
Assert.Equal(3, definition.Data.Execution.All.Count);
}

// Node handler should always be deserialized.
Expand All @@ -523,11 +527,16 @@ public void LoadsDefinition()
Assert.Equal(definition.Data.Execution.Node10, definition.Data.Execution.All[1]);
Assert.Equal("Some Node10 target", definition.Data.Execution.Node10.Target);

// Node16 handler should always be deserialized.
Assert.NotNull(definition.Data.Execution.Node16); // execution.Node16
Assert.Equal(definition.Data.Execution.Node16, definition.Data.Execution.All[2]);
Assert.Equal("Some Node16 target", definition.Data.Execution.Node16.Target);

if (TestUtil.IsWindows())
{
// Process handler should only be deserialized on Windows.
Assert.NotNull(definition.Data.Execution.Process); // execution.Process
Assert.Equal(definition.Data.Execution.Process, definition.Data.Execution.All[2]);
Assert.Equal(definition.Data.Execution.Process, definition.Data.Execution.All[3]);
Assert.Equal("Some process argument format", definition.Data.Execution.Process.ArgumentFormat);
Assert.NotNull(definition.Data.Execution.Process.Platforms);
Assert.Equal(1, definition.Data.Execution.Process.Platforms.Length);
Expand Down