-
Notifications
You must be signed in to change notification settings - Fork 540
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 support for running EndToEnd tests on helix with the aspire
workload
#2534
Conversation
- add a xunit.runner.json, .runsettings - update tests to skip resources as needed - update test fixture to work with sdk+workload for testing
- reference workload.testing nuget from dotnet/runtime - Extra some workload properties needed to a Workload.props, used in more than once place now - Microsoft.NET.Sdk.Aspire: set `PackageType=''` to the manifest nuget is not `dotnetplatform`, and can be installed directly by the workload testing tasks.
TODO:
|
Talked offline with @radical, marking as ready for review as this is ready for feedback. |
</packageSources> | ||
<packageSourceMapping> | ||
<!-- used for installing test workloads for resolving aspire workload manifest --> | ||
<packageSource key="nuget-local"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this package source defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it does seem odd that you can't directly see what this links up to in the repo. I can have the package source name be passed to the task, which would be in aspire repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this throw a warning at all on the initial restore before the task has a chance to replace the source? Did we also consider manually passing in -s <path>
to a manual invocation of restore instead of having this in the config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No warnings. Wouldn't -s path
only add a package source but not the mapping, and because of that restoring from the source would fail. That is what I hit when I removed this mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once dotnet/runtime#99277 is merged this entry can be removed, and it would be added at build time.
<HelixPreCommand Condition="'$(OS)' == 'Windows_NT'" Include="set SDK_FOR_WORKLOAD_TESTING_PATH=%HELIX_CORRELATION_PAYLOAD%\%SDK_DIR_NAME%" /> | ||
<HelixPreCommand Condition="'$(OS)' != 'Windows_NT'" Include="export SDK_FOR_WORKLOAD_TESTING_PATH=$HELIX_CORRELATION_PAYLOAD/$SDK_DIR_NAME" /> | ||
|
||
<HelixPreCommand Condition="'$(OS)' == 'Windows_NT'" Include="set TestsRunningOutOfTree=true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how much I like the term "running out of tree". I think there are 2 things about it I don't like:
- I think I'd rather use the term "repo" than "tree".
- "Running out of" actually makes it sound like that's where the tests are from. Like the phrase "fighting out of the blue corner".
Possible suggestions:
TestingOutsideOfSourceRepo
TestsNotInRepo
TestsNotContainedInRepo
I think at a minimum change OutOf
to OutsideOf
and I'll be OK with the name. TestsRunningOutsideOfTree
<!-- no docker support on helix/windows yet --> | ||
<RunTestsOnHelix Condition="'$(OS)' != 'Windows_NT'">true</RunTestsOnHelix> | ||
<SkipTests Condition="'$(OS)' == 'Windows_NT'">true</SkipTests> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just say RunTestsOnHelix=true
all the time, and then do these checks inside the tests? Similar to how I did it in RabbitMQ in #2345. It just feels cleaner that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can do it like that also. The reason for "also" is that if we don't have any tests that would get run, then not skipping the whole thing would mean:
- installing sdk+workload - extra step on CI
- sending this work item to helix with the big payload (sdk) for nothing to run, which dnceng kinda frowns upon.
I think we can add the attributes also, and for the specific case (windows) where nothing can run, we skip in the project file too. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How long until we are able to run these tests on Windows?
|
||
<BuiltNuGetsDir>$(ArtifactsShippingPackagesDir)</BuiltNuGetsDir> | ||
<PackageVersionForWorkloadManifests>$(PackageVersion)</PackageVersionForWorkloadManifests> | ||
<DefineConstants Condition="'$(TestsRunningOutOfTree)' == 'true'">TESTS_RUNNING_OUT_OF_TREE;$(DefineConstants)</DefineConstants> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get this from an env var when the test runs so we don't have to have an #if
in the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add this just for the VS run, so you need to set only one property in one file to have the tests switch.
Using env var works perfectly well when running from command line, but I don't know what the workflow can be for setting it in case of VS. Open to suggestions.
-t:InstallWorkloadUsingArtifacts | ||
-bl:${{ parameters.repoLogPath }}/WorkloadInstallForTesting.binlog | ||
$(Build.SourcesDirectory)/tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it weird to pick the EndToEnd tests to have this "InstallWorkloadUsingArtifacts" target? It seems like something that should be coming from an "infrastructure" project. Not one of the test projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking of fixing it in a follow up though. But I can try to do it here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep this for a follow up PR, unless you think it should be done here itsefl
|
||
public class TestProgram : IDisposable | ||
{ | ||
private TestProgram(string[] args, Assembly assembly, bool includeIntegrationServices, bool includeNodeApp, bool disableDashboard) | ||
{ | ||
if (args.Contains("--disable-dashboard")) | ||
IList<TestResourceNames> resourcesToSkip = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need this resourcesToSkip
? If we just skipped the cosmos and oracle tests, wouldn't that be enough? Yes it would still spin up those containers during the tests, but nothing would try to connect to them.
I don't really like all these if conditions everywhere. It really clutters up the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have one test that health checks on the whole thing, and that would continue to fail.
I don't really like all these if conditions everywhere. It really clutters up the code.
agree!
…review.3.24151.4)
# Conflicts: # NuGet.config
@@ -10,8 +10,6 @@ | |||
<VSTemp>$(WorkloadIntermediateOutputPath)VS/</VSTemp> | |||
<WorkloadOutputPath>$(ArtifactsBinDir)workloads/</WorkloadOutputPath> | |||
<WorkloadOutputPath Condition="'$(workloadArtifactsPath)' != ''">$(workloadArtifactsPath)/</WorkloadOutputPath> | |||
<PackageSource>$(ArtifactsShippingPackagesDir)</PackageSource> | |||
<PackageSource Condition="'$(workloadPackagesPath)' != ''">$(workloadPackagesPath)/</PackageSource> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that this cannot get overriden any longer? cc: @danegsta in case he is aware if we depend on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does $(workloadPackagesPath)
get set? I didn't find any reference to it in the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine as long as the workload still builds correctly
@eerhardt I tried to add oracledb back, but it failed because the test timeout was 5minutes. I think we continue with that in a follow up PR, so reverting that change. |
@@ -26,7 +26,7 @@ | |||
|
|||
<Target Name="Build" /> | |||
|
|||
<Target Name="BeforeBuild" BeforeTargets="Build"> | |||
<Target Name="BeforeBuild" BeforeTargets="_GetPackageFiles"> |
There was a problem hiding this comment.
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 change? In general, it's best to avoid depending on "private" tragets (Targets that start with an underscore)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to limit this target to only when we are generating a nuget.
Is this target needed only for generating the zip file? Is the zip file used for the dashboard docker image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This target mainly accomplishes two things:
- Adds the right content to the each of the dashboard packs (which actually may no longer be needed now that we have the dashboard as a tool) cc: @danegsta
- Zips up the published output as that will be uploaded as a blob so that it can then be used to build the docker image for the dashboard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
@@ -21,6 +21,7 @@ parameters: | |||
steps: | |||
- script: ${{ parameters.buildScript }} | |||
-restore -build | |||
-pack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already running pack as a separate step (check line 98 in this file). Can we either change the ordering so that happens before the steps that run the tests, or alternatively just remove that whole step if it is no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This pack could conflict with the subsequent pack, since that one is signed. I will investigate this in a separate PR. And it will really be needed only when we have this running on windows again.
For now, I will add -pack
only for linux, where the separate pack
step is not defined at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few comments/suggestions but the rest LGTM.
https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#targetsfortfmspecificcontentinpackage addresses review feedback from @ joperezr
…eview feedback from @ joperezr
Follow-up work is being tracked in #2687 . |
…et stuck waiting for i t
# Conflicts: # tests/testproject/TestProject.IntegrationServiceA/Program.cs
Problem:
We want to run some EndToEnd tests on CI, which can
dotnet run
an aspire project,and allow individual tests to interact with the services.
This requires:
aspire
workload installed.docker
Also, allow using
TestProject.*
intests/testproject
, in two modes:in-tree
test run which directly reference aspire projects, and repo targetsout-of-tree
test runs which uses a SDK+workload based on local build outputSolution:
SDK+workload
global.json
is installed intoartifacts/bin/dotnet-{none,latest}
aspire
workload is installed into the sdk using the nuget packages inartifacts/packages
with a version like8.0.0-{dev,ci}
dotnet new aspire-starter; dotnet run
same as a userdotnet/runtime
TestProject
$(TestsRunningOutsideRepo)
in-tree
the test project directly references hosting targets, and aspire projects viaProjectReference
out-of-tree
theProjectReferences
and imports are replaced withPackageReferences
to the Aspire nugetsin-tree
Helix
dotnet
from the sdk+workload pathdocker
is needed to helix, this is enabled only forLinux
in this PR. Blocked on Needdocker
installed on the helix images for Windows, to allow individual tests to create containers dnceng#2067 for windows support.TL;dr or How do I use this?
Steps to prepare for
out-of-tree
runs.\build.cmd -pack
- to build all the nugetsdotnet build tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.csproj /t:InstallWorkloadUsingArtifacts /p:Configuration=<config>
aspire
workload using the nugets fromartifacts/packages
artifacts/packages/$(Configuration)/Shipping
as a nuget source so the locally built packages can be picked up.Using it from VS
in-tree
modeout-of-tree
add<TestsRunningOutsideRepo>true</TestsRunningOutsideRepo>
totests/Aspire.EndToEnd.Tests/Directory.props
before any imports.artifacts/bin/dotnet-latest
being missingAspire.EndToEnd.Tests
, so a path likeartifacts/bin/Aspire.EndToEnd.Tests/Debug/net8.0/testassets/testproject/
Using it from command line
in-tree
mode<TestsRunningOutsideRepo>true</TestsRunningOutsideRepo>
totests/Aspire.EndToEnd.Tests/Directory.props
before any importsTestsRunningOutsideRepo=true
Other details
tests/Shared/WorkloadTesting
- has sources essentially fromdotnet/runtime
'sWasm.Build.Tests
--skip-resources oracledatabase,cosmos
.runsettings
with 15min timeoutxunit.runner.json
- to get diagnostic messagesAspire.EndToEnd.Tests
, and will get used by other test projects in the futureMicrosoft Reviewers: Open in CodeFlow