Skip to content

Commit

Permalink
[wasm] Use the provisioned chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
radical committed Oct 23, 2022
1 parent b6b3bfa commit d7d0e52
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 33 deletions.
8 changes: 7 additions & 1 deletion eng/pipelines/common/templates/wasm-library-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ jobs:
ne(dependencies.evaluate_paths.outputs.SetPathVars_any_other_than_wasm_wbt_dbg.containsChange, true))
- name: _wasmRunSmokeTestsOnlyArg
value: /p:RunSmokeTestsOnly=${{ eq(parameters.shouldRunSmokeOnly, true) }}
- name: chromeInstallArg
${{ if containsValue(parameters.scenarios, 'wasmtestonbrowser') }}:
value: /p:InstallChromeForTests=true
${{ else }}:
value: ''

jobParameters:
isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }}
testGroup: innerloop
nameSuffix: LibraryTests${{ parameters.nameSuffix }}
buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:BrowserHost=$(_hostedOs) $(_wasmRunSmokeTestsOnlyArg) ${{ parameters.extraBuildArgs }}
buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:BrowserHost=$(_hostedOs) $(_wasmRunSmokeTestsOnlyArg) $(chromeInstallArg) ${{ parameters.extraBuildArgs }}
timeoutInMinutes: 240
# if !alwaysRun, then:
# if this is runtime-wasm (isWasmOnlyBuild):
Expand Down
4 changes: 4 additions & 0 deletions eng/testing/WasmRunnerTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ if [[ -z "$XHARNESS_ARGS" ]]; then
XHARNESS_ARGS="$JS_ENGINE $JS_ENGINE_ARGS $MAIN_JS"
fi

if [[ -n "$PREPEND_PATH" ]]; then
export PATH=$PREPEND_PATH:$PATH
fi

if [[ -n "$XUNIT_RANDOM_ORDER_SEED" ]]; then
WasmXHarnessMonoArgs="${WasmXHarnessMonoArgs} --setenv=XUNIT_RANDOM_ORDER_SEED=${XUNIT_RANDOM_ORDER_SEED}"
fi
Expand Down
7 changes: 5 additions & 2 deletions eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
'$(Scenario)' == 'WasmTestOnBrowser'">true</InstallChromeForTests>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)wasm-provisioning.targets" Condition="'$(InstallChromeForTests)' == 'true'" />
<!-- On CI this is installed as part of pretest, but it should still be installed
for WBT, and debugger tests -->
<Import Project="$(MSBuildThisFileDirectory)wasm-provisioning.targets"
Condition="'$(InstallChromeForTests)' == 'true' and ('$(ContinuousIntegrationBuild)' != 'true' or '$(IsWasmProject)' != 'true')" />

<PropertyGroup Condition="'$(EnableAggressiveTrimming)' == 'true'">
<!-- suppress warnings as these are tests, and not expected to be trim-safe -->
Expand Down Expand Up @@ -348,7 +351,7 @@
<SetScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( set &quot;WasmXHarnessMonoArgs=%WasmXHarnessMonoArgs% --setenv=NPM_MODULES^=$(NodeNpmModuleString)&quot; )" />
<RunScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( call npm ci )" />

<SetScriptCommands Condition="'$(InstallChromeForTests)' == 'true' and '$(ChromeDriverBinaryPath)' != ''" Include="set PREPEND_PATH=$([System.IO.Path]::Path.GetDirectoryName($(ChromeDriverBinaryPath)))" />
<SetScriptCommands Condition="'$(InstallChromeForTests)' == 'true' and '$(ChromeDriverBinaryPath)' != ''" Include="set PREPEND_PATH=$([System.IO.Path]::GetDirectoryName($(ChromeDriverBinaryPath)))" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions eng/testing/wasm-provisioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

<RemoveDir Directories="$(ChromeDir)" />

<Message Text="** Installing chrome version $(ChromeVersion), rev: $(ChromeRevision). Disable this by setting msbuild property InstallChromeForTests=false ."
<Message Text="** Installing chrome version $(ChromeVersion), rev: $(ChromeRevision). To disable this set the msuild property InstallChromeForTests=false ."
Importance="High" />

<DownloadFile SourceUrl="$(ChromeUrl)" DestinationFolder="$(ArtifactsObjDir)" SkipUnchangedFiles="true">
<DownloadFile SourceUrl="$(ChromeUrl)" DestinationFolder="$(ArtifactsObjDir)" SkipUnchangedFiles="false">
<Output TaskParameter="DownloadedFile" PropertyName="_DownloadedFile" />
</DownloadFile>
<Unzip SourceFiles="$(_DownloadedFile)" DestinationFolder="$(ChromeDir)" />
Expand All @@ -51,10 +51,10 @@

<RemoveDir Directories="$(ChromeDriverDir)" />

<Message Text="** Installing chromedriver version $(ChromeVersion), rev: $(ChromeRevision). Disable this by setting msbuild property InstallChromeForTests=false ."
<Message Text="** Installing chromedriver version $(ChromeVersion), rev: $(ChromeRevision). To disable this set the msuild property InstallChromeForTests=false ."
Importance="High" />

<DownloadFile SourceUrl="$(ChromeDriverUrl)" DestinationFolder="$(ArtifactsObjDir)" SkipUnchangedFiles="true">
<DownloadFile SourceUrl="$(ChromeDriverUrl)" DestinationFolder="$(ArtifactsObjDir)" SkipUnchangedFiles="false">
<Output TaskParameter="DownloadedFile" PropertyName="_DownloadedFile" />
</DownloadFile>
<Unzip SourceFiles="$(_DownloadedFile)" DestinationFolder="$(ChromeDriverDir)" />
Expand Down Expand Up @@ -96,19 +96,19 @@
</Target>

<UsingTask AssemblyFile="$(WasmBuildTasksAssemblyPath)"
TaskName="Microsoft.WebAssembly.Build.Tasks.InstallChromeForTests" />
TaskName="Microsoft.WebAssembly.Build.Tasks.GetChromeVersions" />

<Target Name="GetChromeVersion" AfterTargets="Build" Condition="'$(InstallChromeForTests)' == 'true'">
<InstallChromeForTests
<GetChromeVersions
OSIdentifier="$(ChromeOSIdentifier)"
OSPrefix="$(_ChromeOSPrefix)"
Channel="$(ChromeChannel)"
IntermediateOutputPath="$(ArtifactsObjDir)">
<Output TaskParameter="ChromeVersion" PropertyName="ChromeVersion" />
<Output TaskParameter="V8Version" PropertyName="V8Version" />
<Output TaskParameter="BranchBasePosition" PropertyName="ChromeRevision" />
<Output TaskParameter="BranchPosition" PropertyName="ChromeRevision" />
<Output TaskParameter="BaseSnapshotUrl" PropertyName="_ChromeBaseSnapshotUrl" />
</InstallChromeForTests>
</GetChromeVersions>

<PropertyGroup Condition="'$(ChromeOSIdentifier)' == 'linux'">
<ChromeUrl>$(_ChromeBaseSnapshotUrl)/chrome-linux.zip</ChromeUrl>
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/pretest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<ProjectReference Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Runtime.sfxproj" Pack="true" Condition="'$(TargetOS)' == 'Browser'" />
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)testing\wasm-provisioning.targets"
Condition="'$(TargetOS)' == 'Browser' and '$(ContinuousIntegrationBuild)' == 'true'" />

<Target Name="BuildExternalsProject"
BeforeTargets="Build">
<MSBuild Targets="Build"
Expand Down
15 changes: 10 additions & 5 deletions src/libraries/sendtohelix-wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<HelixPreCommand Include="export XHARNESS_LOG_WITH_TIMESTAMPS=true" />

<HelixPreCommand Condition="'$(NeedsToRunOnBrowser)' == 'true' and '$(DebuggerHost)' == 'chrome'" Include="export PATH=$HELIX_CORRELATION_PAYLOAD/$(ChromeDriverDirName):$PATH" />
<HelixPreCommand Condition="'$(NeedsToRunOnBrowser)' == 'true' and '$(DebuggerHost)' == 'chrome'" Include="export PATH=$HELIX_CORRELATION_PAYLOAD/$(ChromiumDirName):$PATH" />
<HelixPreCommand Condition="'$(NeedsToRunOnBrowser)' == 'true' and '$(DebuggerHost)' == 'chrome'" Include="export PATH=$HELIX_CORRELATION_PAYLOAD/$(ChromeDirName):$PATH" />
</ItemGroup>

<ItemGroup Condition="'$(WindowsShell)' == 'true'">
Expand All @@ -97,7 +97,7 @@
<HelixPreCommand Include="set XHARNESS_LOG_WITH_TIMESTAMPS=true" />

<HelixPreCommand Condition="'$(NeedsToRunOnBrowser)' == 'true' and '$(DebuggerHost)' == 'chrome'" Include="set PATH=%HELIX_CORRELATION_PAYLOAD%\$(ChromeDriverDirName)%3B%PATH%" />
<HelixPreCommand Condition="'$(NeedsToRunOnBrowser)' == 'true' and '$(DebuggerHost)' == 'chrome'" Include="set PATH=%HELIX_CORRELATION_PAYLOAD%\$(ChromiumDirName)%3B%PATH%" />
<HelixPreCommand Condition="'$(NeedsToRunOnBrowser)' == 'true' and '$(DebuggerHost)' == 'chrome'" Include="set PATH=%HELIX_CORRELATION_PAYLOAD%\$(ChromeDirName)%3B%PATH%" />
</ItemGroup>

<ItemGroup Condition="'$(NeedsEMSDKNode)' == 'true' and '$(WindowsShell)' != 'true'">
Expand Down Expand Up @@ -161,14 +161,19 @@
</When>
</Choose>

<Import Project="$(RepositoryEngineeringDir)testing\ProvisioningVersions.props" />
<Import Project="$(RepositoryEngineeringDir)testing\wasm-provisioning.targets" />

<Target Name="PrepareHelixCorrelationPayload_Wasm">
<Message Condition="'$(NeedsEMSDK)' == 'true' or '$(NeedsEMSDKNode)' == 'true'" Importance="High" Text="Using emsdk: $(EmSdkDirForHelixPayload)" />

<Error Condition="'$(NeedsToRunOnBrowser)' == 'true' and !Exists($(ChromeDir))"
Text="Could not find chrome at $(ChromeDir)" />
<Error Condition="'$(NeedsToRunOnBrowser)' == 'true' and !Exists($(ChromeDriverDir))"
Text="Could not find chromedriver at $(ChromeDriverDir)" />

<ItemGroup Condition="'$(NeedsToRunOnBrowser)' == 'true'">
<HelixCorrelationPayload Condition="'$(DebuggerHost)' == 'chrome'" Include="chromium" Uri="$(ChromiumUrl)" />
<HelixCorrelationPayload Condition="'$(DebuggerHost)' == 'chrome'" Include="chromedriver" Uri="$(ChromeDriverUrl)" />
<HelixCorrelationPayload Condition="'$(DebuggerHost)' == 'chrome'" Include="$(ChromeDir)" />
<HelixCorrelationPayload Condition="'$(DebuggerHost)' == 'chrome'" Include="$(ChromeDriverDir)" />

<!--<HelixCorrelationPayload Condition="'$(WindowsShell)' != 'true' and '$(DebuggerHost)' == 'firefox'" Include="firefox" Uri="$(FirefoxUrl)" />-->
<HelixCorrelationPayload Condition="'$(WindowsShell)' != 'true' and '$(DebuggerHost)' == 'firefox'" Include="$(FirefoxForHelixPayload)" />
Expand Down
11 changes: 6 additions & 5 deletions src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@

<TestUsingWorkloads Condition="'$(TestUsingWorkloads)' == ''">true</TestUsingWorkloads>
<InstallWorkloadForTesting>true</InstallWorkloadForTesting>
<InstallChromeForTests Condition="'$(InstallChromeForTests)' == '' and '$(ContinuousIntegrationBuild)' != 'true' and Exists('/.dockerenv')">true</InstallChromeForTests>
<InstallChromeForTests Condition="'$(InstallChromeForTests)' == '' and ('$(ContinuousIntegrationBuild)' == 'true' or Exists('/.dockerenv'))">true</InstallChromeForTests>

<!-- don't run any wasm build steps -->
<IsWasmProject>false</IsWasmProject>
<UseDefaultTestHost>true</UseDefaultTestHost>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)testing\wasm-provisioning.targets" />

<PropertyGroup>
<RunScriptInputName Condition="'$(OS)' == 'Windows_NT'">RunScriptTemplate.cmd</RunScriptInputName>
<RunScriptInputName Condition="'$(OS)' != 'Windows_NT'">RunScriptTemplate.sh</RunScriptInputName>
Expand Down Expand Up @@ -49,8 +47,8 @@
<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export BASE_DIR=%24{HELIX_CORRELATION_PAYLOAD}" />
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set BASE_DIR=%HELIX_CORRELATION_PAYLOAD%" />

<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export BROWSER_PATH_FOR_TESTS=$HELIX_CORRELATION_PAYLOAD/chrome-linux/chrome" />
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set BROWSER_PATH_FOR_TESTS=%HELIX_CORRELATION_PAYLOAD%\chrome-win\chrome.exe" />
<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export BROWSER_PATH_FOR_TESTS=$HELIX_CORRELATION_PAYLOAD/$(ChromeDirName)/$(ChromeBinaryName)" />
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set BROWSER_PATH_FOR_TESTS=%HELIX_CORRELATION_PAYLOAD%\$(ChromeDirName)\$(ChromeBinaryName)" />

<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="chmod +x $HELIX_WORKITEM_ROOT/.playwright/node/linux/playwright.sh" />
<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="chmod +x $HELIX_WORKITEM_ROOT/.playwright/node/linux/node" />
Expand All @@ -71,6 +69,9 @@
<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export BASE_DIR=$(ArtifactsBinDir)" />
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set BASE_DIR=$(ArtifactsBinDir)" />

<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export BROWSER_PATH_FOR_TESTS=$(_WasmBrowserPathForTests)" />
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set BROWSER_PATH_FOR_TESTS=$(_WasmBrowserPathForTests)" />

<RunScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="export BUILT_NUGETS_PATH=$(LibrariesShippingPackagesDir)/" />
<RunScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="set BUILT_NUGETS_PATH=$(LibrariesShippingPackagesDir)" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ if [%XHARNESS_ARGS%] == [] (
set "XHARNESS_ARGS=%JS_ENGINE% %JS_ENGINE_ARGS% %BROWSER_PATH% %MAIN_JS%"
)

if [%PREPEND_PATH%] NEQ [] (
set "PATH=%PREPEND_PATH%;%PATH%"
)

echo EXECUTION_DIR=%EXECUTION_DIR%
echo SCENARIO=%SCENARIO%
echo XHARNESS_OUT=%XHARNESS_OUT%
Expand Down
4 changes: 4 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ if [[ -z "$XHARNESS_ARGS" ]]; then
XHARNESS_ARGS="$JS_ENGINE $JS_ENGINE_ARGS $MAIN_JS"
fi

if [[ -n "$PREPEND_PATH" ]]; then
export PATH=$PREPEND_PATH:$PATH
fi

echo EXECUTION_DIR=$EXECUTION_DIR
echo SCENARIO=$SCENARIO
echo XHARNESS_OUT=$XHARNESS_OUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<DebuggerHost Condition="'$(DebuggerHost)' == '' or ('$(DebuggerHost)' != 'chrome' and '$(DebuggerHost)' != 'firefox')">chrome</DebuggerHost>
<DefineConstants Condition="'$(DebuggerHost)' == 'chrome'">$(DefineConstants);RUN_IN_CHROME</DefineConstants>
<BrowserHost Condition="$([MSBuild]::IsOSPlatform('windows'))">windows</BrowserHost>
<InstallChromeForTests Condition="'$(InstallChromeForTests)' == '' and '$(DebuggerHost)' == 'chrome' and '$(ContinuousIntegrationBuild)' != 'true' and Exists('/.dockerenv')">true</InstallChromeForTests>
<InstallChromeForTests Condition="'$(InstallChromeForTests)' == '' and '$(DebuggerHost)' == 'chrome' and ('$(ContinuousIntegrationBuild)' == 'true' or Exists('/.dockerenv'))">true</InstallChromeForTests>
<InstallFirefoxForTests Condition="'$(DebuggerHost)' == 'firefox' and '$(InstallFirefoxForTests)' == '' and '$(ContinuousIntegrationBuild)' != 'true' and Exists('/.dockerenv')">true</InstallFirefoxForTests>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

