Unified test runner: "eventType: sdam" expectEvents ignores ServerDescriptionChangedEvent

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • backpressure-1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Java Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      The Java unified test runner (driver-sync/.../UnifiedTest.java:423-451) handles expectEvents with eventType: sdam by partitioning expected events into two buckets: topology vs everything else. The "everything
      else" bucket is then asserted against TestServerMonitorListener.getEvents(), which only captures heartbeat events.

      ServerDescriptionChangedEvent is captured by a separate listener, TestServerListener (reachable via entities.getServerListener(clientId).getServerDescriptionChangedEvents()), which the runner never consults
      for eventType: sdam. As a result, any spec test that places a serverDescriptionChangedEvent inside an eventType: sdam expectEvents block always compares expected-non-empty against actual-empty and fails with
      "Number of events must be the same. expected:<N> but was:<0>".

      First test that exercises this path: testing/resources/specifications/source/server-discovery-and-monitoring/tests/unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml
      (introduced by DRIVERS-3218). This test asserts the CMAP backpressure invariant "the server description is not changed on handshake error during minPoolSize population" via a single expectEvents → eventType:
      sdam → [{ serverDescriptionChangedEvent: {} }]. It's currently skipped in Java under JAVA-5949 (pending this fix) via UnifiedTestModifications.java.

      Peer-driver comparison:

      • Node.js: single sdamEvents[] array on UnifiedMongoClient, populated by registering listeners for all SDAM events directly on the MongoClient (test/tools/unified-spec-runner/entities.ts, NODE-4534,
        2022-08-24). No gap.
      • .NET: single per-client EventCapturer with .Capture<ServerDescriptionChangedEvent>() + heartbeat types; UnifiedEventMatcher.FilterEventsBySetType(events, "sdam") partitions by bucket
        (tests/.../UnifiedEventMatcher.cs, CSHARP-4227, 2023-02-25). No gap.

      Java is the only outlier; the bug is long-standing (predates the backpressure spec) but only now exercised by a committed spec test.

      Repro:
      1. Remove the skip for backpressure-server-description-unchanged-on-min-pool-size-population-error in UnifiedTestModifications.java.
      2. ./gradlew :driver-sync:test --tests "UnifiedServerDiscoveryAndMonitoringTest*backpressure-server-description-unchanged" on a standalone 7.0+ server.
      3. Observe: AssertionError: Number of events must be the same. expected:<1> but was:<0>.

            Assignee:
            Nabil Hachicha
            Reporter:
            Nabil Hachicha
            Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: