Skip to content

Migrate to xunit.v3 #8403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Apr 2, 2025
Merged

Migrate to xunit.v3 #8403

merged 46 commits into from
Apr 2, 2025

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Mar 29, 2025

Description

Re-creating the PR after some work on Arcade is done to support xunit.v3 extensions.

The number of jobs you have is too large to have a complete comparison. But taking few random samples:

Two runs used for comparison:

Job and step Before After Number of tests before Number of tests after
Setup for tests (Linux) - enumerate tests 36s 34s 54 54
Setup for tests (Windows) - enumerate tests 2m 19s 2m 8s 33 33
Integrations Linux (Azure.AI.OpenAI) / Azure.AI.OpenAI - run tests 14s 28s 113 113
Integrations Linux (Azure.Data.Tables) / Azure.Data.Tables - run tests 20s 21s 41 41
Integrations Linux (Azure.Messaging.EventHubs) / Azure.Messaging.EventHubs - run tests 4s 5s 242 242
Integrations Linux (Azure.Messaging.ServiceBus) / Azure.Messaging.ServiceBus - run tests 27s 28s 76 76
Integrations Linux (Azure.Messaging.WebPubSub) / Azure.Messaging.WebPubSub - run tests 34s 41s 48 48
Integrations Linux (Azure.Npgsql) / Azure.Npgsql - run tests 13s 17s 55 55
EndToEnd - Run nuget dependent tests 52s 41s 4 4

NOTE: I'm comparing a single run before vs a single run after. There might already be high variance as every job is running really small number of tests. So numbers are unlikely to be meaningful here.

NOTE 2: There are 3 test failures that need to be looked at. The failures are similar so the root cause is the same. It might be related to how the test assembly is loaded causing working directory to be different or something.

Fixes # (issue)

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?

@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label Mar 29, 2025
@danmoseley
Copy link
Member

14->28s would be problematic if it's real. Could you maybe do repeat measurement to check whether it's normal variation?

@Youssef1313
Copy link
Member Author

@danmoseley I just looked at another "before" build (https://github.com/dotnet/aspire/actions/runs/14140547808/job/39621122075?pr=8392) and that's 26s.

So looks like there is large variance already between runs that wouldn't make measurements here easy/useful. This is probably normal because the number of tests being run in each job is too small already.

@Youssef1313
Copy link
Member Author

Youssef1313 commented Mar 30, 2025

@danmoseley For the change in one of the test results, I detailed the reason in the commit message (c325772)

This test used to pass with VSTest and xunit v2 because the tests were run under testhost.exe.

So, DistributedApplicationOptions.Assembly was pointing to testhost. Then ResolveProjectDirectory wouldn't correctly find AppHostProjectPath. In DistributedApplicationBuilder constructor, we were falling back to _innerBuilder.Environment.ContentRootPath because ProjectDirectory is null.

With xunit.v3 *or* MTP, generally when the test app is executed as normal executable, we have the right assembly and we are able to resolve project directory correctly
@Youssef1313
Copy link
Member Author

The test EndToEndLoggingTest look like it's incorrectly authored. It's currently written as follows

        logger.LoggedMessage = () =>
        {
            // wait for at least 2 logs to be written
            if (logger.Logs.Count >= 2)
            {
                tsc.SetResult();
            }
        };

If we got a third log message, that will crash because the Task already completed.

@Youssef1313 Youssef1313 marked this pull request as ready for review March 31, 2025 06:50
@Copilot Copilot AI review requested due to automatic review settings March 31, 2025 06:50
@@ -33,6 +33,11 @@

<DashboardPublishedArtifactsOutputDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'DashboardArtifacts', '$(Configuration)'))</DashboardPublishedArtifactsOutputDir>
<WorkloadsPackageSource>$(ArtifactsShippingPackagesDir)</WorkloadsPackageSource>

<!-- xUnit2031: Do not use Where clause with Assert.Single -->
Copy link
Member

Choose a reason for hiding this comment

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

Why are we disabling this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

@radical I wanted to avoid extra changes in this PR to keep it minimal. But I think it can be addressed later. I see you are already tracking it now in the follow-up issue.

radical added 2 commits April 1, 2025 18:20
# Conflicts:
#	tests/Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL.Tests/EnrichNpgsqlTests.cs
@radical
Copy link
Member

radical commented Apr 2, 2025

@danmoseley @eerhardt @joperezr @RussKie Any objections, or concerns about this?

@radical
Copy link
Member

radical commented Apr 2, 2025

I have merged main, and fixed the new QuarantineTestAttribute . cc @RussKie

@@ -0,0 +1,18 @@
<Project>
Copy link
Contributor

Choose a reason for hiding this comment

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

@Youssef1313 is there a reason this isn't done at the Arcade level?

Copy link
Member Author

@Youssef1313 Youssef1313 Apr 2, 2025

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

But you will need to wait until you are using latest Arcade 10 anyways

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome!

Copy link
Contributor

@RussKie RussKie left a comment

Choose a reason for hiding this comment

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

Overall 👍

@radical
Copy link
Member

radical commented Apr 2, 2025

Copy link
Member

@radical radical left a comment

Choose a reason for hiding this comment

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

Thank you for working on this! Great contribution :) LGTM 👍

@radical
Copy link
Member

radical commented Apr 2, 2025

But do wait for the azdo build to be green too, before merging.

@Youssef1313
Copy link
Member Author

Thanks @radical. I'll merge once all is green (including AzDO build) then.

@Youssef1313
Copy link
Member Author

All is green. I re-confirmed the number of tests between the build in this PR and the previous build are the same on AzDO (8,986).

@Youssef1313 Youssef1313 merged commit cba3a47 into dotnet:main Apr 2, 2025
178 of 180 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-engineering-systems infrastructure helix infra engineering repo stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants