Skip to content

Commit 88c5c19

Browse files
authored
[tests] Disable playwright tests on helix/linux (dotnet#4694)
Playwright dependency installation on helix/linux has been failing on some random helix agents. Until that gets fixed, this PR is disabling: - tests that exclusively use playwright - disable parts of tests that use playwright To keep the test runs on CI consistent, these are always being disabled on Helix/Linux. Issue: dotnet#4623
1 parent 2680b78 commit 88c5c19

9 files changed

+54
-28
lines changed

tests/Aspire.Workload.Tests/EmptyTemplateRunTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public EmptyTemplateRunTests(EmptyTemplateRunFixture fixture, ITestOutputHelper
1717
}
1818

1919
[Fact]
20+
[ActiveIssue("https://github.com/dotnet/aspire/issues/4623", typeof(BuildEnvironment), nameof(BuildEnvironment.HasPlaywrightSupport))]
2021
public async Task ResourcesShowUpOnDashboad()
2122
{
2223
await using var context = await CreateNewBrowserContextAsync();

tests/Aspire.Workload.Tests/PerTestFrameworkTemplatesTests.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ public async Task TemplatesForIndividualTestFrameworks(string prefix)
5050
buildEnvironment: BuildEnvironment.ForDefaultFramework);
5151

5252
await project.BuildAsync(extraBuildArgs: [$"-c {config}"]).ConfigureAwait(false);
53-
await using (var context = await CreateNewBrowserContextAsync())
53+
if (BuildEnvironment.HasPlaywrightSupport)
5454
{
55-
await AssertBasicTemplateAsync(context).ConfigureAwait(false);
55+
await using (var context = await CreateNewBrowserContextAsync())
56+
{
57+
await AssertBasicTemplateAsync(context).ConfigureAwait(false);
58+
}
5659
}
5760

5861
// Add test project

tests/Aspire.Workload.Tests/StarterTemplateProjectNamesTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task StarterTemplateWithTest_ProjectNames(string prefix, string tes
4040
BuildEnvironment.ForDefaultFramework,
4141
$"-t {testType}").ConfigureAwait(false);
4242

43-
await using var context = await CreateNewBrowserContextAsync();
43+
await using var context = BuildEnvironment.HasPlaywrightSupport ? await CreateNewBrowserContextAsync() : null;
4444
_testOutput.WriteLine($"Checking the starter template project");
4545
await AssertStarterTemplateRunAsync(context, project, config, _testOutput).ConfigureAwait(false);
4646

tests/Aspire.Workload.Tests/StarterTemplateRunTestsBase.cs

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public StarterTemplateRunTestsBase(T fixture, ITestOutputHelper testOutput)
2222
}
2323

2424
[Fact]
25+
[ActiveIssue("https://github.com/dotnet/aspire/issues/4623", typeof(BuildEnvironment), nameof(BuildEnvironment.HasPlaywrightSupport))]
2526
public async Task ResourcesShowUpOnDashboad()
2627
{
2728
await using var context = await CreateNewBrowserContextAsync();
@@ -34,6 +35,7 @@ await CheckDashboardHasResourcesAsync(
3435
[Theory]
3536
[InlineData("http://")]
3637
[InlineData("https://")]
38+
[ActiveIssue("https://github.com/dotnet/aspire/issues/4623", typeof(BuildEnvironment), nameof(BuildEnvironment.HasPlaywrightSupport))]
3739
public async Task WebFrontendWorks(string urlPrefix)
3840
{
3941
await using var context = await CreateNewBrowserContextAsync();

tests/Aspire.Workload.Tests/TemplateTests.cs

+13-7
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ public async Task BuildAndRunAspireTemplate(string config)
5050
await project.BuildAsync(extraBuildArgs: [$"-c {config}"]);
5151
await project.StartAppHostAsync(extraArgs: [$"-c {config}"]);
5252

53-
await using var context = await CreateNewBrowserContextAsync();
54-
var page = await project.OpenDashboardPageAsync(context);
55-
await CheckDashboardHasResourcesAsync(page, []);
53+
if (BuildEnvironment.HasPlaywrightSupport)
54+
{
55+
await using var context = await CreateNewBrowserContextAsync();
56+
var page = await project.OpenDashboardPageAsync(context);
57+
await CheckDashboardHasResourcesAsync(page, []);
58+
}
5659
}
5760

5861
[Theory]
@@ -67,7 +70,7 @@ public async Task StarterTemplateNewAndRunWithoutExplicitBuild(string config)
6770
_testOutput,
6871
buildEnvironment: BuildEnvironment.ForDefaultFramework);
6972

70-
await using var context = await CreateNewBrowserContextAsync();
73+
await using var context = BuildEnvironment.HasPlaywrightSupport ? await CreateNewBrowserContextAsync() : null;
7174
await AssertStarterTemplateRunAsync(context, project, config, _testOutput);
7275
}
7376

@@ -97,8 +100,11 @@ public async Task ProjectWithNoHTTPSRequiresExplicitOverrideWithEnvironmentVaria
97100
testSpecificBuildEnvironment.EnvVars["ASPIRE_ALLOW_UNSECURED_TRANSPORT"] = "true";
98101
await project.StartAppHostAsync();
99102

100-
await using var context = await CreateNewBrowserContextAsync();
101-
var page = await project.OpenDashboardPageAsync(context);
102-
await CheckDashboardHasResourcesAsync(page, []).ConfigureAwait(false);
103+
if (BuildEnvironment.HasPlaywrightSupport)
104+
{
105+
await using var context = await CreateNewBrowserContextAsync();
106+
var page = await project.OpenDashboardPageAsync(context);
107+
await CheckDashboardHasResourcesAsync(page, []).ConfigureAwait(false);
108+
}
103109
}
104110
}

tests/Aspire.Workload.Tests/WorkloadTestsBase.cs

+26-16
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ private static IBrowser CreateBrowser()
5959
}
6060

6161
public static Task<IBrowserContext> CreateNewBrowserContextAsync()
62-
=> Browser.Value.NewContextAsync(new BrowserNewContextOptions { IgnoreHTTPSErrors = true });
62+
=> BuildEnvironment.HasPlaywrightSupport
63+
? Browser.Value.NewContextAsync(new BrowserNewContextOptions { IgnoreHTTPSErrors = true })
64+
: throw new InvalidOperationException("Playwright is not available");
6365

6466
protected Task<ResourceRow[]> CheckDashboardHasResourcesAsync(IPage dashboardPage, IEnumerable<ResourceRow> expectedResources, int timeoutSecs = 120)
6567
=> CheckDashboardHasResourcesAsync(dashboardPage, expectedResources, _testOutput, timeoutSecs);
@@ -203,29 +205,37 @@ public static IEnumerable<string> GetProjectNamesForTest()
203205
yield return "aspire";
204206
}
205207

206-
public static async Task AssertStarterTemplateRunAsync(IBrowserContext context, AspireProject project, string config, ITestOutputHelper _testOutput)
208+
public static async Task AssertStarterTemplateRunAsync(IBrowserContext? context, AspireProject project, string config, ITestOutputHelper _testOutput)
207209
{
208210
await project.StartAppHostAsync(extraArgs: [$"-c {config}"], noBuild: false);
209211

210-
var page = await project.OpenDashboardPageAsync(context);
211-
ResourceRow[] resourceRows;
212-
try
212+
if (context is not null)
213213
{
214-
resourceRows = await CheckDashboardHasResourcesAsync(
215-
page,
216-
StarterTemplateRunTestsBase<StarterTemplateFixture>.GetExpectedResources(project, hasRedisCache: false),
217-
_testOutput).ConfigureAwait(false);
214+
var page = await project.OpenDashboardPageAsync(context);
215+
ResourceRow[] resourceRows;
216+
try
217+
{
218+
resourceRows = await CheckDashboardHasResourcesAsync(
219+
page,
220+
StarterTemplateRunTestsBase<StarterTemplateFixture>.GetExpectedResources(project, hasRedisCache: false),
221+
_testOutput).ConfigureAwait(false);
222+
}
223+
catch
224+
{
225+
string screenshotPath = Path.Combine(project.LogPath, "dashboard-fail.png");
226+
await page.ScreenshotAsync(new PageScreenshotOptions { Path = screenshotPath });
227+
_testOutput.WriteLine($"Dashboard screenshot saved to {screenshotPath}");
228+
throw;
229+
}
230+
231+
string url = resourceRows.First(r => r.Name == "webfrontend").Endpoints[0];
232+
await StarterTemplateRunTestsBase<StarterTemplateFixture>.CheckWebFrontendWorksAsync(context, url, _testOutput, project.LogPath);
218233
}
219-
catch
234+
else
220235
{
221-
string screenshotPath = Path.Combine(project.LogPath, "dashboard-fail.png");
222-
await page.ScreenshotAsync(new PageScreenshotOptions { Path = screenshotPath });
223-
_testOutput.WriteLine($"Dashboard screenshot saved to {screenshotPath}");
224-
throw;
236+
_testOutput.WriteLine($"Skipping playwright part of the test");
225237
}
226238

227-
string url = resourceRows.First(r => r.Name == "webfrontend").Endpoints[0];
228-
await StarterTemplateRunTestsBase<StarterTemplateFixture>.CheckWebFrontendWorksAsync(context, url, _testOutput, project.LogPath);
229239
await project.StopAppHostAsync();
230240
}
231241

