Skip to content

Commit

Permalink
helix + pw + linux/osx (#30676)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoK authored Mar 17, 2021
1 parent 8b4d24e commit a104f9d
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 31 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
<NewtonsoftJsonBsonVersion>1.0.2</NewtonsoftJsonBsonVersion>
<NewtonsoftJsonVersion>12.0.2</NewtonsoftJsonVersion>
<NSwagApiDescriptionClientVersion>13.0.4</NSwagApiDescriptionClientVersion>
<PlaywrightSharpVersion>0.180.0</PlaywrightSharpVersion>
<PlaywrightSharpVersion>0.191.1</PlaywrightSharpVersion>
<PollyExtensionsHttpVersion>3.0.0</PollyExtensionsHttpVersion>
<PollyVersion>7.1.0</PollyVersion>
<SeleniumSupportVersion>4.0.0-beta1</SeleniumSupportVersion>
Expand Down
2 changes: 2 additions & 0 deletions eng/helix/content/RunTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ static async Task Main(string[] args)
{
keepGoing = await runner.InstallPlaywrightAsync();
}
#else
Console.WriteLine("Playwright install skipped.");
#endif

runner.DisplayContents();
Expand Down
2 changes: 1 addition & 1 deletion eng/helix/content/RunTests/RunTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20158.1" />
<PackageReference Condition=" '$(InstallPlaywright)' == 'true' " Include="PlaywrightSharp" Version="0.180.0" />
<PackageReference Condition=" '$(InstallPlaywright)' == 'true' " Include="PlaywrightSharp" Version="0.191.1" />
</ItemGroup>
</Project>
22 changes: 12 additions & 10 deletions eng/helix/content/RunTests/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ public bool SetupEnvironment()

#if INSTALLPLAYWRIGHT
// Playwright will download and look for browsers to this directory
var playwrightBrowsers = Path.Combine(helixDir, "ms-playwright");
var playwrightBrowsers = Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH");
Console.WriteLine($"Setting PLAYWRIGHT_BROWSERS_PATH: {playwrightBrowsers}");
EnvironmentVariables.Add("PLAYWRIGHT_BROWSERS_PATH", playwrightBrowsers);
var playrightDriver = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH");
Console.WriteLine($"Setting PLAYWRIGHT_DRIVER_PATH: {playrightDriver}");
EnvironmentVariables.Add("PLAYWRIGHT_DRIVER_PATH", playrightDriver);
#else
Console.WriteLine($"Skipping setting PLAYWRIGHT_BROWSERS_PATH");
#endif

Console.WriteLine($"Creating nuget restore directory: {nugetRestore}");
Directory.CreateDirectory(nugetRestore);

Expand Down Expand Up @@ -95,8 +100,9 @@ public async Task<bool> InstallPlaywrightAsync()
{
try
{
Console.WriteLine($"Installing Playwright to {EnvironmentVariables["PLAYWRIGHT_BROWSERS_PATH"]}");
await Playwright.InstallAsync(EnvironmentVariables["PLAYWRIGHT_BROWSERS_PATH"]);
Console.WriteLine($"Installing Playwright to Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")} Driver: {Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH")}");
await Playwright.InstallAsync(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"), Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH"));
DisplayContents(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"));
return true;
}
catch (Exception e)
Expand All @@ -106,7 +112,7 @@ public async Task<bool> InstallPlaywrightAsync()
}
}
#endif

public async Task<bool> InstallAspNetAppIfNeededAsync()
{
try
Expand Down Expand Up @@ -170,7 +176,7 @@ await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
errorDataReceived: Console.Error.WriteLine,
throwOnError: false,
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);

