From d7d0e526f865ce0bf7da71963f98e14768262cfe Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 22 Oct 2022 05:52:58 +0000 Subject: [PATCH] [wasm] Use the provisioned chrome --- .../common/templates/wasm-library-tests.yml | 8 +++++- eng/testing/WasmRunnerTemplate.sh | 4 +++ eng/testing/tests.wasm.targets | 7 ++++-- eng/testing/wasm-provisioning.targets | 16 ++++++------ src/libraries/pretest.proj | 3 +++ src/libraries/sendtohelix-wasm.targets | 15 +++++++---- .../Wasm.Build.Tests/Wasm.Build.Tests.csproj | 11 ++++---- .../data/RunScriptTemplate.cmd | 4 +++ .../data/RunScriptTemplate.sh | 4 +++ .../DebuggerTestSuite.csproj | 2 +- ...ChromeForTests.cs => GetChromeVersions.cs} | 25 +++++++++++-------- 11 files changed, 66 insertions(+), 33 deletions(-) rename src/tasks/WasmBuildTasks/{InstallChromeForTests.cs => GetChromeVersions.cs} (88%) diff --git a/eng/pipelines/common/templates/wasm-library-tests.yml b/eng/pipelines/common/templates/wasm-library-tests.yml index eb64ac55ee7a0..6037b4529ecaa 100644 --- a/eng/pipelines/common/templates/wasm-library-tests.yml +++ b/eng/pipelines/common/templates/wasm-library-tests.yml @@ -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): diff --git a/eng/testing/WasmRunnerTemplate.sh b/eng/testing/WasmRunnerTemplate.sh index 2d5152215635a..077f891d05105 100644 --- a/eng/testing/WasmRunnerTemplate.sh +++ b/eng/testing/WasmRunnerTemplate.sh @@ -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 diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index ca7adf3e2987a..0c845a741f2cd 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -37,7 +37,10 @@ '$(Scenario)' == 'WasmTestOnBrowser'">true - + + @@ -348,7 +351,7 @@ - + diff --git a/eng/testing/wasm-provisioning.targets b/eng/testing/wasm-provisioning.targets index ae0261c4f2976..63238cdbc248a 100644 --- a/eng/testing/wasm-provisioning.targets +++ b/eng/testing/wasm-provisioning.targets @@ -29,10 +29,10 @@ - - + @@ -51,10 +51,10 @@ - - + @@ -96,19 +96,19 @@ + TaskName="Microsoft.WebAssembly.Build.Tasks.GetChromeVersions" /> - - + - + $(_ChromeBaseSnapshotUrl)/chrome-linux.zip diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index ac4f3c9021c0c..dc68ed802a448 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -29,6 +29,9 @@ + + - + @@ -97,7 +97,7 @@ - + @@ -161,14 +161,19 @@ - + + + + - - + + diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index b84e917833944..26d619310c3ea 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -13,15 +13,13 @@ true true - true + true false true - - RunScriptTemplate.cmd RunScriptTemplate.sh @@ -49,8 +47,8 @@ - - + + @@ -71,6 +69,9 @@ + + + diff --git a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd index e2568eff83f79..08a8b04d5f43e 100644 --- a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd +++ b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.cmd @@ -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% diff --git a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh index be117f0063909..d1f987199555e 100644 --- a/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh +++ b/src/mono/wasm/Wasm.Build.Tests/data/RunScriptTemplate.sh @@ -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 diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj index 8032934e68a94..0962b33581bcf 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj +++ b/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj @@ -8,7 +8,7 @@ chrome $(DefineConstants);RUN_IN_CHROME windows - true + true true diff --git a/src/tasks/WasmBuildTasks/InstallChromeForTests.cs b/src/tasks/WasmBuildTasks/GetChromeVersions.cs similarity index 88% rename from src/tasks/WasmBuildTasks/InstallChromeForTests.cs rename to src/tasks/WasmBuildTasks/GetChromeVersions.cs index 5a4587e4b90b6..81a65abb6bd8a 100644 --- a/src/tasks/WasmBuildTasks/InstallChromeForTests.cs +++ b/src/tasks/WasmBuildTasks/GetChromeVersions.cs @@ -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"; @@ -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] @@ -67,7 +67,7 @@ private async Task 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; } @@ -80,13 +80,13 @@ private async Task ExecuteInternalAsync() private async Task 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 @@ -98,11 +98,12 @@ private async Task 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 GetChromeVersionAsync() @@ -119,7 +120,8 @@ private async Task 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 @@ -134,7 +136,8 @@ private async Task 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];