Skip to content

[WCF] Skip ServiceHost tests if non-elevated #2824

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martincostello
Copy link
Member

Changes

  • Skip TelemetryContextPropagatesTest if the tests are run as a non-elevated user.
  • Move ServiceHost setup to its own class and use per-test so that the operation is deferred until after the skip check has determined that the test should run.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 11:56
@martincostello martincostello requested a review from a team as a code owner June 9, 2025 11:56
@github-actions github-actions bot added the comp:instrumentation.wcf Things related to OpenTelemetry.Instrumentation.Wcf label Jun 9, 2025
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.75%. Comparing base (71655ce) to head (85b44e8).
Report is 880 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2824      +/-   ##
==========================================
+ Coverage   73.91%   78.75%   +4.83%     
==========================================
  Files         267       29     -238     
  Lines        9615      706    -8909     
==========================================
- Hits         7107      556    -6551     
+ Misses       2508      150    -2358     
Flag Coverage Δ
unittests-Instrumentation.Wcf 78.75% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 266 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@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 PR updates the WCF instrumentation tests to skip TelemetryContextPropagatesTest when running without admin rights and defers ServiceHost initialization until after the skip check by extracting it into a per-test context.

  • Introduces RunAsAdminTheoryAttribute to conditionally skip tests based on admin privileges.
  • Removes inline ServiceHost setup in the test class and adds a new ServiceHostContext helper.
  • Updates TelemetryPropagationTests to use ServiceHostContext for URIs.

Reviewed Changes

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

File Description
test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryPropagationTests.netfx.cs Replaced [Theory] with [RunAsAdminTheory], removed constructor/dispose host setup, added ServiceHostContext.
test/OpenTelemetry.Instrumentation.Wcf.Tests/RunAsAdminTheoryAttribute.cs Added a new theory attribute to skip tests when not running as an administrator.
Comments suppressed due to low confidence (2)

test/OpenTelemetry.Instrumentation.Wcf.Tests/RunAsAdminTheoryAttribute.cs:10

  • [nitpick] The summary refers to this as a “fact” but it inherits from TheoryAttribute. Update the XML comment to mention it’s a theory-based test attribute for clarity.
/// Attribute that is applied to a method to indicate that it is a fact that should be run by the test runner

test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryPropagationTests.netfx.cs:154

  • [nitpick] The ServiceHost property on ServiceHostContext isn’t used by the tests—consider removing it to reduce the public API surface.
public ServiceHost ServiceHost => this.serviceHost;

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jun 17, 2025
@martincostello martincostello force-pushed the wcf-skip-if-non-elevated branch from 71da70c to 8c38d56 Compare June 17, 2025 05:54
@github-actions github-actions bot removed the Stale label Jun 18, 2025
- Skip `TelemetryContextPropagatesTest` if the tests are run as a non-elevated user.
- Move ServiceHost setup to its own class and use per-test so that the operation is deferred until after the skip check has determined that the test should run.
@martincostello martincostello force-pushed the wcf-skip-if-non-elevated branch from 8c38d56 to 85b44e8 Compare June 18, 2025 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.wcf Things related to OpenTelemetry.Instrumentation.Wcf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant