Skip to content

[Testing] Remove ResourceNameSuffix randomization#7378

Merged
ReubenBond merged 1 commit intomainfrom
rebond/testing-persistent-containers
Feb 3, 2025
Merged

[Testing] Remove ResourceNameSuffix randomization#7378
ReubenBond merged 1 commit intomainfrom
rebond/testing-persistent-containers

Conversation

@ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Feb 3, 2025

Description

Aspire.Hosting.Testing currently adds a random suffix to resource names to reduce the chance of clashes when running tests in parallel. This is no longer necessary, as @karolz-ms points out, since DCP includes its own distinguisher. This PR disables resource name suffix randomization.

Users can still randomize resource name suffixes themselves by passing a random suffix to DistributedApplicationTestingBuilder like so:

var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.TestingAppHost1_AppHost>([$"DcpPublisher:ResourceNameSuffix={Random.Shared.Next():x}"]);
await using var app = await appHost.BuildAsync();
await app.StartAsync();

For context, see: #6891 (comment)

Fixes #6891
Fixes #6850

I verified that this addresses the above issue by running the Aspire.Hosting.Testing.Tests suite locally. I don't feel we need a specific unit test for this behavior at this time.

Before this change:

image

After this change:

image

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@ReubenBond ReubenBond force-pushed the rebond/testing-persistent-containers branch from caa1550 to 7e48482 Compare February 3, 2025 00:24
@ReubenBond ReubenBond changed the title [WIP] [Testing] Remove ResourceNameSuffix randomization [Testing] Remove ResourceNameSuffix randomization Feb 3, 2025
@ReubenBond ReubenBond enabled auto-merge (squash) February 3, 2025 01:08
@davidfowl
Copy link
Member

Looked into the test failure, looked unrelated. We should use the Build Analysis tab to file the issue and just merge next time 😄

@ReubenBond ReubenBond merged commit f28df8e into main Feb 3, 2025
65 checks passed
@ReubenBond ReubenBond deleted the rebond/testing-persistent-containers branch February 3, 2025 03:11
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2025
@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persistent container recreated in every test run Allow DistributedApplicationTestingBuilder to override WithLifetime(ContainerLifetime.Persistent)

3 participants