opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

refactor: parametrize tests

Open chickenbreeder opened this issue 4 weeks ago • 5 comments

Fixes https://github.com/open-telemetry/opentelemetry-rust/issues/1552

Changes

  • Parametrized a few tests
  • Bumped the rstest version to no longer depend on async-std by default (See: https://github.com/la10736/rstest/pull/311); this issue only occurred in the context of
#[rstest]
#[tokio::test]

Merge requirement checklist

  • [X] CONTRIBUTING guidelines followed
  • [X] Unit tests added/updated (if applicable)
  • [ ] Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • [X] Changes in public API reviewed (if applicable)

chickenbreeder avatar Nov 22 '25 11:11 chickenbreeder

CLA Signed
The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: chickenbreeder / name: chickenbreeder (a1e2f3a369eed323e3e20692943c50430dcc61b6)

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 80.7%. Comparing base (df412fe) to head (a1e2f3a).

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3256     +/-   ##
=======================================
- Coverage   80.8%   80.7%   -0.1%     
=======================================
  Files        129     129             
  Lines      23203   23167     -36     
=======================================
- Hits       18750   18714     -36     
  Misses      4453    4453             

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Nov 22 '25 11:11 codecov[bot]

I asked Claude to see if there are many others here we could pick up. Not sure how useful this is, but it's probably worth trying to pick out other instances of this pattern we can clean up!

  1. opentelemetry-zipkin/src/propagator/mod.rs:464-683
    • B3 propagator tests with extensive test data sets
    • Multiple nested loops for single/multi-header formats
    • Could consolidate 20+ test cases
  2. opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs - Multiple locations (555-664, 914-1072, 1141-1229) - Complex test data structures for bucket calculations - 30+ test cases across different test functions
  3. opentelemetry-otlp/src/retry.rs:218-495 - 10+ similar async test functions for retry logic - Each tests different scenarios (success, failure, timeout, throttling) - Perfect candidate for #[rstest] with #[case] attributes

scottgerring avatar Nov 22 '25 13:11 scottgerring

@chickenbreeder let me know when you are ready with this!

scottgerring avatar Nov 22 '25 15:11 scottgerring

Hey @chickenbreeder , did you want to do more of these, or should we review it as it is?

scottgerring avatar Dec 08 '25 14:12 scottgerring

Hey @scottgerring. Sorry, I did not get around to do any further work on this.

chickenbreeder avatar Dec 16 '25 09:12 chickenbreeder