aspire icon indicating copy to clipboard operation
aspire copied to clipboard

[tests] Failing test on CI - `DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource`

Open radical opened this issue 1 year ago • 5 comments

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:

Run date Test Name
Apr 26 6 PM [windows] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 6 PM [linux] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 4 PM [windows] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 4 PM [linux] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 2 PM [windows] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 2 PM [linux] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 12 PM [windows] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 12 PM [linux] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 10 AM [windows] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource
Apr 26 10 AM [linux] Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessAndProxiedEndpointBothWorkOnSameResource

-- Updated on 4/29/2025 6:21:23 PM UTC

Summary

Last 40 Total failed / total runs
5 130 / 165

radical avatar Jun 19 '24 21:06 radical

@radical Do we still need this issue?

davidfowl avatar Sep 15 '24 18:09 davidfowl

@radical Do we still need this issue?

Yeah, looks like the test is still disabled.

radical avatar Sep 16 '24 18:09 radical

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

davidfowl avatar Jan 13 '25 07:01 davidfowl

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

radical avatar Apr 08 '25 07:04 radical

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.

radical avatar Apr 25 '25 21:04 radical