diff --git a/playground/Directory.Build.props b/playground/Directory.Build.props
index 42f5a81c61f..7e291844b5a 100644
--- a/playground/Directory.Build.props
+++ b/playground/Directory.Build.props
@@ -12,6 +12,8 @@
CS1712: Type parameter 'type_parameter' has no matching typeparam tag in the XML comment on 'type_or_member' (but other type parameters do)
-->
$(NoWarn),1573,1591,1712
+
+ $(MSBuildThisFileDirectory)artifacts\$(MSBuildProjectName)\
diff --git a/playground/mongo/Mongo.AppHost/Program.cs b/playground/mongo/Mongo.AppHost/Program.cs
index 0b347e63849..7e98ad985ff 100644
--- a/playground/mongo/Mongo.AppHost/Program.cs
+++ b/playground/mongo/Mongo.AppHost/Program.cs
@@ -4,7 +4,9 @@
var builder = DistributedApplication.CreateBuilder(args);
var db = builder.AddMongoDB("mongo")
+#if !SKIP_DASHBOARD_REFERENCE
.WithMongoExpress(c => c.WithHostPort(3022))
+#endif
.PublishAsContainer();
builder.AddProject("api")
diff --git a/tests/Aspire.Playground.Tests/AppHostTests.cs b/tests/Aspire.Playground.Tests/AppHostTests.cs
index c612c6c6288..48825cee877 100644
--- a/tests/Aspire.Playground.Tests/AppHostTests.cs
+++ b/tests/Aspire.Playground.Tests/AppHostTests.cs
@@ -6,6 +6,7 @@
using System.Text.RegularExpressions;
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Tests.Utils;
+using Aspire.Workload.Tests;
using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.DependencyInjection;
using Polly.Timeout;
@@ -19,12 +20,24 @@ namespace Aspire.Playground.Tests;
public class AppHostTests
{
- private readonly ITestOutputHelper _testOutput;
+ private readonly TestOutputWrapper _testOutput;
private static readonly string? s_appHostNameFilter = Environment.GetEnvironmentVariable("TEST_PLAYGROUND_APPHOST_FILTER");
+ private static readonly string s_appHostBasePath = ComputeAppHostBasePath();
+
+ private static string ComputeAppHostBasePath()
+ {
+ var appHostBasePath = Path.Combine(AppContext.BaseDirectory, "playground", "artifacts");
+ if (!Directory.Exists(appHostBasePath))
+ {
+ appHostBasePath = Path.Combine(AppContext.BaseDirectory);
+ }
+
+ return appHostBasePath;
+ }
public AppHostTests(ITestOutputHelper testOutput)
{
- _testOutput = testOutput;
+ _testOutput = new TestOutputWrapper(testOutput);
}
[Theory]
@@ -49,7 +62,11 @@ public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints)
var appHostName = testEndpoints.AppHost!;
var resourceEndpoints = testEndpoints.ResourceEndpoints!;
- var appHostPath = $"{appHostName}.dll";
+ // FIXME: find this path or set it outside
+ _testOutput.WriteLine($"Looking for app host '{appHostName}' in '{s_appHostBasePath}'");
+ var appHostPath = Directory.EnumerateFiles(s_appHostBasePath, $"{appHostName}.dll", SearchOption.AllDirectories).Single();
+
+ // var appHostPath = Path.Combine(_appHostBasePath, appHostName, "bin", "Debug", "net8.0", $"{appHostName}.dll");
var appHost = await DistributedApplicationTestFactory.CreateAsync(appHostPath, _testOutput);
var projects = appHost.Resources.OfType();
await using var app = await appHost.BuildAsync();
@@ -200,13 +217,13 @@ public static IList GetAllTestEndpoints()
resourceEndpoints: new() { { "apiservice", ["/alive", "/health"] } }),
// Issue: https://github.com/dotnet/aspire/issues/5274
- //new TestEndpoints("Mongo.AppHost",
- //resourceEndpoints: new() { { "api", ["/alive", "/health", "/"] } },
- //waitForTexts: [
- //new ("mongo", "Waiting for connections"),
+ new TestEndpoints("Mongo.AppHost",
+ resourceEndpoints: new() { { "api", ["/alive", "/health", "/"] } },
+ waitForTexts: [
+ new ("mongo", "Waiting for connections"),
//new ("mongo-mongoexpress", "Mongo Express server listening"),
- //new("api", "Application started.")
- //]),
+ new("api", "Application started.")
+ ]),
new TestEndpoints("MySqlDb.AppHost",
resourceEndpoints: new() { { "apiservice", ["/alive", "/health", "/catalog"] } },
waitForTexts: [
@@ -306,9 +323,9 @@ public static TheoryData TestEndpoints()
private static IEnumerable GetPlaygroundAppHostAssemblyPaths()
{
- // All the AppHost projects are referenced by this project so we can find them by looking for all their assemblies in the base directory
- return Directory.GetFiles(AppContext.BaseDirectory, "*.AppHost.dll")
- .Where(fileName => !fileName.EndsWith("Aspire.Hosting.AppHost.dll", StringComparison.OrdinalIgnoreCase));
+ return Directory
+ .EnumerateFiles(s_appHostBasePath, "*.AppHost.dll", SearchOption.AllDirectories)
+ .Where(fileName => !fileName.EndsWith("Aspire.Hosting.AppHost.dll", StringComparison.OrdinalIgnoreCase));
}
}
diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj
index 67930e243a9..af3934add6a 100644
--- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj
+++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj
@@ -3,29 +3,22 @@
$(NetCurrent)
-
- true
-
true
true
- staging-archive\
-
$(TestArchiveTestsDirForBuildOnHelixTests)
-
- $(MSBuildThisFileDirectory)..\..\playground\
- $(MSBuildThisFileDirectory)..\Shared\
$(MSBuildThisFileDirectory).runsettings
-
-
-
+
+
+
+
+
@@ -34,34 +27,62 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_RunScriptCommand Include="#!/usr/bin/env bash" />
+ <_RunScriptCommand Include="export TestsRunningOutsideOfRepo=true" />
+ <_RunScriptCommand Include="export SkipDashboardProjectReference=true" />
+ <_RunScriptCommand Include="dotnet build -bl:$HELIX_WORKITEM_UPLOAD_ROOT/logs/build-playground-apps.binlog build-playground-apps.proj && dotnet test Aspire.Playground.Tests.dll -s .runsettings --ResultsDirectory:${HELIX_WORKITEM_UPLOAD_ROOT}/logs" />
+
+
+
+
+
+
diff --git a/tests/Aspire.Playground.Tests/Infrastructure/DistributedApplicationTestFactory.cs b/tests/Aspire.Playground.Tests/Infrastructure/DistributedApplicationTestFactory.cs
index cfcdf3e4d60..120d6cb8c93 100644
--- a/tests/Aspire.Playground.Tests/Infrastructure/DistributedApplicationTestFactory.cs
+++ b/tests/Aspire.Playground.Tests/Infrastructure/DistributedApplicationTestFactory.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Reflection;
@@ -37,10 +37,6 @@ public static async Task CreateAsync(stri
builder.Services.AddLogging(logging =>
{
logging.ClearProviders();
- logging.AddSimpleConsole(configure =>
- {
- configure.SingleLine = true;
- });
logging.AddFakeLogging();
if (testOutput is not null)
{
diff --git a/tests/Aspire.Playground.Tests/build-playground-apps.proj b/tests/Aspire.Playground.Tests/build-playground-apps.proj
new file mode 100644
index 00000000000..df3499a0a05
--- /dev/null
+++ b/tests/Aspire.Playground.Tests/build-playground-apps.proj
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ <_AppHostProject Include="playground\**\*AppHost.csproj" />
+
+
+
+
+
+
+
+
diff --git a/tests/Aspire.Playground.Tests/xunit.runner.json b/tests/Aspire.Playground.Tests/xunit.runner.json
new file mode 100644
index 00000000000..6a881a7a913
--- /dev/null
+++ b/tests/Aspire.Playground.Tests/xunit.runner.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
+ "diagnosticMessages": true,
+ "longRunningTestSeconds": 120,
+ "parallelizeAssembly": false,
+ "parallelizeTestCollections": false
+}
diff --git a/tests/Shared/WorkloadTesting/TestOutputWrapper.cs b/tests/Shared/WorkloadTesting/TestOutputWrapper.cs
index 90592eda92d..09711fb4902 100644
--- a/tests/Shared/WorkloadTesting/TestOutputWrapper.cs
+++ b/tests/Shared/WorkloadTesting/TestOutputWrapper.cs
@@ -7,14 +7,14 @@
namespace Aspire.Workload.Tests;
-public class TestOutputWrapper(ITestOutputHelper? testOutputHelper = null, IMessageSink? messageSink = null) : ITestOutputHelper
+public class TestOutputWrapper(ITestOutputHelper? testOutputHelper = null, IMessageSink? messageSink = null, bool alwaysWriteToConsole = false) : ITestOutputHelper
{
public void WriteLine(string message)
{
testOutputHelper?.WriteLine(message);
messageSink?.OnMessage(new DiagnosticMessage(message));
- if (EnvironmentVariables.ShowBuildOutput)
+ if (alwaysWriteToConsole || EnvironmentVariables.ShowBuildOutput)
{
Console.WriteLine(message);
}
@@ -24,7 +24,7 @@ public void WriteLine(string format, params object[] args)
{
testOutputHelper?.WriteLine(format, args);
messageSink?.OnMessage(new DiagnosticMessage(string.Format(CultureInfo.CurrentCulture, format, args)));
- if (EnvironmentVariables.ShowBuildOutput)
+ if (alwaysWriteToConsole || EnvironmentVariables.ShowBuildOutput)
{
Console.WriteLine(format, args);
}
diff --git a/tests/helix/send-to-helix-buildonhelixtests.targets b/tests/helix/send-to-helix-buildonhelixtests.targets
index 1488f77ecb9..504145c3466 100644
--- a/tests/helix/send-to-helix-buildonhelixtests.targets
+++ b/tests/helix/send-to-helix-buildonhelixtests.targets
@@ -14,6 +14,7 @@
+
@@ -32,7 +33,7 @@
<_TestBlameArguments Include="--blame-crash-dump-type full" />
- <_TestRunCommandArguments Include="dotnet test -s .runsettings --results-directory $(_HelixLogsPath)" />
+ <_TestRunCommandArguments Include="dotnet test -s .runsettings --results-directory $(_HelixLogsPath) -v n" />
<_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" />
@@ -54,7 +55,8 @@
$(_EnvVarSetKeyword) "TEST_NAME=%(FileName)" $(_ShellCommandSeparator) $(_EnvVarSetKeyword) "$(_SetPathEnvVar)"
- cd tests/%(FileName) %3B $(_TestRunCommand)
+
+ chmod +x RunTests.sh; ./RunTests.sh
00:15:00
00:25:00
diff --git a/tests/helix/send-to-helix-ci.proj b/tests/helix/send-to-helix-ci.proj
index f83854ac1f2..10e74c82a2c 100644
--- a/tests/helix/send-to-helix-ci.proj
+++ b/tests/helix/send-to-helix-ci.proj
@@ -1,10 +1,10 @@
-
+
-
-
+
+