namespace Microsoft.WebAssembly.Build.Tasks;

public class InstallChromeForTests : MBU.Task
public class GetChromeVersions : MBU.Task
{
private const string s_allJsonUrl = "http://omahaproxy.appspot.com/all.json";
private const string s_snapshotBaseUrl = $"https://storage.googleapis.com/chromium-browser-snapshots";
private const int s_versionCheckThresholdDays = 3;
private const int s_numBranchPositionsToTry = 10;
private const int s_numBranchPositionsToTry = 30;
private static readonly HttpClient s_httpClient = new();

public string Channel { get; set; } = "stable";
Expand All @@ -45,7 +45,7 @@ public class InstallChromeForTests : MBU.Task
[Output]
public string ChromeVersion { get; set; } = string.Empty;
[Output]
public string BranchBasePosition { get; set; } = string.Empty;
public string BranchPosition { get; set; } = string.Empty;
[Output]
public string BaseSnapshotUrl { get; set; } = string.Empty;
[Output]
Expand All @@ -67,7 +67,7 @@ private async Task<bool> ExecuteInternalAsync()
BaseSnapshotUrl = await GetChromeUrlsAsync(version).ConfigureAwait(false);
ChromeVersion = version.version;
V8Version = version.v8_version;
BranchBasePosition = version.branch_base_position;
BranchPosition = version.branch_base_position;

return !Log.HasLoggedErrors;
}
Expand All @@ -80,13 +80,13 @@ private async Task<bool> ExecuteInternalAsync()

private async Task<string> GetChromeUrlsAsync(ChromeVersionSpec version)
{
string baseUrl = Path.Combine(s_snapshotBaseUrl, OSPrefix);
string baseUrl = $"{s_snapshotBaseUrl}/{OSPrefix}";

int branchPosition = int.Parse(version.branch_base_position);
for (int i = 0; i < s_numBranchPositionsToTry; i++)
{
string branchUrl = Path.Combine(baseUrl, branchPosition.ToString());
string url = Path.Combine(branchUrl, "REVISIONS");
string branchUrl = $"{baseUrl}/{branchPosition}";
string url = $"{branchUrl}/REVISIONS";

Log.LogMessage(MessageImportance.Low, $"Checking if {url} exists ..");
HttpResponseMessage response = await s_httpClient
Expand All @@ -98,11 +98,12 @@ private async Task<string> GetChromeUrlsAsync(ChromeVersionSpec version)
return branchUrl;
}

branchPosition -= 1;
branchPosition += 1;
}

throw new LogAsErrorException($"Could not find a chrome snapshot folder under {baseUrl}, " +
$"starting at branch position {branchPosition}, for version {version.version}");
$"for branch positions {version.branch_base_position} to " +
$"{branchPosition}, for version {version.version}.");
}

private async Task<ChromeVersionSpec> GetChromeVersionAsync()
Expand All @@ -119,7 +120,8 @@ private async Task<ChromeVersionSpec> GetChromeVersionAsync()
if (foundOSVersions.Length == 0)
{
string availableOSIds = string.Join(", ", perOSVersions.Select(osv => osv.os).Distinct().Order());
throw new LogAsErrorException($"Unknown OS identifier '{OSIdentifier}'. OS identifiers found in all.json: {availableOSIds}");
throw new LogAsErrorException($"Unknown OS identifier '{OSIdentifier}'. OS identifiers found " +
$"in all.json: {availableOSIds}");
}

ChromeVersionSpec[] foundChromeVersions = foundOSVersions
Expand All @@ -134,7 +136,8 @@ private async Task<ChromeVersionSpec> GetChromeVersionAsync()
.Select(cv => cv.channel)
.Distinct()
.Order());
throw new LogAsErrorException($"Unknown chrome channel '{Channel}'. Channels found in all.json: {availableChannels}");
throw new LogAsErrorException($"Unknown chrome channel '{Channel}'. Channels found in all.json: " +
availableChannels);
}

return foundChromeVersions[0];
Expand Down

0 comments on commit d7d0e52

Please sign in to comment.