Skip to content
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

Test proxy logs - sanitizer info #9164

Merged
merged 26 commits into from
Nov 1, 2024

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Oct 14, 2024

Test Proxy Logs - Impacted recordings and sanitizers

Introducing improvements to the test proxy logging in terms of which sanitizers are applied and how.
Key changes below:

Main changes

  1. RecordEntry.cs

    • Added Clone method to create a copy of the RecordEntry, which is used primarily for sanitization logging.
  2. RecordSession.cs

    • Capturing and comparing the state of entries before and after sanitization to log sanitizer modifications.
    • Added methods to copy RecordEntry and log modifications, enhancing traceability and debugging capabilities.
  3. LoggingTests.cs

    • Enhanced AssertLogs method to include a testType parameter, adjusting the logic to handle different test types.
    • Updated PlaybackLogsSanitizedRequest and RecordingHandlerLogsSanitizedRequests tests to use the new AssertLogs method.

Impact

These changes enhance the transparency and traceability of the sanitizers in test proxy by adding detailed logging for request and response modifications. This will aid in debugging and understanding the effects of sanitizers during test sessions.

Fixes #8474

Example Output

Central sanitizer from test proxy User registered sanitizer
Output 1
Output 2

…d; update commentsAdded a ToString method to RecordEntry for string representation.Introduced logging in RecordSession to track sanitizer changes.Added SanitizerId to RecordedTestSanitizer for unique identification.Updated RegisteredSanitizer constructor to set SanitizerId.Corrected copyright comment in RequestOrResponse.cs.Added necessary using directives to RecordEntry.cs.
@HarshaNalluru HarshaNalluru changed the title Test proxy logs Test proxy logs - sanitizer info Oct 14, 2024
@HarshaNalluru HarshaNalluru marked this pull request as ready for review October 15, 2024 00:01
@scbedd
Copy link
Member

scbedd commented Oct 15, 2024

I like the idea, but we are adding a ton of workload to every single request. Every time we sanitize we write all the entries out. We have to put this behind a debug flag somehow. I'm not certain how big of an impact there will be, so my thoughts is once you get these tests resolved, I will help you get this upgrade to a branch off of azure-sdk-tools to publish it.

Easiest way to check performance of a proxy upgrade is to simply try updating the target_version.txt and see how all the repos handle it.

Copy link
Member

@scbedd scbedd 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 Harsha!

We spoke offline about fixing tests, figuring out how to put the heavier consistent tostringing behind a flag, and checking against existing libraries.

Push this to an upstream branch at your convenience so we can easily publish the results as proxy versions.

Copy link
Member

@scbedd scbedd left a comment

Choose a reason for hiding this comment

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

Overall this is pretty damn solid. I requested a couple refactors for clarity, but nothing that is crazy.

Copy link
Member

@scbedd scbedd left a comment

Choose a reason for hiding this comment

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

Please address this comment and then we're g2g aside from your ToString() todo.

Feel free to use TryGetContentAsText if you'd prefer that to relying on ToString().

Copy link
Member

@scbedd scbedd left a comment

Choose a reason for hiding this comment

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

@HarshaNalluru HarshaNalluru merged commit 266508f into Azure:main Nov 1, 2024
12 checks passed
@scbedd scbedd mentioned this pull request Nov 1, 2024
HarshaNalluru added a commit to Azure/azure-sdk-for-js that referenced this pull request Nov 25, 2024
## What's going on?

- Invocation of `test-proxy` in the `child_process` will now support
environment variables
- injects the current environment variables into the child's environment
- Added a new flag `"test-proxy-debug"` to all the test commands, which
enables debug logging for the test-proxy
- sets the environment variable `Logging__LogLevel__Default` to
`"Debug"`
- Simply setting the environment variable `Logging__LogLevel__Default`
to `"Debug"` will have the same effect as passing `test-proxy-debug`
flag to the test commands.

Related to Azure/azure-sdk-tools#9164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sanitizers log their actions
3 participants