Skip to content

Commit a7f23ec

Browse files
radicaleerhardt
andauthored
[tests] Add Aspire.Playground.Tests (#5208)
Add wrapper tests for apps in `playground/`. - The tests are based on https://github.com/dotnet/aspire-samples/blob/aee52a7a08ca3433bd1e54e8a90a7febdc852ebd/tests/SamplesIntegrationTests/AppHostTests.cs . - And test infrastructure from https://github.com/dotnet/aspire-samples/tree/aee52a7a08ca3433bd1e54e8a90a7febdc852ebd//tests/SamplesIntegrationTests/Infrastructure has been copied to the project here This effectively increases coverage for various components like Qdrant, and Seq, and their hosting bits. Details: - Skip dashboard project reference to playground apps when running building for tests - Use `MapDefaultEndpoints` to add `/alive` and `/health` endpoints needed for testing - Rename `playground/TestShop/ServiceDefaults` to `playground/TestShop/TestShop.ServiceDefaults` to disambiguate the project binaries in `artifacts` - Only a few of the playground apps are being tested here. More will be added in follow up PRs. Contributes to #4297 . Co-authored-by: Eric Erhardt <[email protected]>
1 parent 58ba5e1 commit a7f23ec

File tree

53 files changed

+854
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+854
-87
lines changed

Aspire.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "playground", "playground",
1313
playground\README.md = playground\README.md
1414
EndProjectSection
1515
EndProject
16-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceDefaults", "playground\TestShop\ServiceDefaults\ServiceDefaults.csproj", "{C7B2309C-073A-4552-A508-A69768B64C6F}"
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestShop.ServiceDefaults", "playground\TestShop\TestShop.ServiceDefaults\TestShop.ServiceDefaults.csproj", "{C7B2309C-073A-4552-A508-A69768B64C6F}"
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatalogService", "playground\TestShop\CatalogService\CatalogService.csproj", "{6D04BB34-1CC6-4FF3-A02A-1FFAC2A7A4F3}"
1919
EndProject
@@ -507,6 +507,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "python", "python", "{7123AB
507507
EndProject
508508
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.AppHost", "playground\python\Python.AppHost\Python.AppHost.csproj", "{173BDA6E-F175-4457-BF64-58CD184E9A81}"
509509
EndProject
510+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Playground.Tests", "tests\Aspire.Playground.Tests\Aspire.Playground.Tests.csproj", "{8C07B9BF-87F4-450D-92FA-E03CF763013B}"
511+
EndProject
510512
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Elasticsearch.Tests", "tests\Aspire.Hosting.Elasticsearch.Tests\Aspire.Hosting.Elasticsearch.Tests.csproj", "{62D8C73C-DAB3-4B9E-A508-34C886C374F9}"
511513
EndProject
512514
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{C424395C-1235-41A4-BF55-07880A04368C}"
@@ -1393,6 +1395,10 @@ Global
13931395
{173BDA6E-F175-4457-BF64-58CD184E9A81}.Debug|Any CPU.Build.0 = Debug|Any CPU
13941396
{173BDA6E-F175-4457-BF64-58CD184E9A81}.Release|Any CPU.ActiveCfg = Release|Any CPU
13951397
{173BDA6E-F175-4457-BF64-58CD184E9A81}.Release|Any CPU.Build.0 = Release|Any CPU
1398+
{8C07B9BF-87F4-450D-92FA-E03CF763013B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1399+
{8C07B9BF-87F4-450D-92FA-E03CF763013B}.Debug|Any CPU.Build.0 = Debug|Any CPU
1400+
{8C07B9BF-87F4-450D-92FA-E03CF763013B}.Release|Any CPU.ActiveCfg = Release|Any CPU
1401+
{8C07B9BF-87F4-450D-92FA-E03CF763013B}.Release|Any CPU.Build.0 = Release|Any CPU
13961402
{62D8C73C-DAB3-4B9E-A508-34C886C374F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13971403
{62D8C73C-DAB3-4B9E-A508-34C886C374F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
13981404
{62D8C73C-DAB3-4B9E-A508-34C886C374F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -1756,6 +1762,7 @@ Global
17561762
{D5B392A4-29CD-41F9-8847-0C211C832713} = {C424395C-1235-41A4-BF55-07880A04368C}
17571763
{7123AB7A-A4FD-4F64-8B05-D2DD0C3E2ABC} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
17581764
{173BDA6E-F175-4457-BF64-58CD184E9A81} = {7123AB7A-A4FD-4F64-8B05-D2DD0C3E2ABC}
1765+
{8C07B9BF-87F4-450D-92FA-E03CF763013B} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60}
17591766
{62D8C73C-DAB3-4B9E-A508-34C886C374F9} = {830A89EC-4029-4753-B25A-068BAE37DEC7}
17601767
{C424395C-1235-41A4-BF55-07880A04368C} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60}
17611768
{830A89EC-4029-4753-B25A-068BAE37DEC7} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60}

playground/AzureStorageEndToEnd/AzureStorageEndToEnd.AppHost/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
.WithExternalHttpEndpoints()
1414
.WithReference(blobs);
1515

16+
#if !SKIP_DASHBOARD_REFERENCE
1617
// This project is only added in playground projects to support development/debugging
1718
// of the dashboard. It is not required in end developer code. Comment out this code
18-
// to test end developer dashboard launch experience. Refer to Directory.Build.props
19-
// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output
20-
// in the artifacts dir).
19+
// or build with `/p:SkipDashboardReference=true`, to test end developer
20+
// dashboard launch experience, Refer to Directory.Build.props for the path to
21+
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
22+
// artifacts dir).
2123
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
24+
#endif
2225

2326
builder.Build().Run();
2427

playground/CosmosEndToEnd/CosmosEndToEnd.AppHost/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
.WithExternalHttpEndpoints()
1212
.WithReference(db);
1313

14+
#if !SKIP_DASHBOARD_REFERENCE
1415
// This project is only added in playground projects to support development/debugging
1516
// of the dashboard. It is not required in end developer code. Comment out this code
16-
// to test end developer dashboard launch experience. Refer to Directory.Build.props
17-
// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output
18-
// in the artifacts dir).
17+
// or build with `/p:SkipDashboardReference=true`, to test end developer
18+
// dashboard launch experience, Refer to Directory.Build.props for the path to
19+
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
20+
// artifacts dir).
1921
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
22+
#endif
2023

2124
builder.Build().Run();

playground/CustomResources/CustomResources.AppHost/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77

88
builder.AddParameter("p0");
99

10+
#if !SKIP_DASHBOARD_REFERENCE
1011
// This project is only added in playground projects to support development/debugging
1112
// of the dashboard. It is not required in end developer code. Comment out this code
12-
// to test end developer dashboard launch experience. Refer to Directory.Build.props
13-
// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output
14-
// in the artifacts dir).
13+
// or build with `/p:SkipDashboardReference=true`, to test end developer
14+
// dashboard launch experience, Refer to Directory.Build.props for the path to
15+
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
16+
// artifacts dir).
1517
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
18+
#endif
1619

1720
builder.Build().Run();

playground/DatabaseMigration/DatabaseMigration.AppHost/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
builder.AddProject<Projects.DatabaseMigration_MigrationService>("migration")
1313
.WithReference(db1);
1414

15+
#if !SKIP_DASHBOARD_REFERENCE
1516
// This project is only added in playground projects to support development/debugging
1617
// of the dashboard. It is not required in end developer code. Comment out this code
17-
// to test end developer dashboard launch experience. Refer to Directory.Build.props
18-
// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output
19-
// in the artifacts dir).
18+
// or build with `/p:SkipDashboardReference=true`, to test end developer
19+
// dashboard launch experience, Refer to Directory.Build.props for the path to
20+
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
21+
// artifacts dir).
2022
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
23+
#endif
2124

2225
builder.Build().Run();

playground/Directory.Build.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<Project>
22
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
33

4-
<!-- When $(BuildForTest)==true, importing Aspire.RepoTesting.targets is needed. But import
5-
only when in-repo. For out-of-repo a parent Directory.Build.props does the import -->
6-
<Import Project="$(TestsSharedRepoTestingDir)Aspire.RepoTesting.props" Condition="'$(RepoRoot)' != '' and '$(BuildForTest)' != 'true'" />
4+
<!-- Import only when in-repo. For out-of-repo a parent Directory.Build.props does the import -->
5+
<Import Project="$(TestsSharedRepoTestingDir)Aspire.RepoTesting.props" Condition="'$(RepoRoot)' != ''" />
76

87
<PropertyGroup>
98
<!--

playground/Directory.Build.targets

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<Project>
22
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
33

4-
<ItemGroup Condition="'$(BuildForTest)' != 'true' and '$(IsAspireHost)' == 'true' and '$(SkipDashboardProjectReference)' != 'true'">
4+
<ItemGroup Condition="'$(IsAspireHost)' == 'true' and '$(SkipDashboardProjectReference)' != 'true'">
55
<ProjectReference Include="$(RepoRoot)src\Aspire.Dashboard\Aspire.Dashboard.csproj" />
66
</ItemGroup>
77

8-
<!-- When $(BuildForTest)==true, importing Aspire.RepoTesting.targets is needed. But import
9-
only when in-repo. For the out-of-repo case a parent Directory.Build.targets does the import -->
10-
<Import Project="$(TestsSharedRepoTestingDir)Aspire.RepoTesting.targets" Condition="'$(RepoRoot)' != '' and '$(BuildForTest)' != 'true'" />
8+
<!-- Import only when in-repo. For the out-of-repo case a parent Directory.Build.targets does the import -->
9+
<Import Project="$(TestsSharedRepoTestingDir)Aspire.RepoTesting.targets" Condition="'$(RepoRoot)' != ''" />
10+
11+
<PropertyGroup Condition="'$(TestsRunningOutsideOfRepo)' == 'true' or '$(SkipDashboardProjectReference)' == 'true'">
12+
<DefineConstants>SKIP_DASHBOARD_REFERENCE;$(DefineConstants)</DefineConstants>
13+
</PropertyGroup>
1114
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Packages.Helix.props" Condition="'$(TestsRunningOutsideOfRepo)' == 'true'" />
3+
4+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Packages.props', '$(MSBuildThisFileDirectory)../'))" Condition="'$(TestsRunningOutsideOfRepo)' != 'true'" />
5+
</Project>

playground/Elasticsearch/Elasticsearch.ApiService/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
var app = builder.Build();
1414

15+
app.MapDefaultEndpoints();
1516
app.MapGet("/get", async (ElasticsearchClient elasticClient) =>
1617
{
1718
var response = await elasticClient.GetAsync<Person>("people", "1");

playground/Elasticsearch/Elasticsearch.AppHost/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
builder.AddProject<Projects.Elasticsearch_ApiService>("elasticsearch-apiservice")
1010
.WithReference(elasticsearch);
1111

12+
#if !SKIP_DASHBOARD_REFERENCE
1213
// This project is only added in playground projects to support development/debugging
1314
// of the dashboard. It is not required in end developer code. Comment out this code
14-
// to test end developer dashboard launch experience. Refer to Directory.Build.props
15-
// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output
16-
// in the artifacts dir).
15+
// or build with `/p:SkipDashboardReference=true`, to test end developer
16+
// dashboard launch experience, Refer to Directory.Build.props for the path to
17+
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
18+
// artifacts dir).
1719
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
20+
#endif
1821

1922
builder.Build().Run();

0 commit comments

Comments
 (0)