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] Workload tests #4168

Merged
merged 39 commits into from
May 21, 2024
Merged

[tests] Workload tests #4168

merged 39 commits into from
May 21, 2024

Conversation

radical
Copy link
Member

@radical radical commented May 13, 2024

This adds Aspire.Workload.Tests which are meant to exercise the aspire workload. The individual tests create projects from templates just like a user would, and then run, and validate them.

It uses the existing infrastructure from Aspire.EndToEnd.Tests to install sdk+workload for testing.

  • Enables tests on Linux, and Windows
  • Because we don't have docker support on helix/Windows yet, the docker dependent tests are skipped on windows

Tests

Two kinds of tests are being added here:

  1. Tests that create+build a aspire-starter template project, and then some tests interact with that running app to validate it
  2. Individual tests exercise the various templates, for example to create aspire-starter with [xunit,nunit,mstest] options
  • The tests also connect to the dashboard and validate that the expected services show up as expected using Playwright.
  • Some tests also connect to the webapp in aspire-starter template to validate some parts of it.

Fixes #47 .

Follow up work is tracked in #4222

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-components Issues pertaining to Aspire Component packages label May 13, 2024
@radical radical force-pushed the workload-tests-prep branch 2 times, most recently from df23466 to abd154e Compare May 14, 2024 06:46
radical added 11 commits May 16, 2024 18:04
- also, deploy the chromium browser for helix
  - for this we use a `PlaywrightWrapper` project to invoke to run
    `Main` for `Playwright` and use it to provision the browser.
This can be used to prepare a shell environment for using the
sdk+workload from `artifacts/bin/dotnet-latest`.

`$ source /path-to-aspire-repo/dogfood.sh`
@@ -0,0 +1,28 @@
if [ -z "$ZSH_VERSION" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

NIT: should probably have #!/usr/bin/env bash at the top line of this script.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I don't see in other scripts in the repo us checking if you are using Bash or Zsh, is there a reason why we need that here?

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 meant to be used like source dogfood.sh, so that wouldn't be appropriate AFAIU.

Copy link
Member Author

Choose a reason for hiding this comment

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

${BASH_SOURCE[0]} is not supported in zsh.

Copy link
Member

Choose a reason for hiding this comment

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

I see, I think that having it be a .sh will be misleading then if the intent is to do source dogfood.sh. Just curious, why not make it an actual bash script that can be executed? Here is precedent of a very similar use cas in the sdk repo: https://github.com/dotnet/sdk/blob/main/eng/dogfood.sh

Copy link
Member Author

Choose a reason for hiding this comment

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

If the script is run as /foo/dogfood.sh then the changes to the environment will be limited to that script. The documentation in sdk also suggests using source dogfood.sh:

https://github.com/dotnet/sdk/blob/9e277c9ce470d35ee4ebe751a5629be8688f5037/documentation/project-docs/developer-guide.md?plain=1#L108

When using source .. we are using the current shell to run the commands so the shebang should be not be needed, AFAIU.

dogfood.sh Outdated Show resolved Hide resolved
dogfood.sh Outdated Show resolved Hide resolved
@radical radical marked this pull request as ready for review May 16, 2024 22:41
The template generators can handle odd characters in the project name,
so this isn't needed anymore.
.. and instead use a pre-generated `runtimeconfig.json` to directly run
`Microsoft.Playwright.dll`.

Based on feedback from @ eerhardt .

<RunTestsOnHelix>true</RunTestsOnHelix>
<TestUsingWorkloads>true</TestUsingWorkloads>
<InstallWorkloadForTesting>true</InstallWorkloadForTesting>
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
<InstallWorkloadForTesting>true</InstallWorkloadForTesting>

I don't think this is needed, since it defaults to TestUsingWorkloads

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't default to TestUsingWorkloads.

The workload testing targets install two sdks - dotnet-latest, and dotnet-none. The former has the manifest+workload installed, but that latter has only the manifest installed. It is useful for running tests that want to check the case the user does not have the workload installed.

The TestUsingWorkloads property essentially controls that. I'll open a PR in dotnet/runtime to rename this property so its purpose is clearer. And possibly clean this up a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tracking in #4222 .

</Exec>

<PropertyGroup>
<_Regex>^\s*(Aspire.Workload.Tests[^\($]+)</_Regex>
Copy link
Member

Choose a reason for hiding this comment

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

What happens if a new test gets added that doesn't follow this naming? Does the test just get skipped and never executed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah :/ I'll open an issue to make this more robust.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tracking in #4222 .

{
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
{
if (!RequiresDockerTheoryAttribute.IsSupported)
Copy link
Member

Choose a reason for hiding this comment

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

(not necessarily for this PR) - it would be nice if we had a consolidated "RequiresDocker" story across all our tests. This feels pretty spread out - some in Aspire.Components.Common.Tests, some here, some in Aspire.Hosting.Tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tracking in #4222 .

radical and others added 6 commits May 20, 2024 16:22
This was used for inserting a source for the locally built nugets. But this was changed to instead have `<add key="built-local" value="%BUILT_NUGETS_PATH%" />` so the path comes from the environment variable `BUILT_NUGETS_PATH` now, and we can avoid needing to patch the nuget.config.
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.

Nice work here @radical! Let's get this in and we can iterate on it as we go.

@radical radical merged commit 2c430b4 into dotnet:main May 21, 2024
8 checks passed
@radical radical deleted the workload-tests-prep branch May 21, 2024 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-components Issues pertaining to Aspire Component packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for templates
3 participants