Skip to content

Add an option to set DCP log file name suffix based on test name #9088

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 1 commit into from
May 5, 2025

Conversation

karolz-ms
Copy link
Member

Description

Adds a DCP option that allows DCP log names to reflect the test that launched the specific DCP instance (and leverages it for DistributedApplicationTests). With this change DCP log names follow the following format

`<"dcp" or "dcpctrl">-<unique instance id>-<test name>.log`

for example dcp-12345678-proxyless-endpoint-works.log (for proxyless-endpoint-works test), making it very easy to correlate between test under investigation and corresponding DCP log file.

The environment variable that this change is using is not effective yet with the DCP version that is integrated into Aspire, but it will become effective with the next DCP insertion.

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-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label May 3, 2025
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.

Pull Request Overview

This pull request adds an option to allow DCP log files to incorporate the test name into their suffix, making it easier to correlate logs with specific tests.

  • Test program now sets the "LogFileNameSuffix" configuration based on the test name.
  • DcpOptions is updated with a new nullable property and corresponding documentation.
  • DcpHost now uses the new option to add an environment variable if the suffix is provided.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/testproject/TestProject.AppHost/TestProgram.cs Adds a new configuration entry for log file suffix
src/Aspire.Hosting/Dcp/DcpOptions.cs Introduces the LogFileNameSuffix property and documentation
src/Aspire.Hosting/Dcp/DcpHost.cs Applies the new option to set an environment variable for DCP logging
Comments suppressed due to low confidence (1)

tests/testproject/TestProject.AppHost/TestProgram.cs:57

  • [nitpick] Consider adding unit or integration tests to verify that the log file name suffix is correctly propagated and applied, ensuring the expected log file naming format is maintained.
builder.Configuration["DcpPublisher:LogFileNameSuffix"] = testName;

@@ -54,6 +54,7 @@ private TestProgram(
builder.Configuration["DcpPublisher:ResourceNameSuffix"] = $"{Random.Shared.Next():x}";
builder.Configuration["DcpPublisher:RandomizePorts"] = randomizePorts.ToString(CultureInfo.InvariantCulture);
builder.Configuration["DcpPublisher:WaitForResourceCleanup"] = "true";
builder.Configuration["DcpPublisher:LogFileNameSuffix"] = testName;
Copy link
Member

Choose a reason for hiding this comment

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

Do we have an issue for doing this in more places?

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 do not think we do. Do you want me to open one?

Copy link
Member

Choose a reason for hiding this comment

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

Yep. This is a very specific test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Created #9106 to track that work

@davidfowl davidfowl merged commit 7ae0762 into main May 5, 2025
171 checks passed
@davidfowl davidfowl deleted the dev/karolz/dcp-log-files branch May 5, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

2 participants