From 1a2f0ab695e4e327cac1004acabe7a097ef145fa Mon Sep 17 00:00:00 2001
From: Tanay Parikh <TanayParikh@users.noreply.github.com>
Date: Tue, 7 Dec 2021 14:10:57 -0800
Subject: [PATCH] Backport `components-e2e` CI Pipeline Fixes to release/6.0
 (#38815)

* Quarantine CanAddAndDisposeRootComponents (#38693)

* Fix `components-e2e` Pipeline (#38704)

* Fix `components-e2e` Pipeline

Support for the `QuarantinedTest` attribute.

Using the `Quarantined` trait defined here:
https://github.com/dotnet/aspnetcore/blob/ba18614ec220c1209a3976f66aacc2c761568931/src/Testing/src/xunit/QuarantinedTestTraitDiscoverer.cs#L18

Extension of https://github.com/dotnet/aspnetcore/pull/38693 which got auto-merged.

* Update components-e2e-tests.yml

* PR Feedback

* Update components-e2e-tests.yml

- I pointed to an `xUnit` example, sorry

* PR Feedback

* PR Feedback

* Update artifacts dir

Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com>

Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com>
---
 .azure/pipelines/components-e2e-tests.yml     | 25 ++++++++++++++++---
 .../E2ETest/Tests/JSRootComponentsTest.cs     |  1 +
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/.azure/pipelines/components-e2e-tests.yml b/.azure/pipelines/components-e2e-tests.yml
index 734b7a2ac8e..057a6402772 100644
--- a/.azure/pipelines/components-e2e-tests.yml
+++ b/.azure/pipelines/components-e2e-tests.yml
@@ -43,17 +43,36 @@ jobs:
       displayName: NPM install
     - script: .dotnet/dotnet build ./src/Components/test/E2ETest -c $(BuildConfiguration) --no-restore
       displayName: Build
-    - script: .dotnet/dotnet test ./src/Components/test/E2ETest -c $(BuildConfiguration) --no-build --logger trx
+    - script: .dotnet/dotnet test ./src/Components/test/E2ETest -c $(BuildConfiguration) --no-build --filter 'Quarantined!=true|Quarantined=false'
+                 --logger:"trx%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.trx"
+                 --logger:"html%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.html"
+                 --results-directory $(Build.SourcesDirectory)/artifacts/TestResults/$(BuildConfiguration)/Unquarantined
       displayName: Run E2E tests
+    - script: .dotnet/dotnet test ./src/Components/test/E2ETest -c $(BuildConfiguration) --no-build --filter 'Quarantined=true' -p:RunQuarantinedTests=true
+                 --logger:"trx%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.trx"
+                 --logger:"html%3BLogFileName=Microsoft.AspNetCore.Components.E2ETests.html"
+                 --results-directory $(Build.SourcesDirectory)/artifacts/TestResults/$(BuildConfiguration)/Quarantined
+      displayName: Run Quarantined E2E tests
+      continueOnError: true
     - task: PublishTestResults@2
       displayName: Publish E2E Test Results
       inputs:
         testResultsFormat: 'VSTest'
         testResultsFiles: '*.trx'
-        searchFolder: '$(Build.SourcesDirectory)/src/Components/test/E2ETest/TestResults'
+        searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(BuildConfiguration)/Unquarantined'
         testRunTitle: ComponentsE2E-$(AgentOsName)-$(BuildConfiguration)-xunit
       condition: always()
+    - task: PublishTestResults@2
+      displayName: Publish Quarantined E2E Test Results
+      inputs:
+        testResultsFormat: 'VSTest'
+        testResultsFiles: '*.trx'
+        searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(BuildConfiguration)/Quarantined'
+        testRunTitle: Quarantine-$(AgentOsName)-$(BuildConfiguration)-xunit
+        mergeTestResults: true
+      condition: always()
+
     artifacts:
     - name: Components_E2E_Test_Logs
-      path: ./src/Components/test/E2ETest/TestResults
+      path: '$(Build.SourcesDirectory)/artifacts/TestResults/$(BuildConfiguration)'
       publishOnError: true
diff --git a/src/Components/test/E2ETest/Tests/JSRootComponentsTest.cs b/src/Components/test/E2ETest/Tests/JSRootComponentsTest.cs
index c1c1764c5c4..c4e4b29bfd6 100644
--- a/src/Components/test/E2ETest/Tests/JSRootComponentsTest.cs
+++ b/src/Components/test/E2ETest/Tests/JSRootComponentsTest.cs
@@ -36,6 +36,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
         [InlineData(false, true)]
         [InlineData(true, false)]
         [InlineData(true, true)]
+        [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/38613")]
         public void CanAddAndDisposeRootComponents(bool intoBlazorUi, bool attachShadowRoot)
         {
             var message = app.FindElement(By.Id("message"));
-- 
GitLab