tests/Shared/WorkloadTesting/BuildEnvironment.cs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class BuildEnvironment
2525
public const TestTargetFramework DefaultTargetFramework = TestTargetFramework.Net80;
2626
public static readonly string TestDataPath = Path.Combine(AppContext.BaseDirectory, "data");
2727
public static readonly string TestRootPath = Path.Combine(Path.GetTempPath(), "testroot");
28+
public static bool HasPlaywrightSupport => !EnvironmentVariables.DisablePlaywrightTests;
2829

2930
public static bool IsRunningOnHelix => Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT") is not null;
3031
public static bool IsRunningOnCIBuildMachine => Environment.GetEnvironmentVariable("BUILD_BUILDID") is not null;

tests/Shared/WorkloadTesting/EnvironmentVariables.cs

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ public static class EnvironmentVariables
1717
public static readonly string? TestAssetsPath = Environment.GetEnvironmentVariable("TEST_ASSETS_PATH");
1818
public static readonly string? TestScenario = Environment.GetEnvironmentVariable("TEST_SCENARIO");
1919
public static readonly string? BrowserPath = Environment.GetEnvironmentVariable("BROWSER_PATH");
20+
public static readonly bool DisablePlaywrightTests = Environment.GetEnvironmentVariable("DISABLE_PLAYWRIGHT_TESTS") is "true";
2021
}

tests/helix/send-to-helix-inner.proj

+4-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@
7474
<HelixCorrelationPayload Include="$(PlaywrightDependenciesDirectory)" Destination="playwright-deps" />
7575

7676
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="chmod +x $HELIX_WORKITEM_ROOT/.playwright/node/linux-x64/node" />
77-
<!-- wait for lock for 2mins -->
78-
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="(sudo apt-get -o DPkg::Lock::Timeout=120 install -y libgbm1 libxkbcommon0 || (cat /var/lib/dkms/lttng-modules/2.13.8/build/make.log; exit 1)) || exit 1" />
77+
78+
<!-- Disable playwright tests on helix/linux. Issue: https://github.com/dotnet/aspire/issues/4623 -->
79+
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="export DISABLE_PLAYWRIGHT_TESTS=true" />
80+
<!--<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="(sudo apt-get -o DPkg::Lock::Timeout=120 install -y libgbm1 libxkbcommon0 || (cat /var/lib/dkms/lttng-modules/2.13.8/build/make.log; exit 1)) || exit 1" />-->
7981

8082
<HelixPreCommand Condition="'$(OS)' == 'Windows_NT'" Include="set PLAYWRIGHT_BROWSERS_PATH=%HELIX_CORRELATION_PAYLOAD%\playwright-deps" />
8183
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="export PLAYWRIGHT_BROWSERS_PATH=$HELIX_CORRELATION_PAYLOAD/playwright-deps" />

0 commit comments

Comments
 (0)