-
Notifications
You must be signed in to change notification settings - Fork 745
Add aspire test command with pytest support and auxiliary backchannel infrastructure
#13275
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mitchdenny <[email protected]>
aspire test command with feature flag
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13275Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13275" |
|
@copilot Now that we have this basic plumbing in place. Create a minimal version of the logic in TestCommand based on logic in the |
…channel Co-authored-by: mitchdenny <[email protected]>
Implemented in commit 89545b3. The TestCommand now:
Added |
|
@copilot introduce a new API to the Aspire.Hosting.Python package called In addition to wrapping a call to AddPythonExecutable(...) it should add a new annotation called TestResourceAnnotation (defined in Aspire.Hosting). For now this is just a marker annotation which will be expanded on more later. Then to the auxillary backchannel in the apphost add a method called GetTestResultsAsync(...) which will be a new RPC method. The GetTestResultsAsync call will scan through the apphost looking for all resources that have a TestResourceAnnotation and wait for them to enter a completed state (using the ResourceNotificationService). Then add another RPC method to the auxillary backchannel which is StopAppHostAsync(...). This fires off a background task which waits for the RPC channel to disconnect and then calls IHostApplicationLifetime.StopApplication(...) for an orderly shutdown of the apphost. Introduce a new |
…ncements - Add TestResourceAnnotation marker in Aspire.Hosting - Add AddPytest extension method to Aspire.Hosting.Python - Add GetTestResultsAsync and StopAppHostAsync RPC methods to AuxiliaryBackchannelRpcTarget - Create IAuxiliaryBackchannel interface and AuxiliaryBackchannel implementation - Update AuxiliaryBackchannelMonitor to use IAuxiliaryBackchannel - Add TestResults and TestResourceResult to shared backchannel data types Co-authored-by: mitchdenny <[email protected]>
Implemented in commit c5c4890. Changes include: 1. TestResourceAnnotation - Marker annotation in Aspire.Hosting to identify test resources 2. AddPytest - Extension method in Aspire.Hosting.Python: builder.AddPytest("api-tests", "../api")
.WithArgs("-v", "tests/");Wraps AddPythonExecutable and adds TestResourceAnnotation 3. Auxiliary Backchannel RPC Methods:
4. IAuxiliaryBackchannel interface and AuxiliaryBackchannel implementation - Encapsulates all RPC communication between CLI and AppHost 5. Updated AuxiliaryBackchannelMonitor - Now uses IAuxiliaryBackchannel and stores it in AppHostConnection All components build successfully and are ready for use by the test command. |
aspire test command with feature flagaspire test command with pytest support and auxiliary backchannel infrastructure
|
@copilot connect to the apphost using the auxillary backchannel and call the get test results RPC. Also ... at the moment the AuxillaryBackchannel is swallowing exceptions. Allow the exceptions to bubble out for now. |
…sync - Remove exception swallowing from AuxiliaryBackchannel - let exceptions bubble up - Update TestCommand to connect to auxiliary backchannel socket - Call GetTestResultsAsync to wait for test resources to complete - Call StopAppHostAsync to shut down the AppHost after tests complete - Display test results to user - Fix test that creates AppHostConnection to include backchannel parameter Co-authored-by: mitchdenny <[email protected]>
Implemented in commit 4498c67. Changes:
All tests pass. |
…mmand-to-cli' into copilot/add-test-command-to-cli
Description
Introduces the
aspire testcommand that will launch the AppHost, run test resources to completion, and shutdown. This PR implements the command infrastructure, DI plumbing, execution logic with full auxiliary backchannel integration, and the supporting infrastructure for test resource management and AppHost lifecycle control.Changes
CLI Command Infrastructure
testCommandEnabledtoKnownFeatures.cs(disabled by default)TestCommandwith complete execution logic that:IProjectLocatorIDotNetCliRunner.RunAsyncwith backchannel connectionGetTestResultsAsync()via auxiliary backchannel to wait for test resources to completeStopAppHostAsync()via auxiliary backchannel for orderly AppHost shutdown--projectoption to specify the AppHost project file pathTestCommandStrings.resxwith localization for description, status messages, and option descriptionsProgram.cs) and test (CliTestHelper.cs) containersTestCommandTests.cswith 4 tests covering help, feature flag visibility, and project discoveryTest Resource Support (Aspire.Hosting)
AddPythonExecutableto run pytest from the virtual environmentTestResourceAnnotationto mark the resource as a testAuxiliary Backchannel Enhancements
GetTestResultsAsync: Scans for resources withTestResourceAnnotation, waits for them to reach finished state usingResourceNotificationService, and returns test resultsStopAppHostAsync: Initiates orderly shutdown of the AppHost viaIHostApplicationLifetime.StopApplication()IAuxiliaryBackchannelinstances instead of direct RPC callsTestResultsandTestResourceResultclasses toBackchannelDataTypes.csUsage
Example AppHost with pytest
When executed via
aspire test, the command will:GetTestResultsAsync()which waits for the pytest resource to completeStopAppHostAsync()to shut down the AppHostFixes #(issue)
Checklist
<remarks />and<code />elements on your triple slash comments?Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.