diff --git a/.vsts/builds/e2e-tests.yml b/.vsts/builds/e2e-tests.yml index 014f5481ba..3db5a15233 100644 --- a/.vsts/builds/e2e-tests.yml +++ b/.vsts/builds/e2e-tests.yml @@ -1,19 +1,61 @@ trigger: none -queue: - name: DotNetCore-Windows - timeoutInMinutes: 120 -steps: -- task: NodeTool@0 - displayName: Install Node 10.x - inputs: - versionSpec: 10.x -- powershell: | - test/Cli.FunctionalTests/run-tests.ps1 -ci -ProdConManifestUrl $env:ProdConManifestUrl - condition: ne(variables['PB_SkipTests'], 'true') - displayName: Run E2E tests -- task: PublishTestResults@2 - displayName: Publish test results - condition: always() - inputs: - testRunner: vstest - testResultsFiles: 'artifacts/logs/**/*.trx' +phases: +- phase: Host_Windows + queue: + name: DotNetCore-Windows + parallel: 4 + matrix: + Portable: + Test.RuntimeIdentifier: none + SelfContainedWindows: + Test.RuntimeIdentifier: win-x64 + SelfContainedLinux: + Test.RuntimeIdentifier: linux-x64 + SelfContainedMacOs: + Test.RuntimeIdentifier: osx-x64 + steps: + - task: NodeTool@0 + displayName: Install Node 10.x + inputs: + versionSpec: 10.x + - powershell: | + test/Cli.FunctionalTests/run-tests.ps1 ` + -ci ` + -ProdConManifestUrl $env:PRODCONMANIFESTURL ` + -TestRuntimeIdentifier $(Test.RuntimeIdentifier) + condition: ne(variables['PB_SkipTests'], 'true') + displayName: Run E2E tests + - task: PublishTestResults@2 + displayName: Publish test results + condition: always() + inputs: + testRunner: vstest + testResultsFiles: 'artifacts/logs/**/*.trx' +- phase: Host_macOS + queue: + name: Hosted macOS Preview + parallel: 4 + matrix: + Portable: + Test.RuntimeIdentifier: none + SelfContainedWindows: + Test.RuntimeIdentifier: win-x64 + SelfContainedLinux: + Test.RuntimeIdentifier: linux-x64 + SelfContainedMacOs: + Test.RuntimeIdentifier: osx-x64 + steps: + - task: NodeTool@0 + displayName: Install Node 10.x + inputs: + versionSpec: 10.x + - powershell: | + test/Cli.FunctionalTests/run-tests.ps1 -ci -ProdConManifestUrl $env:PRODCONMANIFESTURL -TestRuntimeIdentifier $(Test.RuntimeIdentifier) + condition: ne(variables['PB_SkipTests'], 'true') + displayName: Run E2E tests + - task: PublishTestResults@2 + displayName: Publish test results + condition: always() + inputs: + testRunner: vstest + testResultsFiles: 'artifacts/logs/**/*.trx' diff --git a/scripts/common.psm1 b/scripts/common.psm1 index 97b5216f85..c7a59ee7df 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -1,4 +1,6 @@ $ErrorActionPreference = 'Stop' +# Update the default TLS support to 1.2 +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 function Assert-Git { if (!(Get-Command git -ErrorAction Ignore)) { diff --git a/test/Cli.FunctionalTests/Cli.FunctionalTests.sln b/test/Cli.FunctionalTests/Cli.FunctionalTests.sln index 6aff0f5478..42f7f90f69 100644 --- a/test/Cli.FunctionalTests/Cli.FunctionalTests.sln +++ b/test/Cli.FunctionalTests/Cli.FunctionalTests.sln @@ -5,6 +5,11 @@ VisualStudioVersion = 15.0.28016.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cli.FunctionalTests", "Cli.FunctionalTests.csproj", "{D44EA496-EF83-4D47-8C45-4DAF5A1B0070}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0EC88B4E-B1F2-4183-9EBF-BF66C45D19D7}" + ProjectSection(SolutionItems) = preProject + ..\..\.vsts\builds\e2e-tests.yml = ..\..\.vsts\builds\e2e-tests.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/test/Cli.FunctionalTests/Templates/RazorApplicationBaseTemplate.cs b/test/Cli.FunctionalTests/Templates/RazorApplicationBaseTemplate.cs index f1dceecde4..a7ac0d7001 100644 --- a/test/Cli.FunctionalTests/Templates/RazorApplicationBaseTemplate.cs +++ b/test/Cli.FunctionalTests/Templates/RazorApplicationBaseTemplate.cs @@ -51,11 +51,6 @@ namespace Cli.FunctionalTests.Templates public override IEnumerable ExpectedFilesAfterPublish => base.ExpectedFilesAfterPublish - .Concat(RazorUtil.GetExpectedFilesAfterPublish(this)) - .Concat(new[] - { - "appsettings.Development.json", - "appsettings.json", - }); + .Concat(RazorUtil.GetExpectedFilesAfterPublish(this)); } } diff --git a/test/Cli.FunctionalTests/Templates/WebApiTemplate.cs b/test/Cli.FunctionalTests/Templates/WebApiTemplate.cs index 4bb6fa3c48..5609063371 100644 --- a/test/Cli.FunctionalTests/Templates/WebApiTemplate.cs +++ b/test/Cli.FunctionalTests/Templates/WebApiTemplate.cs @@ -1,8 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Collections.Generic; -using System.Linq; namespace Cli.FunctionalTests.Templates { @@ -13,13 +11,5 @@ namespace Cli.FunctionalTests.Templates public override string Name => "webapi"; public override string RelativeUrl => "/api/values"; - - public override IEnumerable ExpectedFilesAfterPublish => - base.ExpectedFilesAfterPublish - .Concat(new[] - { - "appsettings.Development.json", - "appsettings.json", - }); } } diff --git a/test/Cli.FunctionalTests/Templates/WebTemplate.cs b/test/Cli.FunctionalTests/Templates/WebTemplate.cs index a2e77925f6..3571ca6cfc 100644 --- a/test/Cli.FunctionalTests/Templates/WebTemplate.cs +++ b/test/Cli.FunctionalTests/Templates/WebTemplate.cs @@ -220,15 +220,29 @@ namespace Cli.FunctionalTests.Templates }, { ("netcoreapp2.2", RuntimeIdentifier.None), () => _additionalFilesAfterPublish[("netcoreapp2.1", RuntimeIdentifier.None)]() + .Concat(new[] + { + "appsettings.Development.json", + "appsettings.json", + }) }, { ("netcoreapp2.2", RuntimeIdentifier.Linux_x64), () => _additionalFilesAfterPublish[("netcoreapp2.1", RuntimeIdentifier.Linux_x64)]() + .Except(new[] + { + "Microsoft.AspNetCore.Identity.UI.Views.dll", + }) .Concat(new[] { + "appsettings.Development.json", + "appsettings.json", "Microsoft.AspNetCore.Diagnostics.HealthChecks.dll", + "Microsoft.AspNetCore.Identity.UI.Views.V3.dll", + "Microsoft.AspNetCore.Identity.UI.Views.V4.dll", "Microsoft.AspNetCore.Server.IIS.dll", "Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.dll", "Microsoft.Extensions.Diagnostics.HealthChecks.dll", + "Microsoft.Extensions.Options.DataAnnotations.dll", }) }, { ("netcoreapp2.2", RuntimeIdentifier.OSX_x64), () => diff --git a/test/Cli.FunctionalTests/run-tests.ps1 b/test/Cli.FunctionalTests/run-tests.ps1 index 6cdff63b0f..9fd603af4b 100644 --- a/test/Cli.FunctionalTests/run-tests.ps1 +++ b/test/Cli.FunctionalTests/run-tests.ps1 @@ -14,6 +14,16 @@ The blob feed for the .NET Core CLI. If not specified, it will determined automa .PARAMETER RestoreSources A list of additional NuGet feeds. If not specified, it will determined automatically if possible. +.PARAMETER TestRuntimeIdentifier +Filter the tests by which RID they publish for. If empty (default), tests are run for +* none (portable) +* osx-x64 +* linux-x64 +* win-x64 + +.PARAMETER HostRid +The RID of the platform running the tests. (Determined automatically if possible) + .PARAMETER ProdConManifestUrl The prodcon build.xml file @@ -23,9 +33,12 @@ The prodcon channel to use if a build.xml file isn't set. param( [switch]$ci, - $AssetRootUrl = $env:PB_AccessRootUrl, - $AccessTokenSuffix = $env:PB_AccessTokenSuffix, - $RestoreSources = $env:PB_RestoreSources, + $AssetRootUrl = $env:PB_ASSETROOTURL, + $AccessTokenSuffix = $env:PB_ACCESSTOKENSUFFIX, + $RestoreSources = $env:PB_RESTORESOURCES, + [ValidateSet('none', 'osx-x64', 'linux-x64', 'win-x64')] + $TestRuntimeIdentifier, + $HostRid, $ProdConManifestUrl, $ProcConChannel = 'master' ) @@ -36,12 +49,40 @@ Set-StrictMode -Version 1 $repoRoot = Resolve-Path "$PSScriptRoot/../../" Import-Module "$repoRoot/scripts/common.psm1" -Scope Local -Force +if (-not $HostRid) { + if (Test-Path Variable:/IsCoreCLR) { + $HostRid = if ($IsWindows) { 'win-x64' } ` + elseif ($IsLinux) { 'linux-x64' } ` + elseif ($IsMacOS) { 'osx-x64' } + } + else { + $HostRid = 'win-x64' + } +} + +if (-not $HostRid) { + throw 'Could not determine which platform this script is running on. Add -HostRid $rid where $rid = the .NET Core SDK to install' +} + +switch ($HostRid) { + 'win-x64' { + $dotnetFileName = 'dotnet.exe' + $archiveExt = '.zip' + } + default { + $dotnetFileName = 'dotnet' + $archiveExt = '.tar.gz' + } +} + Push-Location $PSScriptRoot try { New-Item -Type Directory "$PSScriptRoot/obj/" -ErrorAction Ignore | Out-Null $sdkVersion = '' if (-not $ci -or $ProdConManifestUrl) { + # Workaround for pwsh 6 dumping progress info + $ProgressPreference = 'SilentlyContinue' if (-not $ProdConManifestUrl) { Write-Host -ForegroundColor Magenta "Running tests for the latest ProdCon build" @@ -76,28 +117,45 @@ try { @{ sdk = @{ version = $sdkVersion } } | ConvertTo-Json | Set-Content "$PSScriptRoot/global.json" $dotnetRoot = "$repoRoot/.dotnet" - $dotnet = "$dotnetRoot/dotnet.exe" + $dotnet = "$dotnetRoot/$dotnetFileName" if (-not (Test-Path "$dotnetRoot/sdk/$sdkVersion/dotnet.dll")) { Remove-Item -Recurse -Force $dotnetRoot -ErrorAction Ignore | Out-Null - $cliUrl = "$AssetRootUrl/Sdk/$sdkVersion/dotnet-sdk-$sdkVersion-win-x64.zip" + $cliUrl = "$AssetRootUrl/Sdk/$sdkVersion/dotnet-sdk-$sdkVersion-$HostRid$archiveExt" + $cliArchiveFile = "$PSScriptRoot/obj/dotnet$archiveExt" Write-Host "Downloading $cliUrl" - Invoke-WebRequest -UseBasicParsing "${cliUrl}${AccessTokenSuffix}" -OutFile "$PSScriptRoot/obj/dotnet.zip" - Expand-Archive "$PSScriptRoot/obj/dotnet.zip" -DestinationPath $dotnetRoot + Invoke-WebRequest -UseBasicParsing "${cliUrl}${AccessTokenSuffix}" -OutFile $cliArchiveFile + if ($archiveExt -eq '.zip') { + Expand-Archive $cliArchiveFile -DestinationPath $dotnetRoot + } + else { + New-Item -Type Directory $dotnetRoot -ErrorAction Ignore | Out-Null + Invoke-Block { & tar xzf $cliArchiveFile -C $dotnetRoot } + } } # Set a clean test environment $env:DOTNET_ROOT = $dotnetRoot $env:DOTNET_MULTILEVEL_LOOKUP = 0 $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 0 - $env:MSBuildSdksPath = '' + $env:MSBUILDSDKSPATH = '' $env:PATH = "$dotnetRoot;$env:PATH" + # Required by the tests. It is assumed packages on this feed will end up on nuget.org + $env:NUGET_PACKAGE_SOURCE = $RestoreSources + + [string[]] $filterArgs = @() + + if ($TestRuntimeIdentifier) { + $filterArgs += '--filter',"rid: $TestRuntimeIdentifier" + } + Invoke-Block { & $dotnet test ` --logger "console;verbosity=detailed" ` --logger "trx;LogFileName=$repoRoot/artifacts/logs/e2etests.trx" ` "-p:DotNetRestoreSources=$RestoreSources" ` - "-bl:$repoRoot/artifacts/logs/e2etests.binlog" } + "-bl:$repoRoot/artifacts/logs/e2etests.binlog" ` + @filterArgs } } finally { Pop-Location