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

CXX-3208 update SDAM monitoring tests following mongo-c-driver a91d6f6a #1332

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eramongodb
Copy link
Collaborator

@eramongodb eramongodb commented Feb 12, 2025

Followup to #1331 which overlooked an update to SDAM Monitoring behavior as part of CDRIVER-3775:

sdam-monitoring.cpp:181: failed: new_type == "Single" for: "Unknown" == "Single"

Specifically due to mongodb/mongo-c-driver#1842, which included the following change(s):

* Fies for lifecycle events generated for Structured Log and APM consumers:
  * ServerOpeningEvent is deferred based on topology 'opening' state, not based on when callbacks are installed.
  * Required ServerClosedEvent and topology Unknown state changes are emitted prior to TopologyClosedEvent.

This PR proposes simply ignoring the Unknown topology description state during the "Topology Events" assertions, as AFAIK there is not a deterministic way to know in advance that a particular TopologyDescriptionChanged event is specifically due to server monitoring shutdown without significant refactoring of the SDAM Monitoring test case (e.g. we likely do not want to hardcode assumptions about the number of members in the replica set).

The Catch2 v3 CHECKED_IF macro is used for improved test debugging experience and verify runtime behavior (example output is paraphrased to reduce verbosity):

$ ./test_driver --reporter compact --success --section "Topology Events" "SDAM Monitoring"
Filters: "SDAM Monitoring"
RNG seed: [...]
...
sdam-monitoring.cpp:176: passed: new_type != "Unknown" for: "ReplicaSetNoPrimary" != "Unknown"
sdam-monitoring.cpp:181: passed: new_type == "ReplicaSetNoPrimary" for: "ReplicaSetNoPrimary" == "ReplicaSetNoPrimary"
...
sdam-monitoring.cpp:176: passed: new_type != "Unknown" for: "ReplicaSetWithPrimary" != "Unknown"
sdam-monitoring.cpp:179: passed: new_type == "ReplicaSetWithPrimary" for: "ReplicaSetWithPrimary" == "ReplicaSetWithPrimary"
...
sdam-monitoring.cpp:176: passed: new_type != "Unknown" for: "ReplicaSetWithPrimary" != "Unknown"
sdam-monitoring.cpp:179: passed: new_type == "ReplicaSetWithPrimary" for: "ReplicaSetWithPrimary" == "ReplicaSetWithPrimary"
...
sdam-monitoring.cpp:176: passed: new_type != "Unknown" for: "ReplicaSetWithPrimary" != "Unknown"
sdam-monitoring.cpp:179: passed: new_type == "ReplicaSetWithPrimary" for: "ReplicaSetWithPrimary" == "ReplicaSetWithPrimary"
...
sdam-monitoring.cpp:176: failed - but was ok: new_type != "Unknown" for: "Unknown" != "Unknown"
...
sdam-monitoring.cpp:221: passed: topology_opening_events > 0 for: 1 > 0
sdam-monitoring.cpp:222: passed: topology_changed_events > 0 for: 5 > 0
sdam-monitoring.cpp:223: passed: topology_closed_events > 0 for: 1 > 0
sdam-monitoring.cpp:224: passed: found_servers for: true
All tests passed (56 assertions in 1 test case)

AFAICT this is the first use of the Catch2 v3 CHECKED_IF macro in the test suite. It was present in Catch2 v2, but negative conditions were treated as an assertion failure rather than simply a recorded result.

No other changes appear to be necessary.

@eramongodb eramongodb self-assigned this Feb 12, 2025
Copy link
Contributor

@mdbmes mdbmes left a comment

Choose a reason for hiding this comment

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

Looks good to me. We could do more to include test coverage for the lifecycle events if we wanted, but this is clearly an improvement. I noticed the comment about ServerClosedEvent isn't true any more: "// We don't expect a ServerClosedEvent unless a replica set member is removed." (It should be emitted before the close of topology monitoring)

@eramongodb
Copy link
Collaborator Author

I noticed the comment about ServerClosedEvent isn't true any more [...] it should be emitted before the close of topology monitoring.

Thank you for the suggestion. Replaced the obsolete comment with new assertions which mirror those which already exist for the TopologyClosedEvent for completeness.

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.

2 participants