Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Add Aspire.Playground.Tests #5208

Merged
merged 23 commits into from
Aug 9, 2024

Conversation

radical
Copy link
Member

@radical radical commented Aug 7, 2024

Add wrapper tests for apps in playground/.

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 .

Microsoft Reviewers: Open in CodeFlow

radical added 8 commits August 6, 2024 21:33
.. to disambiguate the project binaries in `artifacts`
Playground apps add a reference to the Dashboard project for local
debugging. Skip that when building for tests.
.. with test infrastructure
(`tests/Aspire.Playground.Tests/Infrastructure/`) taken from aspire-samples repo.
.. under a new category - `buildforhelixtests`. This is for any tests
that expect to build the tests project itself on helix, and then run it
there.
.. props file. This allows project builds where test packages are added
by default to work by providing the package versions for those packages.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Aug 7, 2024
@radical radical added testing ☑️ area-engineering-systems infrastructure helix infra engineering repo stuff and removed area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication labels Aug 7, 2024
@radical radical marked this pull request as ready for review August 7, 2024 02:20
@radical radical requested a review from eerhardt as a code owner August 7, 2024 02:20
@mitchdenny
Copy link
Member

As part of this it would be good to ensure that the the content of aspire-manifest.json has not changed in each of the playground projects. We want to detect if the apphost is generating a manifest different to what is checked in so that we can identify changes that we didn't intend (it also helps with the review process).

@radical radical mentioned this pull request Aug 7, 2024
35 tasks
@radical
Copy link
Member Author

radical commented Aug 7, 2024

As part of this it would be good to ensure that the the content of aspire-manifest.json has not changed in each of the playground projects. We want to detect if the apphost is generating a manifest different to what is checked in so that we can identify changes that we didn't intend (it also helps with the review process).

Added to #5210

tests/Aspire.Playground.Tests/README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this copy of this file? Can we use the default one in the root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to allow the source being buildable from outside the repo, as we wouldn't have eng/testing/.runsettings available there.

The alternative would be to copy it for the archive, and also have a <RunSettingsFilePath Condition="'$(RepoRoot)' == ''">$(MSBuildThisFileDirectory).runsettings</RunSettingsFilePath>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just have the root .runsettings file checked into the repo, and then the infrastructure copies it to the correct place in the helix payload?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will get covered by the follow up task of building on the build machine, and only running on helix.

tests/helix/send-to-helix-inner.proj Outdated Show resolved Hide resolved
tests/helix/send-to-helix-buildonhelixtests.targets Outdated Show resolved Hide resolved
tests/helix/send-to-helix-buildonhelixtests.targets Outdated Show resolved Hide resolved
<Compile Include="$(TestsSharedDir)WorkloadTesting\EnvironmentVariables.cs" />
<Compile Include="$(TestsSharedDir)Logging\*.cs" />

<AspireProjectOrPackageReference Include="Aspire.Hosting" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we rebuild the Aspire.Playground.Tests in Helix? If so, why? Why don't we build this project on the build machine, and then run the already built tests on Helix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think this can be reworked so this project builds on the build machine. Then we can build the playground projects on helix, and point the tests to the bindir for these.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need some reworking. I have added it as a follow up task in #5210 . We can get the tests checked-in before that.

Comment on lines +31 to +37
<ProjectReference Include="$(PlaygroundSourceDir)ProxylessEndToEnd/ProxylessEndToEnd.AppHost/ProxylessEndToEnd.AppHost.csproj" AdditionalProperties="SkipDashboardProjectReference=true" />
<ProjectReference Include="$(PlaygroundSourceDir)Qdrant/Qdrant.AppHost/Qdrant.AppHost.csproj" AdditionalProperties="SkipDashboardProjectReference=true" />
<ProjectReference Include="$(PlaygroundSourceDir)TestShop/TestShop.AppHost/TestShop.AppHost.csproj" AdditionalProperties="SkipDashboardProjectReference=true" />
<ProjectReference Include="$(PlaygroundSourceDir)mongo/Mongo.AppHost/Mongo.AppHost.csproj" AdditionalProperties="SkipDashboardProjectReference=true" />
<ProjectReference Include="$(PlaygroundSourceDir)mysql/MySqlDb.AppHost/MySqlDb.AppHost.csproj" AdditionalProperties="SkipDashboardProjectReference=true" />
<ProjectReference Include="$(PlaygroundSourceDir)nats/Nats.AppHost/Nats.AppHost.csproj" AdditionalProperties="SkipDashboardProjectReference=true" />
<ProjectReference Include="$(PlaygroundSourceDir)seq/Seq.AppHost/Seq.AppHost.csproj" AdditionalProperties="SkipDashboardProjectReference=true" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only some of these? Why not all?

Should we do it like the aspire-samples does it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because not all of them work right now. Issues like #5219, #5218, some of the projects requiring azure creds, some failing with other issues that need to be investigated.

@@ -12,6 +12,7 @@

var app = builder.Build();

app.MapDefaultEndpoints();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually interesting that we weren't calling this in the past but we were Adding Service Defaults. Do you happen to know why? Why do we need it now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need it to get the /alive, and /health endpoints being used by the tests. When running it manually, it wasn't useful I'm guessing.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work, @radical. Nice job.

Let's get this in and get more tests enabled.

<!-- Import only when in-repo. For the out-of-repo case a parent Directory.Build.targets does the import -->
<Import Project="$(TestsSharedRepoTestingDir)Aspire.RepoTesting.targets" Condition="'$(RepoRoot)' != ''" />

<PropertyGroup Condition="'$(TestsRunningOutsideOfRepo)' == 'true' or '$(SkipDashboardProjectReference)' == 'true'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<PropertyGroup Condition="'$(TestsRunningOutsideOfRepo)' == 'true' or '$(SkipDashboardProjectReference)' == 'true'">
<PropertyGroup Condition="'$(SkipDashboardProjectReference)' == 'true'">

When are these tests running outside of the repo and SkipDashboardProjectReference is not set?

</PropertyGroup>

<ItemGroup>
<Compile Condition="'$(RepoRoot)' != ''" Include="$(RepoRoot)src\Aspire.Hosting\Utils\PasswordGenerator.cs" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this build when RepoRoot isn't set? WithRandomParameterValues needs this code in order to build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We copy the source to the test directory in the archive for helix, so it gets picked up by msbuild as part of collecting the all .cs files.


public AppHostTests(ITestOutputHelper testOutput)
{
this._testOutput = new TestOutputWrapper(testOutput);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this TestOutputWrapper? Why can't we use the ITestOutputHelper directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful to see the output streaming to testOutputHelper when the test run might be taking long. But in the case of these tests most of the output is being logged to the console anyway, so we can drop this.


public AppHostTests(ITestOutputHelper testOutput)
{
this._testOutput = new TestOutputWrapper(testOutput);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit)

Suggested change
this._testOutput = new TestOutputWrapper(testOutput);
_testOutput = new TestOutputWrapper(testOutput);

@radical
Copy link
Member Author

radical commented Aug 9, 2024

Merging this, and will open follow up PRs for the suggestions.

@radical radical merged commit a7f23ec into dotnet:main Aug 9, 2024
11 checks passed
@radical radical deleted the playground-tests-helix branch August 9, 2024 18:31
radical added a commit that referenced this pull request Aug 9, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-engineering-systems infrastructure helix infra engineering repo stuff testing ☑️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants