Remove OpCounters::resetForTest()

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      As part of porting opCounters over to OTel (SERVER-118979), we want to use an otel Counter type which can never go down (not even reset for testing). So this API needed to be removed. This wasn't too hard. This patch refactors test infrastructure to use isolated OpCounters instances instead of resetting global counters, which has the nice side effects of removing global variable references.

      What changed?

      • Removed `resetForTest()` method from `OpCounters` class that was used to reset global counters
      • Modified `ClusterCommandTestFixture::testOpcountersAreCorrect()` to calculate counter deltas instead of comparing absolute values
      • Added dependency injection to `QueryAnalysisSampler::QueryStats` to accept custom `OpCounters` instances via `setOpCountersForTest()`
      • Updated test files to use isolated `OpCounters` instances rather than manipulating global state

            Assignee:
            Charlie Swanson
            Reporter:
            Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: