Skip to content

Commit 124a0b6

Browse files
authored
[Helix] Reenable some template tests again (#19520)
1 parent ddedfc6 commit 124a0b6

File tree

9 files changed

+73
-29
lines changed

9 files changed

+73
-29
lines changed

eng/helix/content/runtests.cmd

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
2-
REM Disable "!Foo!" expansions because they break the filter syntax
3-
setlocal disableextensions
2+
REM Need delayed expansion !PATH! so parens in the path don't mess up the parens for the if statements that use parens for blocks
3+
setlocal enabledelayedexpansion
44

55
REM Use '$' as a variable name prefix to avoid MSBuild variable collisions with these variables
66
set $target=%1
@@ -9,28 +9,41 @@ set $runtimeVersion=%3
99
set $helixQueue=%4
1010
set $arch=%5
1111
set $quarantined=%6
12+
set $efVersion=%7
1213

1314
set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk
1415
set DOTNET_ROOT=%DOTNET_HOME%\%$arch%
1516
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
1617
set DOTNET_MULTILEVEL_LOOKUP=0
1718
set DOTNET_CLI_HOME=%HELIX_CORRELATION_PAYLOAD%\home
1819

19-
set PATH=%DOTNET_ROOT%;%PATH%;%HELIX_CORRELATION_PAYLOAD%\node\bin
20-
20+
set PATH=%DOTNET_ROOT%;!PATH!;%HELIX_CORRELATION_PAYLOAD%\node\bin
21+
echo Set path to: %PATH%
22+
echo "Installing SDK"
2123
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture %$arch% -Version %$sdkVersion% -InstallDir %DOTNET_ROOT%"
24+
echo "Installing Runtime"
2225
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture %$arch% -Runtime dotnet -Version %$runtimeVersion% -InstallDir %DOTNET_ROOT%"
23-
26+
echo "Checking for Microsoft.AspNetCore.App"
2427
if EXIST ".\Microsoft.AspNetCore.App" (
2528
echo "Found Microsoft.AspNetCore.App, copying to %DOTNET_ROOT%\shared\Microsoft.AspNetCore.App\%runtimeVersion%"
2629
xcopy /i /y ".\Microsoft.AspNetCore.App" %DOTNET_ROOT%\shared\Microsoft.AspNetCore.App\%runtimeVersion%\
30+
31+
echo "Adding current directory to nuget sources: %HELIX_WORKITEM_ROOT%"
32+
dotnet nuget add source %HELIX_WORKITEM_ROOT%
33+
dotnet nuget add source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json
34+
dotnet nuget list source
35+
dotnet tool install dotnet-ef --global --version %$efVersion%
36+
37+
set PATH=!PATH!;%DOTNET_CLI_HOME%\.dotnet\tools
2738
)
2839

2940
echo "Current Directory: %HELIX_WORKITEM_ROOT%"
3041
set HELIX=%$helixQueue%
3142
set HELIX_DIR=%HELIX_WORKITEM_ROOT%
3243
set NUGET_FALLBACK_PACKAGES=%HELIX_DIR%
3344
set NUGET_RESTORE=%HELIX_DIR%\nugetRestore
45+
set DotNetEfFullPath=%HELIX_DIR%\nugetRestore\dotnet-ef\%$efVersion%\tools\netcoreapp3.1\any\dotnet-ef.exe
46+
echo "Set DotNetEfFullPath: %DotNetEfFullPath%"
3447
echo "Setting HELIX_DIR: %HELIX_DIR%"
3548
echo Creating nuget restore directory: %NUGET_RESTORE%
3649
mkdir %NUGET_RESTORE%
@@ -53,6 +66,8 @@ if %$quarantined%==True (
5366
set %$quarantined=true
5467
)
5568

69+
REM Disable "!Foo!" expansions because they break the filter syntax
70+
setlocal disabledelayedexpansion
5671
set NONQUARANTINE_FILTER="Quarantined!=true"
5772
set QUARANTINE_FILTER="Quarantined=true"
5873
if %$quarantined%==true (

eng/helix/content/runtests.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dotnet_runtime_version="$3"
66
helix_queue_name="$4"
77
target_arch="$5"
88
quarantined="$6"
9+
efVersion="$7"
910

1011
RESET="\033[0m"
1112
RED="\033[0;31m"
@@ -33,6 +34,8 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
3334
export helix="$helix_queue_name"
3435
export HELIX_DIR="$DIR"
3536
export NUGET_FALLBACK_PACKAGES="$DIR"
37+
export DotNetEfFullPath=$DIR\nugetRestore\dotnet-ef\$efVersion\tools\netcoreapp3.1\any\dotnet-ef.dll
38+
echo "Set DotNetEfFullPath: $DotNetEfFullPath"
3639
export NUGET_RESTORE="$DIR/nugetRestore"
3740
echo "Creating nugetRestore directory: $NUGET_RESTORE"
3841
mkdir $NUGET_RESTORE
@@ -95,6 +98,17 @@ if [ -d "Microsoft.AspNetCore.App" ]
9598
then
9699
echo "Found Microsoft.AspNetCore.App directory, copying to $DOTNET_ROOT/shared/Microsoft.AspNetCore.App/$dotnet_runtime_version."
97100
cp -r Microsoft.AspNetCore.App $DOTNET_ROOT/shared/Microsoft.AspNetCore.App/$dotnet_runtime_version
101+
102+
echo "Adding current directory to nuget sources: $DIR"
103+
dotnet nuget add source $DIR
104+
dotnet nuget add source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json
105+
dotnet nuget list source
106+
107+
dotnet tool install dotnet-ef --global --version $efVersion
108+
109+
# Ensure tools are on on PATH
110+
export PATH="$PATH:$DOTNET_CLI_HOME/.dotnet/tools"
111+
98112
fi
99113

100114
if [ -e /proc/self/coredump_filter ]; then

eng/targets/Helix.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
120120
<TestAssembly>$(TargetFileName)</TestAssembly>
121121
<PreCommands>@(HelixPreCommand)</PreCommands>
122122
<PostCommands>@(HelixPostCommand)</PostCommands>
123-
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
124-
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests)</Command>
123+
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion)</Command>
124+
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion)</Command>
125125
<Command Condition="$(HelixCommand) != ''">$(HelixCommand)</Command>
126126
<Timeout>$(HelixTimeout)</Timeout>
127127
</HelixWorkItem>

src/ProjectTemplates/test/Helpers/Project.cs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.IO;
88
using System.Linq;
99
using System.Reflection;
10+
using System.Runtime.InteropServices;
1011
using System.Threading;
1112
using System.Threading.Tasks;
1213
using Microsoft.Extensions.CommandLineUtils;
@@ -28,12 +29,11 @@ public class Project
2829
? GetAssemblyMetadata("ArtifactsLogDir")
2930
: Path.Combine(Environment.GetEnvironmentVariable("HELIX_DIR"), "logs");
3031

31-
// FIGURE OUT EF PATH
32-
public static string DotNetEfFullPath => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
32+
public static string DotNetEfFullPath => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DotNetEfFullPath")))
3333
? typeof(ProjectFactoryFixture).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
3434
.First(attribute => attribute.Key == "DotNetEfFullPath")
3535
.Value
36-
: Path.Combine("NuGetPackageRoot", "dotnet-ef/$(DotnetEfPackageVersion)/tools/netcoreapp3.1/any/dotnet-ef.dll");
36+
: Environment.GetEnvironmentVariable("DotNetEfFullPath");
3737

3838
public SemaphoreSlim DotNetNewLock { get; set; }
3939
public SemaphoreSlim NodeLock { get; set; }
@@ -306,14 +306,24 @@ private async Task<ProcessEx> RestoreAsync(ITestOutputHelper output, string work
306306

307307
internal async Task<ProcessEx> RunDotNetEfCreateMigrationAsync(string migrationName)
308308
{
309-
var args = $"\"{DotNetEfFullPath}\" --verbose --no-build migrations add {migrationName}";
310-
309+
var args = $"--verbose --no-build migrations add {migrationName}";
310+
311311
// Only run one instance of 'dotnet new' at once, as a workaround for
312312
// https://github.com/aspnet/templating/issues/63
313313
await DotNetNewLock.WaitAsync();
314314
try
315315
{
316-
var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), args);
316+
var command = DotNetMuxer.MuxerPathOrDefault();
317+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DotNetEfFullPath")))
318+
{
319+
args = $"\"{DotNetEfFullPath}\" " + args;
320+
}
321+
else
322+
{
323+
command = "dotnet-ef";
324+
}
325+
326+
var result = ProcessEx.Run(Output, TemplateOutputDir, command, args);
317327
await result.Exited;
318328
return result;
319329
}
@@ -325,14 +335,24 @@ internal async Task<ProcessEx> RunDotNetEfCreateMigrationAsync(string migrationN
325335

326336
internal async Task<ProcessEx> RunDotNetEfUpdateDatabaseAsync()
327337
{
328-
var args = $"\"{DotNetEfFullPath}\" --verbose --no-build database update";
338+
var args = "--verbose --no-build database update";
329339

330340
// Only run one instance of 'dotnet new' at once, as a workaround for
331341
// https://github.com/aspnet/templating/issues/63
332342
await DotNetNewLock.WaitAsync();
333343
try
334344
{
335-
var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), args);
345+
var command = DotNetMuxer.MuxerPathOrDefault();
346+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DotNetEfFullPath")))
347+
{
348+
args = $"\"{DotNetEfFullPath}\" " + args;
349+
}
350+
else
351+
{
352+
command = "dotnet-ef";
353+
}
354+
355+
var result = ProcessEx.Run(Output, TemplateOutputDir, command, args);
336356
await result.Exited;
337357
return result;
338358
}

