Skip to content

test(hosting): fix Outerloop tests asserting null proxyless EffectivePort - #18249

Closed
Ankit Jain (radical) wants to merge 1 commit into
microsoft:mainfrom
radical:radical/fix-outerloop-null-endpoint-port
Closed

test(hosting): fix Outerloop tests asserting null proxyless EffectivePort#18249
Ankit Jain (radical) wants to merge 1 commit into
microsoft:mainfrom
radical:radical/fix-outerloop-null-endpoint-port

Conversation

@radical

Copy link
Copy Markdown
Member

The Outerloop Tests workflow fails every scheduled night (7/7 this week, flagged in #18223). Two [OuterloopTest] + Docker-required Hosting tests fail deterministically on the Hosting (8-core-ubuntu-latest) job and pass on windows-latest:

  • Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessContainerCanBeReferenced
  • Aspire.Hosting.Tests.DistributedApplicationTests.WithEndpointProxySupportDisablesProxies

Both fail the same way:

Assert.IsType() Failure: Value is null
Expected: typeof(int)
Actual:   null
  at Aspire.Hosting.Tests.DistributedApplicationTests.AssertAllocatedProxylessPort(Service service)
  at Aspire.Hosting.Tests.DistributedApplicationTests.ProxylessContainerCanBeReferenced() line 1835

Root cause

Both tests assert on the redisNoPort proxyless service's Status.EffectivePort. PR #17924 ("Add proxyless endpoint port allocator") made Aspire pre-assign the proxyless host port synchronously (Service.Spec.Port) and intentionally excluded proxyless services from the startup address-wait in DcpExecutor — connection strings are built from the Aspire-assigned Spec.Port, which is available immediately, so startup need not block on DCP echoing the bound port.

DCP still reports that port back asynchronously via Status.EffectivePort. After StartAsync() and the app responding, DCP may not yet have populated EffectivePort for the proxyless service. The fast 8-core Linux runner reads the service list before that update lands → null; Windows lands the update first → pass. The unit-test fake sets EffectivePort = Spec.Port synchronously, so unit tests never hit the race.

This is a test bug, not a product regression — the orchestrator behavior is correct by design.

The fix

Test-side only. Both tests now wait for the proxyless service to report a non-null Status.EffectivePort (using KubernetesHelper.GetResourceByNameAsync, the existing watch-based waiter already used elsewhere in this file) before running AssertAllocatedProxylessPort, instead of asserting against a once-fetched service list. This preserves the end-to-end check that DCP actually bound the Aspire-assigned port. No product code changes.

Call-outs

  • WithEndpointProxySupportDisablesProxies is not yet tracked by an issue; it shares the exact same root cause and is fixed by the same change.
  • Validated on Linux in a Docker container (the environment that fails in CI): both tests fail with the verbatim null error before the change and pass (2/2, ~41s) after it.
  • No product code touched; DcpExecutor's intentional proxyless exclusion is unchanged.

Fixes #8773

ProxylessContainerCanBeReferenced and WithEndpointProxySupportDisablesProxies
([OuterloopTest], Docker-required) failed every scheduled Outerloop run on the
Hosting (8-core-ubuntu-latest) job while passing on Windows:

    Assert.IsType() Failure: Value is null
    Expected: typeof(int)
    Actual:   null
      at ...AssertAllocatedProxylessPort(Service service) line 2319
      at ...ProxylessContainerCanBeReferenced() line 1835

Both assert on the redisNoPort proxyless service's Status.EffectivePort.
PR microsoft#17924 made Aspire pre-assign the proxyless host port synchronously
(Service.Spec.Port) and deliberately excluded proxyless services from the
startup address-wait in DcpExecutor, since connection strings use the
Aspire-assigned Spec.Port immediately. DCP still echoes the bound port back
asynchronously via Status.EffectivePort. On a fast Linux agent the test reads
the service list before DCP populates EffectivePort, so the assertion sees
null; on Windows the update lands first, so it passes. The unit-test fake sets
EffectivePort = Spec.Port synchronously, hiding the race.

Fix is test-side: wait for the proxyless service to report a non-null
EffectivePort (via KubernetesHelper.GetResourceByNameAsync, the existing
watch-based waiter) before asserting, instead of reading a once-fetched
service list. No product change - the orchestrator behavior is correct.

Fixes microsoft#8773

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 18:58
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18249

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18249"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes two deterministically failing [OuterloopTest] tests on Linux CI (ProxylessContainerCanBeReferenced and WithEndpointProxySupportDisablesProxies) that fail because DCP hasn't yet populated Service.Status.EffectivePort when the test assertion runs. The root cause is that PR #17924 intentionally excluded proxyless services from the DCP startup address-wait (since connection strings use the synchronously-assigned Spec.Port), but the tests asserted against EffectivePort from a one-shot list fetch, creating a race condition on fast Linux CI agents.

Changes:

  • Replaced the synchronous GetEndpointService(serviceList, ...) helper with a new WaitForAllocatedProxylessServiceAsync that uses the existing watch-based KubernetesHelper.GetResourceByNameAsync to wait until DCP populates EffectivePort.
  • Removed the now-unnecessary serviceList fetch from ProxylessContainerCanBeReferenced (the second test retains it for an unrelated Assert.All assertion).

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@radical

Copy link
Copy Markdown
Member Author

Consolidating the unapproved Outerloop test fixes into a single PR: #18250. Closing in favor of that one (same change, preserved authorship).

@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.5 milestone Jun 16, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Failing test]: ProxylessContainerCanBeReferenced

2 participants