// ';' is the path separator on Windows, and ':' on Unix
Options.Path += OperatingSystem.IsWindows() ? ";" : ":";
Options.Path += $"{Environment.GetEnvironmentVariable("DOTNET_CLI_HOME")}/.dotnet/tools";
Expand Down Expand Up @@ -341,9 +347,7 @@ public void UploadResults()
// Combine the directory name + log name for the copied log file name to avoid overwriting duplicate test names in different test projects
var logName = $"{Path.GetFileName(Path.GetDirectoryName(file))}_{Path.GetFileName(file)}";
Console.WriteLine($"Copying: {file} to {Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, logName)}");
// Need to copy to HELIX_WORKITEM_UPLOAD_ROOT and HELIX_WORKITEM_UPLOAD_ROOT/../ in order for Azure Devops attachments to link properly and for Helix to store the logs
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, logName));
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, "..", logName));
}
}
else
Expand All @@ -357,9 +361,7 @@ public void UploadResults()
{
var fileName = Path.GetFileName(file);
Console.WriteLine($"Copying: {file} to {Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, fileName)}");
// Need to copy to HELIX_WORKITEM_UPLOAD_ROOT and HELIX_WORKITEM_UPLOAD_ROOT/../ in order for Azure Devops attachments to link properly and for Helix to store the logs
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, fileName));
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, "..", fileName));
}
}
else
Expand Down
5 changes: 3 additions & 2 deletions eng/helix/content/runtests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ param(

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0
$env:PLAYWRIGHT_BROWSERS_PATH = "$currentDirectory\ms-playwright"
$env:InstallPlaywright = "$InstallPlaywright"

$currentDirectory = Get-Location
$env:PLAYWRIGHT_BROWSERS_PATH = "$currentDirectory\ms-playwright"
$env:PLAYWRIGHT_DRIVER_PATH = "$currentDirectory\.playwright\win-x64\native\playwright.cmd"

$envPath = "$env:PATH;$env:HELIX_CORRELATION_PAYLOAD\node\bin"

function InvokeInstallDotnet([string]$command) {
Expand Down
47 changes: 44 additions & 3 deletions eng/helix/content/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

dotnet_sdk_version="$2"
dotnet_runtime_version="$3"
helixQueue="$5"
installPlaywright="${10}"

RESET="\033[0m"
RED="\033[0;31m"
Expand All @@ -25,8 +27,47 @@ export DOTNET_CLI_HOME="$DIR/.home$RANDOM"

export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

# Set playwright browser path
# Set playwright stuff
export PLAYWRIGHT_BROWSERS_PATH="$DIR/ms-playwright"
if [[ "$helixQueue" == *"OSX"* ]]; then
export PLAYWRIGHT_DRIVER_PATH="$DIR/.playwright/osx/native/playwright.sh"
PLAYWRIGHT_NODE_PATH=$DIR/.playwright/osx/native/node
else
export PLAYWRIGHT_DRIVER_PATH="$DIR/.playwright/unix/native/playwright.sh"
PLAYWRIGHT_NODE_PATH=$DIR/.playwright/unix/native/node
fi
export InstallPlaywright="$installPlaywright"
if [ -f "$PLAYWRIGHT_DRIVER_PATH" ]; then
if [[ "$helixQueue" != *"OSX"* ]]; then
echo "Installing Playwright requirements..."
sudo apt-get install -y libdbus-glib-1-2
sudo apt-get install -y libbrotli1
sudo apt-get install -y libegl1
sudo apt-get install -y libnotify4
sudo apt-get install -y libvpx5
sudo apt-get install -y libopus0
sudo apt-get install -y libwoff1
sudo apt-get install -y libgstreamer-plugins-base1.0-0
sudo apt-get install -y libgstreamer1.0-0
sudo apt-get install -y libgstreamer-gl1.0-0
sudo apt-get install -y libgstreamer-plugins-bad1.0-0
sudo apt-get install -y libopenjp2-7
sudo apt-get install -y libwebpdemux2
sudo apt-get install -y libwebp6
sudo apt-get install -y libenchant1c2a
sudo apt-get install -y libsecret-1-0
sudo apt-get install -y libhyphen0
sudo apt-get install -y libgles2
sudo apt-get install -y gstreamer1.0-libav
sudo apt-get install -y libxkbcommon0
sudo apt-get install -y libgtk-3-0
sudo apt-get install -y libharfbuzz-icu0
fi
echo "chmod +x $PLAYWRIGHT_DRIVER_PATH"
chmod +x $PLAYWRIGHT_DRIVER_PATH
echo "chmod +x $PLAYWRIGHT_NODE_PATH"
chmod +x $PLAYWRIGHT_NODE_PATH
fi

RESET="\033[0m"
RED="\033[0;31m"
Expand Down Expand Up @@ -83,8 +124,8 @@ exit_code=0
echo "Restore: $DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --ignore-failed-sources"
$DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --ignore-failed-sources

echo "Running tests: $DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $5 --arch $6 --quarantined $7 --ef $8 --helixTimeout $9"
$DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $5 --arch $6 --quarantined $7 --ef $8 --helixTimeout $9
echo "Running tests: $DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $helixQueue --arch $6 --quarantined $7 --ef $8 --helixTimeout $9"
$DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $helixQueue --arch $6 --quarantined $7 --ef $8 --helixTimeout $9
exit_code=$?
echo "Finished tests...exit_code=$exit_code"

Expand Down
4 changes: 2 additions & 2 deletions eng/targets/Helix.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

<!-- PR(ci.yaml) required queues -->
<ItemGroup Condition="'$(IsRequiredCheck)' == 'true' AND '$(TargetArchitecture)' == 'x64' AND '$(_UseHelixOpenQueues)' == 'true'">
<HelixAvailableTargetQueue Include="Ubuntu.1604.Amd64.Open" Platform="Linux" />
<HelixAvailableTargetQueue Include="Ubuntu.1804.Amd64.Open" Platform="Linux" />
<HelixAvailableTargetQueue Include="Windows.10.Amd64.Server20H2.Open" Platform="Windows" />
<HelixAvailableTargetQueue Include="OSX.1014.Amd64.Open" Platform="Linux" />
</ItemGroup>

<!-- queues for helix-matrix.yml pipeline -->
<ItemGroup Condition="'$(TargetArchitecture)' == 'x64' AND '$(IsHelixDaily)' == 'true' AND '$(_UseHelixOpenQueues)' == 'true' AND '$(IsWindowsOnlyTest)' != 'true'">
<HelixAvailableTargetQueue Include="Ubuntu.1804.Amd64.Open" Platform="Linux" />
<HelixAvailableTargetQueue Include="Ubuntu.1604.Amd64.Open" Platform="Linux" />
<HelixAvailableTargetQueue Include="Ubuntu.2004.Amd64.Open" Platform="Linux" />
<HelixAvailableTargetQueue Include="OSX.1100.Amd64.Open" Platform="Linux" />
<HelixAvailableTargetQueue Include="Debian.9.Amd64.Open" Platform="Linux" />
Expand Down
4 changes: 2 additions & 2 deletions eng/targets/Helix.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<HelixPreCommand Include="call RunPowershell.cmd mssql\InstallSqlServerLocalDB.ps1 || exit /b 1" />
</ItemGroup>

<PropertyGroup Condition="'$(TestDependsOnPlaywright)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
<SkipHelixQueues>Windows.7.Amd64.Open;Windows.81.Amd64.Open</SkipHelixQueues>
<PropertyGroup Condition="'$(TestDependsOnPlaywright)' == 'true'">
<SkipHelixQueues>Windows.7.Amd64.Open;Windows.81.Amd64.Open;Redhat.7.Amd64.Open;Redhat.7.Amd64;Debian.9.Amd64.Open;Debian.9.Amd64.Open;Ubuntu.2004.Amd64.Open;Ubuntu.2004.Amd64;Ubuntu.1604.Amd64.Open;Ubuntu.1604.Amd64;Alpine.312.Amd64.Open;(Alpine.312.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:alpine-3.12-helix-20200908125345-56c6673;(Fedora.33.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:fedora-33-helix-20210120000908-a9df267</SkipHelixQueues>
</PropertyGroup>

<ItemGroup Condition="'$(TestDependsOnPlaywright)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ await Fixture.BrowserManager.GetBrowserInstance(browserKind, BrowserContextInfo)
[Theory]
[MemberData(nameof(BlazorServerTemplateWorks_IndividualAuthData))]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/30807")]
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/30825", Queues = "All.OSX")]
public async Task BlazorServerTemplateWorks_IndividualAuth(BrowserKind browserKind, bool useLocalDB)
{
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<RunTemplateTests Condition="'$(RunTemplateTests)' == ''">true</RunTemplateTests>
<SkipTests Condition="'$(RunTemplateTests)' != 'true'">true</SkipTests>
<IsWindowsOnlyTest>true</IsWindowsOnlyTest>
<SkipHelixArm>true</SkipHelixArm>
<BaseOutputPath />
<OutputPath />
Expand Down Expand Up @@ -45,6 +44,8 @@
<Reference Include="Microsoft.Extensions.Configuration" />
<Reference Include="Microsoft.Extensions.Configuration.Json" />
<Reference Include="Anglesharp" />
<Reference Include="PlaywrightSharp" Condition="'$(TargetOsName)' != 'linux-musl'" />
<Reference Include="PlaywrightSharp" ExcludeAssets="build" Condition="'$(TargetOsName)' == 'linux-musl'" />
<ProjectReference Include="$(RepoRoot)src\Framework\App.Runtime\src\Microsoft.AspNetCore.App.Runtime.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
Expand All @@ -57,4 +58,13 @@

<!-- Shared testing infrastructure for running E2E template tests -->
<Import Project="..\TestInfrastructure\PrepareForTest.targets" />

<Target Name="PublishAssets" AfterTargets="Publish">
<ItemGroup>
<_PublishFiles Include="$(OutputPath).playwright\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(_PublishFiles)" DestinationFolder="$(PublishDir)\.playwright\%(_PublishFiles.RecursiveDir)\" />
</Target>


</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public Task BlazorWasmHostedTemplate_IndividualAuth_Works_WithLocalDB(BrowserKin
[Theory]
[InlineData(BrowserKind.Chromium)]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/30820")]
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/30825", Queues = "All.OSX")]
public Task BlazorWasmHostedTemplate_IndividualAuth_Works_WithOutLocalDB(BrowserKind browserKind)
{
return BlazorWasmHostedTemplate_IndividualAuth_Works(browserKind, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"Firefox": {
"BrowserKind": "Firefox",
"IsEnabled": true
"IsEnabled": false
},
"Webkit": {
"BrowserKind": "Webkit",
Expand Down
11 changes: 10 additions & 1 deletion src/Shared/BrowserTesting/src/BrowserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -46,7 +47,15 @@ private async Task InitializeAsync()

async Task InitializeCore()
{
Playwright = await PlaywrightSharp.Playwright.CreateAsync(_loggerFactory/*, debug: "pw:api"*/);
var driverPath = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH");
if (!string.IsNullOrEmpty(driverPath))
{
Playwright = await PlaywrightSharp.Playwright.CreateAsync(_loggerFactory, driverExecutablePath: driverPath, debug: "pw:api");
}
else
{
Playwright = await PlaywrightSharp.Playwright.CreateAsync(_loggerFactory, debug: "pw:api");
}
foreach (var (browserName, options) in _browserManagerConfiguration.BrowserOptions)
{
if (!_launchBrowsers.ContainsKey(browserName))
Expand Down
11 changes: 4 additions & 7 deletions src/Shared/BrowserTesting/src/ContextInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,18 @@ private void CleanupPage(object sender, EventArgs e)

internal BrowserContextOptions ConfigureUniqueHarPath(BrowserContextOptions browserContextOptions)
{
var uploadDir = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
if (browserContextOptions?.RecordHar?.Path != null)
{
var identifier = Guid.NewGuid().ToString("N");
var harDirectory = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
if (string.IsNullOrEmpty(harDirectory))
{
harDirectory = browserContextOptions.RecordHar.Path;
}
browserContextOptions.RecordHar.Path = Path.Combine(harDirectory, $"{identifier}.har");
browserContextOptions.RecordHar.Path = Path.Combine(
string.IsNullOrEmpty(uploadDir) ? browserContextOptions.RecordHar.Path : uploadDir,
$"{identifier}.har");
_harPath = browserContextOptions.RecordHar.Path;
}

if (browserContextOptions?.RecordVideo?.Dir != null)
{
var uploadDir = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
if (!string.IsNullOrEmpty(uploadDir))
{
browserContextOptions.RecordVideo.Dir = uploadDir;
Expand Down

0 comments on commit a104f9d

Please sign in to comment.