src/ProjectTemplates/test/IdentityUIPackageTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static TheoryData<IDictionary<string, string>, string, string[]> MSBuildI
120120

121121
[ConditionalTheory]
122122
[MemberData(nameof(MSBuildIdentityUIPackageOptions))]
123-
[SkipOnHelix("ef restore no worky")]
123+
[SkipOnHelix("cert failure", Queues = "OSX.1014.Amd64;OSX.1014.Amd64.Open")]
124124
public async Task IdentityUIPackage_WorksWithDifferentOptions(IDictionary<string, string> packageOptions, string versionValidator, string[] expectedFiles)
125125
{
126126
Project = await ProjectFactory.GetOrCreateProject("identityuipackage" + string.Concat(packageOptions.Values), Output);

src/ProjectTemplates/test/MvcTemplateTest.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
using System.Collections.Generic;
55
using System.IO;
6+
using System.Linq;
67
using System.Threading.Tasks;
8+
using Microsoft.AspNetCore.Testing;
79
using Templates.Test.Helpers;
8-
using System.Linq;
910
using Xunit;
1011
using Xunit.Abstractions;
11-
using Microsoft.AspNetCore.Testing;
1212

1313
namespace Templates.Test
1414
{
@@ -107,7 +107,7 @@ private async Task MvcTemplateCore(string languageOverride)
107107
[ConditionalTheory]
108108
[InlineData(true)]
109109
[InlineData(false)]
110-
[SkipOnHelix("ef restore no worky")]
110+
[SkipOnHelix("cert failure", Queues = "OSX.1014.Amd64;OSX.1014.Amd64.Open")]
111111
public async Task MvcTemplate_IndividualAuth(bool useLocalDB)
112112
{
113113
Project = await ProjectFactory.GetOrCreateProject("mvcindividual" + (useLocalDB ? "uld" : ""), Output);
@@ -222,8 +222,7 @@ public async Task MvcTemplate_IndividualAuth(bool useLocalDB)
222222
}
223223
}
224224

225-
[ConditionalFact]
226-
[SkipOnHelix("razor compilation restore no worky")]
225+
[Fact]
227226
public async Task MvcTemplate_RazorRuntimeCompilation_BuildsAndPublishes()
228227
{
229228
Project = await ProjectFactory.GetOrCreateProject("mvc_rc", Output);

src/ProjectTemplates/test/RazorClassLibraryTemplateTest.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Templates.Test.Helpers;
66
using Xunit;
77
using Xunit.Abstractions;
8-
using Microsoft.AspNetCore.Testing;
98

109
namespace Templates.Test
1110
{
@@ -41,8 +40,7 @@ public async Task RazorClassLibraryTemplate_WithViews_Async()
4140
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", Project, buildResult));
4241
}
4342

44-
[ConditionalFact]
45-
[SkipOnHelix("restore no worky")]
43+
[Fact]
4644
public async Task RazorClassLibraryTemplateAsync()
4745
{
4846
Project = await ProjectFactory.GetOrCreateProject("razorclasslib", Output);

src/ProjectTemplates/test/RazorPagesTemplateTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public async Task RazorPagesTemplate_NoAuth()
9797
[ConditionalTheory]
9898
[InlineData(false)]
9999
[InlineData(true)]
100-
[SkipOnHelix("ef restore no worky")]
100+
[SkipOnHelix("cert failure", Queues = "OSX.1014.Amd64;OSX.1014.Amd64.Open")]
101101
public async Task RazorPagesTemplate_IndividualAuth(bool useLocalDB)
102102
{
103103
Project = await ProjectFactory.GetOrCreateProject("razorpagesindividual" + (useLocalDB ? "uld" : ""), Output);
@@ -212,8 +212,7 @@ public async Task RazorPagesTemplate_IndividualAuth(bool useLocalDB)
212212
}
213213
}
214214

215-
[ConditionalFact]
216-
[SkipOnHelix("runtime compliation restore no worky")]
215+
[Fact]
217216
public async Task RazorPagesTemplate_RazorRuntimeCompilation_BuildsAndPublishes()
218217
{
219218
Project = await ProjectFactory.GetOrCreateProject("razorpages_rc", Output);

src/ProjectTemplates/test/WorkerTemplateTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public WorkerTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHelpe
2121
public ProjectFactoryFixture ProjectFactory { get; }
2222
public ITestOutputHelper Output { get; }
2323

24-
[ConditionalFact]
25-
[SkipOnHelix("restore no worky")]
24+
[Fact]
2625
public async Task WorkerTemplateAsync()
2726
{
2827
Project = await ProjectFactory.GetOrCreateProject("worker", Output);

0 commit comments

Comments
 (0)