Skip to content

Commit b2cf502

Browse files
authored
Run E2E tests in parallel and on macOS (#1369)
1 parent 3cbf1ea commit b2cf502

File tree

2 files changed

+123
-23
lines changed

2 files changed

+123
-23
lines changed

.vsts/builds/e2e-tests.yml

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,64 @@
11
trigger: none
2-
queue:
3-
name: DotNetCore-Windows
4-
timeoutInMinutes: 120
5-
steps:
6-
- task: NodeTool@0
7-
displayName: Install Node 10.x
8-
inputs:
9-
versionSpec: 10.x
10-
- powershell: |
11-
test/Cli.FunctionalTests/run-tests.ps1 -ci -ProdConManifestUrl $env:ProdConManifestUrl
12-
condition: ne(variables['PB_SkipTests'], 'true')
13-
displayName: Run E2E tests
14-
- task: PublishTestResults@2
15-
displayName: Publish test results
16-
condition: always()
17-
inputs:
18-
testRunner: vstest
19-
testResultsFiles: 'artifacts/logs/**/*.trx'
2+
phases:
3+
- phase: Host_Windows
4+
queue:
5+
name: DotNetCore-Windows
6+
parallel: 4
7+
matrix:
8+
Portable:
9+
Test.RuntimeIdentifier: none
10+
SelfContainedWindows:
11+
Test.RuntimeIdentifier: win-x64
12+
SelfContainedLinux:
13+
Test.RuntimeIdentifier: linux-x64
14+
SelfContainedMacOs:
15+
Test.RuntimeIdentifier: osx-x64
16+
steps:
17+
- task: NodeTool@0
18+
displayName: Install Node 10.x
19+
inputs:
20+
versionSpec: 10.x
21+
- powershell: |
22+
test/Cli.FunctionalTests/run-tests.ps1 `
23+
-ci `
24+
-ProdConManifestUrl $env:ProdConManifestUrl `
25+
-TestRuntimeIdentifier $(Test.RuntimeIdentifier)
26+
condition: ne(variables['PB_SkipTests'], 'true')
27+
displayName: Run E2E tests
28+
- task: PublishTestResults@2
29+
displayName: Publish test results
30+
condition: always()
31+
inputs:
32+
testRunner: vstest
33+
testResultsFiles: 'artifacts/logs/**/*.trx'
34+
- phase: Host_macOS
35+
queue:
36+
name: Hosted macOS Preview
37+
parallel: 4
38+
matrix:
39+
Portable:
40+
Test.RuntimeIdentifier: none
41+
SelfContainedWindows:
42+
Test.RuntimeIdentifier: win-x64
43+
SelfContainedLinux:
44+
Test.RuntimeIdentifier: linux-x64
45+
SelfContainedMacOs:
46+
Test.RuntimeIdentifier: osx-x64
47+
steps:
48+
- task: NodeTool@0
49+
displayName: Install Node 10.x
50+
inputs:
51+
versionSpec: 10.x
52+
- powershell: |
53+
test/Cli.FunctionalTests/run-tests.ps1 \
54+
-ci \
55+
-ProdConManifestUrl $env:ProdConManifestUrl \
56+
-TestRuntimeIdentifier $(Test.RuntimeIdentifier)
57+
condition: ne(variables['PB_SkipTests'], 'true')
58+
displayName: Run E2E tests
59+
- task: PublishTestResults@2
60+
displayName: Publish test results
61+
condition: always()
62+
inputs:
63+
testRunner: vstest
64+
testResultsFiles: 'artifacts/logs/**/*.trx'

test/Cli.FunctionalTests/run-tests.ps1

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ The blob feed for the .NET Core CLI. If not specified, it will determined automa
1414
.PARAMETER RestoreSources
1515
A list of additional NuGet feeds. If not specified, it will determined automatically if possible.
1616
17+
.PARAMETER TestRuntimeIdentifier
18+
Filter the tests by which RID they publish for. If empty (default), tests are run for
19+
* none (portable)
20+
* osx-x64
21+
* linux-x64
22+
* win-x64
23+
24+
.PARAMETER HostRid
25+
The RID of the platform running the tests. (Determined automatically if possible)
26+
1727
.PARAMETER ProdConManifestUrl
1828
The prodcon build.xml file
1929
@@ -26,6 +36,9 @@ param(
2636
$AssetRootUrl = $env:PB_AccessRootUrl,
2737
$AccessTokenSuffix = $env:PB_AccessTokenSuffix,
2838
$RestoreSources = $env:PB_RestoreSources,
39+
[ValidateSet('none', 'osx-x64', 'linux-x64', 'win-x64')]
40+
$TestRuntimeIdentifier,
41+
$HostRid,
2942
$ProdConManifestUrl,
3043
$ProcConChannel = 'release/2.2'
3144
)
@@ -36,12 +49,40 @@ Set-StrictMode -Version 1
3649
$repoRoot = Resolve-Path "$PSScriptRoot/../../"
3750
Import-Module "$repoRoot/scripts/common.psm1" -Scope Local -Force
3851

52+
if (-not $HostRid) {
53+
if (Test-Path Variable:/IsCoreCLR) {
54+
$HostRid = if ($IsWindows) { 'win-x64' } `
55+
elseif ($IsLinux) { 'linux-x64' } `
56+
elseif ($IsMacOS) { 'osx-x64' }
57+
}
58+
else {
59+
$HostRid = 'win-x64'
60+
}
61+
}
62+
63+
if (-not $HostRid) {
64+
throw 'Could not determine which platform this script is running on. Add -HostRid $rid where $rid = the .NET Core SDK to install'
65+
}
66+
67+
switch ($HostRid) {
68+
'win-x64' {
69+
$dotnetFileName = 'dotnet.exe'
70+
$archiveExt = '.zip'
71+
}
72+
default {
73+
$dotnetFileName = 'dotnet'
74+
$archiveExt = '.tar.gz'
75+
}
76+
}
77+
3978
Push-Location $PSScriptRoot
4079
try {
4180
New-Item -Type Directory "$PSScriptRoot/obj/" -ErrorAction Ignore | Out-Null
4281
$sdkVersion = ''
4382

4483
if (-not $ci -or $ProdConManifestUrl) {
84+
# Workaround for pwsh 6 dumping progress info
85+
$ProgressPreference = 'SilentlyContinue'
4586

4687
if (-not $ProdConManifestUrl) {
4788
Write-Host -ForegroundColor Magenta "Running tests for the latest ProdCon build"
@@ -76,14 +117,21 @@ try {
76117
@{ sdk = @{ version = $sdkVersion } } | ConvertTo-Json | Set-Content "$PSScriptRoot/global.json"
77118

78119
$dotnetRoot = "$repoRoot/.dotnet"
79-
$dotnet = "$dotnetRoot/dotnet.exe"
120+
$dotnet = "$dotnetRoot/$dotnetFileName"
80121

81122
if (-not (Test-Path "$dotnetRoot/sdk/$sdkVersion/dotnet.dll")) {
82123
Remove-Item -Recurse -Force $dotnetRoot -ErrorAction Ignore | Out-Null
83-
$cliUrl = "$AssetRootUrl/Sdk/$sdkVersion/dotnet-sdk-$sdkVersion-win-x64.zip"
124+
$cliUrl = "$AssetRootUrl/Sdk/$sdkVersion/dotnet-sdk-$sdkVersion-$HostRid$archiveExt"
125+
$cliArchiveFile = "$PSScriptRoot/obj/dotnet$archiveExt"
84126
Write-Host "Downloading $cliUrl"
85-
Invoke-WebRequest -UseBasicParsing "${cliUrl}${AccessTokenSuffix}" -OutFile "$PSScriptRoot/obj/dotnet.zip"
86-
Expand-Archive "$PSScriptRoot/obj/dotnet.zip" -DestinationPath $dotnetRoot
127+
Invoke-WebRequest -UseBasicParsing "${cliUrl}${AccessTokenSuffix}" -OutFile $cliArchiveFile
128+
if ($archiveExt -eq '.zip') {
129+
Expand-Archive $cliArchiveFile -DestinationPath $dotnetRoot
130+
}
131+
else {
132+
New-Item -Type Directory $dotnetRoot -ErrorAction Ignore | Out-Null
133+
Invoke-Block { & tar xzf $cliArchiveFile -C $dotnetRoot }
134+
}
87135
}
88136

89137
# Set a clean test environment
@@ -96,11 +144,18 @@ try {
96144
# Required by the tests. It is assumed packages on this feed will end up on nuget.org
97145
$env:NUGET_PACKAGE_SOURCE = $RestoreSources
98146

147+
[string[]] $filterArgs = @()
148+
149+
if ($TestRuntimeIdentifier) {
150+
$filterArgs += '--filter',"rid: $TestRuntimeIdentifier"
151+
}
152+
99153
Invoke-Block { & $dotnet test `
100154
--logger "console;verbosity=detailed" `
101155
--logger "trx;LogFileName=$repoRoot/artifacts/logs/e2etests.trx" `
102156
"-p:DotNetRestoreSources=$RestoreSources" `
103-
"-bl:$repoRoot/artifacts/logs/e2etests.binlog" }
157+
"-bl:$repoRoot/artifacts/logs/e2etests.binlog" `
158+
@filterArgs }
104159
}
105160
finally {
106161
Pop-Location

0 commit comments

Comments
 (0)