Repository navigation
Fix DistributedApplicationTestingBuilder dashboard with dynamic ports - #17729
David Fowler (davidfowl) merged 2 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17729Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17729" |
There was a problem hiding this comment.
Pull request overview
Fixes DistributedApplicationTestingBuilder startup failures when the Aspire dashboard is enabled and the testing defaults use http:// endpoints, by defaulting ASPIRE_ALLOW_UNSECURED_TRANSPORT to true in the testing factory and adding a regression test that waits for the dashboard resource to become healthy.
Changes:
- Default
ASPIRE_ALLOW_UNSECURED_TRANSPORT=trueinDistributedApplicationFactory.PreConfigureBuilderOptionsto avoidTransportOptionsValidatorfailures with HTTP defaults. - Add a Docker-gated regression test that enables the dashboard and waits for the
aspire-dashboardresource to become healthy. - Include shared
AsyncTestHelpersin the test project to useDefaultTimeout(...)/TestConstants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Testing.Tests/TestingBuilderTests.cs | Adds regression test for dashboard-enabled testing builder scenarios. |
| tests/Aspire.Hosting.Testing.Tests/Aspire.Hosting.Testing.Tests.csproj | Links shared AsyncTestHelpers.cs into the test project. |
| src/Aspire.Hosting.Testing/DistributedApplicationFactory.cs | Defaults ASPIRE_ALLOW_UNSECURED_TRANSPORT to true for testing builder defaults that use HTTP. |
|
James Newton-King (@JamesNK) target release/13.4 |
…ed with dynamic ports When users set DisableDashboard = false on DistributedApplicationTestingBuilder, the TransportOptionsValidator rejected the HTTP URLs that the testing builder defaults (http://localhost:8080, http://localhost:4317) because ASPIRE_ALLOW_UNSECURED_TRANSPORT was not set. Fix: Set AllowUnsecuredTransport = true by default in PreConfigureBuilderOptions, since all URLs are already defaulted to HTTP. Add a regression test that enables the dashboard and verifies it becomes healthy. Fixes #17622
53a6b58 to
5cb3e2e
Compare
|
/backport to release/13.4 |
|
Started backporting to |
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
3f17cf3 to
20c2b87
Compare
|
❓ CLI E2E Tests unknown — 110 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26699662675 |
|
✅ No documentation update needed. docs_optional → No signals triggered (signal_count: 0). This PR is a bug fix that corrects internal behavior in |
Fixes #17622
Summary
When
DistributedApplicationTestingBuilderenables the dashboard (either explicitly or by default in the future), the resource service gRPC host fails to start if the endpoint uses a loopback IP with port 0 (dynamic port). This is because Kestrel'sListenLocalhost(0)throws "Dynamic port binding is not supported when binding to localhost."Changes
DistributedApplicationFactory.csAllowUnsecuredTransporttotruein testing scenarios. The testing builder defaults dashboard URLs to HTTP, butTransportOptionsValidatorrejects HTTP without this flag.DashboardServiceHost.cs127.0.0.1,::1), useListen(IPAddress, port)directly instead ofListenLocalhost(port). This supports port 0 for dynamic binding.ListenLocalhostforlocalhost/*.localhosthostnames (which bind both IPv4+IPv6 but don't support port 0).ArgumentExceptionfor non-local addresses.internal static IsLocalResourceServiceEndpointmethod (replaced by inline logic and a privateIsLocalhostOrLocalhostTldhelper).Tests
DashboardEnabledInTestingBuilderShouldWorkWithDynamicPorts- verifies dashboard starts with default dynamic port configuration.LoopbackWithDynamicPortstheory - verifies explicit127.0.0.1:0and[::1]:0endpoints work.NonLocalResourceServiceEndpointThrows- verifies non-local addresses are rejected.IsLocalResourceServiceEndpoint_ReturnsExpectedResulttest (method no longer exists).