Skip to content

Conversation

danmoseley
Copy link
Member

Description

MySql test was timing out here and it seemed almost all the 2 mins was pulling the mysql docker image.

await app.WaitForTextAsync(s_mySqlReadyText).WaitAsync(TimeSpan.FromMinutes(2));

  1. Change MySql tests to have a single timeout using a ct, so they're easier to reason about.
  2. Change the ct timeout to something similar in terms of a new ExtraLongTimeout, so it can be changed centrally.
  3. Make ExtraLongTimeout longer on CI.

It's super hard to reason about whether timeouts are too long or not. They're everywhere in the tests. But it probably makes sense to convert tests to have an overall timeout like this so they're easier to reason about, and to centralize the value to some extent.

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?
    • [x ] 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?

@Copilot Copilot AI review requested due to automatic review settings April 3, 2025 22:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • tests/Aspire.Hosting.MySql.Tests/Aspire.Hosting.MySql.Tests.csproj: Language not supported
Comments suppressed due to low confidence (2)

tests/Aspire.Hosting.MySql.Tests/MySqlFunctionalTests.cs:69

  • [nitpick] Multiplying a TimeSpan directly by an integer is not supported in standard C#. If an operator overload is defined for this, consider making the conversion explicit or introducing a helper method for clarity.
var ct = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan * 2).Token;

tests/Aspire.Hosting.MySql.Tests/MySqlFunctionalTests.cs:69

  • [nitpick] Consider defining a named constant (e.g., 'DoubleExtraLongTimeout') instead of multiplying the ExtraLongTimeoutTimeSpan inline. This can improve readability and consistency across tests.
var ct = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan * 2).Token;

@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Apr 3, 2025
@danmoseley
Copy link
Member Author

danmoseley commented Apr 3, 2025

MySql test was timing out here and it seemed almost all the 2 mins was pulling the mysql docker image.

Hmm, except that line is waiting for sql ready before starting the 2 min clock. Hmm, well, still good cleanup.. maybe I misread the logs

@danmoseley
Copy link
Member Author

@radical

@danmoseley danmoseley enabled auto-merge (squash) April 4, 2025 18:13
@@ -453,7 +454,7 @@ public async Task MySql_WithPersistentLifetime_ReusesContainers(bool useMultiple
// it generates and mounts a config.user.inc.php file instead of using environment variables.
// For this reason we need to test with and without multiple instances to cover both scenarios.

var cts = new CancellationTokenSource(TimeSpan.FromMinutes(10));
using var cts = new CancellationTokenSource(TestConstants.ExtraLongTimeoutTimeSpan * 2);
Copy link
Member

Choose a reason for hiding this comment

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

On CI this would be a 12min timeout, is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did this because it was 10 mins already. Now either 6 mins locally or 12 mins in CI. @sebastienros I assume you picked such a large timeout for a reason..?

Copy link
Member

Choose a reason for hiding this comment

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

10 minutes? probably to be sure it has enough time to run on the (slow) CI since it starts multiple containers serially. I haven't checked but obviously we can pick whatever the value is from normal runs on the CI + some margin.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK I think this is fine as is -- maybe eventually we have some script that adjusts each test's timeouts to match CI * margin. But right now, most tests don't even have a single timeout.

Copy link
Member Author

Choose a reason for hiding this comment

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

can you sign off if OK?

@danmoseley danmoseley merged commit a98ccc2 into dotnet:main Apr 7, 2025
174 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 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.

4 participants