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

PYTHON-4117 Require 4.3.1+ server version when using failCommand errorLabels option #1526

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

blink1073
Copy link
Member

@blink1073 blink1073 commented Feb 16, 2024

Also fixes PYTHON-4018

@blink1073 blink1073 requested a review from a team as a code owner February 16, 2024 12:02
@blink1073 blink1073 requested review from caseyclements and removed request for a team February 16, 2024 12:02
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

One test is failing:

 [2024/02/16 04:18:28.646] =================================== FAILURES ===================================
 [2024/02/16 04:18:28.646] _ TestCommandMonitoringWriteConcernError.test_A_retryable_write_with_write_concern_errors_publishes_success_event _
 [2024/02/16 04:18:28.646] self = <test.test_command_monitoring.TestCommandMonitoringWriteConcernError testMethod=test_A_retryable_write_with_write_concern_errors_publishes_success_event>
 [2024/02/16 04:18:28.646]     def test_case(self):
 [2024/02/16 04:18:28.646] >       self.run_scenario(spec)
 [2024/02/16 04:18:28.646] test/unified_format.py:1851:
 [2024/02/16 04:18:28.646] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 [2024/02/16 04:18:28.646] test/unified_format.py:1798: in run_scenario
 [2024/02/16 04:18:28.646]     self._run_scenario(spec, uri)
 [2024/02/16 04:18:28.646] test/unified_format.py:1834: in _run_scenario
 [2024/02/16 04:18:28.646]     self.check_events(expect_events)
 [2024/02/16 04:18:28.646] test/unified_format.py:1712: in check_events
 [2024/02/16 04:18:28.646]     self.match_evaluator.match_event(event_type, expected_event, actual_events[idx])
 [2024/02/16 04:18:28.646] test/unified_format.py:872: in match_event
 [2024/02/16 04:18:28.646]     self.match_result(reply, actual.reply)
 [2024/02/16 04:18:28.646] test/unified_format.py:791: in match_result
 [2024/02/16 04:18:28.646]     return self._match_document(expectation, actual, is_root=not in_recursive_call)
 [2024/02/16 04:18:28.646] test/unified_format.py:780: in _match_document
 [2024/02/16 04:18:28.646]     self.match_result(value, actual[key], in_recursive_call=True)
 [2024/02/16 04:18:28.646] test/unified_format.py:791: in match_result
 [2024/02/16 04:18:28.646]     return self._match_document(expectation, actual, is_root=not in_recursive_call)
 [2024/02/16 04:18:28.646] test/unified_format.py:787: in _match_document
 [2024/02/16 04:18:28.646]     self.test.assertEqual(expected_keys, set(actual.keys()))
 [2024/02/16 04:18:28.646] E   AssertionError: Items in the second set but not the first:
 [2024/02/16 04:18:28.646] E   'errorLabels'
 [2024/02/16 04:18:28.646] ------------------------------ Captured log call -------------------------------
 [2024/02/16 04:18:28.646] INFO     pymongo.serverSelection:logger.py:94 {"message": "Waiting for suitable server to become available", "selector": "<function writable_server_selector at 0x7f65496abac0>", "operation": "insert", "topologyDescription": "<TopologyDescription id: 65cf50f6de68da9dcd97141c, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=WriteConcernError(\"None, full error: {'code': 91, 'errorLabels': ['RetryableWriteError']}\")>, <ServerDescription ('localhost', 27018) server_type: RSSecondary, rtt: 0.0005081769999719654>, <ServerDescription ('localhost', 27019) server_type: RSArbiter, rtt: 0.001811891000045307>]>", "clientId": {"$oid": "65cf50f6de68da9dcd97141c"}, "remainingTimeMS": 29}

https://evergreen.mongodb.com/task_log_raw/mongo_python_driver_tests_python_version_rhel8_test_ssl__platform~rhel8_auth_ssl~auth_ssl_python_version~3.10_coverage~coverage_test_4.4_replica_set_patch_ebb94b669ec2be5968f2cdfd7928b68808539216_65cf4ec01e2d1734e23a6242_24_02_16_12_02_09/0?type=T

@blink1073
Copy link
Member Author

Test failures are CSOT and https://jira.mongodb.org/projects/PYTHON/issues/PYTHON-4182.

Copy link
Contributor

@caseyclements caseyclements left a comment

Choose a reason for hiding this comment

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

Once tests pass, updates look good to me.

@@ -254,6 +254,8 @@ def _get_wce_doc(result: Mapping[str, Any]) -> Optional[Mapping[str, Any]]:
# convenient to attach it to the writeConcernError doc itself.
error_labels = result.get("errorLabels")
if error_labels:
# Copy to avoid changing the original document.
wce = wce.copy()
Copy link
Member

@ShaneHarvey ShaneHarvey Feb 20, 2024

Choose a reason for hiding this comment

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

Does this work with if result is a RawBSONDocument? Can we add a test for it?

Edit: Oh I see, this is only used for write command responses so we only ever pass dict. Besides that, RawBSONDocument would already fail the wce["errorLabels"] = error_labels assignment.

@blink1073 blink1073 merged commit 0793138 into mongodb:master Feb 20, 2024
72 of 75 checks passed
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.

3 participants