[tests] Failing test on CI - `DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource`
https://github.com/dotnet/aspire/pull/4500 enables extra Aspire.Hosting.Tests to run on the build machine. Prior to this they were never run on CI.
Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource fails because the first client.GetStringAsync($"{httpEndPoint}urls" returned only the http endpoint. But the second invocation got both http, and https. Adding a sufficient delay before hitting the /urls endpoints makes the test pass though.
The tests have an existing class for the hook which I tried to use here - https://gist.github.com/radical/7ef257229178c36f6b72ffd09f7e0b79#file-test-cs-L22-L27
But running the test with CWLs added to print the results from /urls:
Got urls from http://localhost:1234/urls: ["http://localhost:1234"]
Got urls from https://localhost:57048/urls: ["http://localhost:1234","https://localhost:57051"]
The first call is missing the https endpoint. Did the AfterEndpointsAllocatedAsync get invoked too early? Or am I missing something else?
(related thread: https://github.com/dotnet/aspire/pull/4500#discussion_r1639055442) cc @ReubenBond @DamianEdwards @eerhardt
Build Information
Build: Build error leg or test failing: Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource Pull request:
Error Message
Fill the error message using step by step known issues guidance.
{
"ErrorMessage": "Expected: \"[\"http://localhost:1234\"]\"",
"ErrorPattern": "",
"BuildRetry": false,
"ExcludeConsoleLog": true
}
Last 10 failures:
-- Updated on 4/29/2025 6:21:23 PM UTC
Summary
| Last 40 | Total failed / total runs |
|---|---|
| 5 | 130 / 165 |
@radical Do we still need this issue?
@radical Do we still need this issue?
Yeah, looks like the test is still disabled.
OK I spent some time and figured this one out. The tests are just racy because kestrel binds to the input addresses and mutates the collection as its doing so. We can use health checks to wait for both to be bound (which is the cleaner solution) or look at ASPNETCORE_URLS
In the last 54 runs 54 failed. Listing last 10 failures:
| Run date | Outcome |
|---|---|
| Apr 8 6 AM | Failed |
| Apr 8 6 AM | Failed |
| Apr 8 4 AM | Failed |
| Apr 8 2 AM | Failed |
| Apr 8 2 AM | Failed |
| Apr 8 12 AM | Failed |
| Apr 8 12 AM | Failed |
| Apr 7 10 PM | Failed |
| Apr 7 10 PM | Failed |
| Apr 7 8 PM | Failed |
After the fix in #8958 the reason for the failure is now - System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot.