-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5208 Add spec test for wait queue timeout errors do not clear the pool #2199
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a25df07
PYTHON-5202 Add spec test
ShaneHarvey ddd7523
PYTHON-5202 Resync
ShaneHarvey 16ac4a0
Merge branch 'master' into PYTHON-5202-spec-test
ShaneHarvey d48b62c
PYTHON-5202 Resync
ShaneHarvey 9c9528b
Merge branch 'master' into PYTHON-5202-spec-test
ShaneHarvey dbe39f3
PYTHON-5202 Advance clusterTime without using ping command
ShaneHarvey b67f6a3
PYTHON-5202 fix init _cluster_time attr
ShaneHarvey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,7 +222,6 @@ def __init__(self, test_class): | |
self._listeners: Dict[str, EventListenerUtil] = {} | ||
self._session_lsids: Dict[str, Mapping[str, Any]] = {} | ||
self.test: UnifiedSpecTestMixinV1 = test_class | ||
self._cluster_time: Mapping[str, Any] = {} | ||
|
||
def __contains__(self, item): | ||
return item in self._entities | ||
|
@@ -421,13 +420,11 @@ def get_lsid_for_session(self, session_name): | |
# session has been closed. | ||
return self._session_lsids[session_name] | ||
|
||
async def advance_cluster_times(self) -> None: | ||
async def advance_cluster_times(self, cluster_time) -> None: | ||
"""Manually synchronize entities when desired""" | ||
if not self._cluster_time: | ||
self._cluster_time = (await self.test.client.admin.command("ping")).get("$clusterTime") | ||
for entity in self._entities.values(): | ||
if isinstance(entity, AsyncClientSession) and self._cluster_time: | ||
entity.advance_cluster_time(self._cluster_time) | ||
if isinstance(entity, AsyncClientSession) and cluster_time: | ||
entity.advance_cluster_time(cluster_time) | ||
|
||
|
||
class UnifiedSpecTestMixinV1(AsyncIntegrationTest): | ||
|
@@ -1044,7 +1041,7 @@ async def _testOperation_targetedFailPoint(self, spec): | |
|
||
async def _testOperation_createEntities(self, spec): | ||
await self.entity_map.create_entities_from_spec(spec["entities"], uri=self._uri) | ||
await self.entity_map.advance_cluster_times() | ||
await self.entity_map.advance_cluster_times(self._cluster_time) | ||
|
||
def _testOperation_assertSessionTransactionState(self, spec): | ||
session = self.entity_map[spec["session"]] | ||
|
@@ -1443,11 +1440,12 @@ async def _run_scenario(self, spec, uri=None): | |
await self.entity_map.create_entities_from_spec( | ||
self.TEST_SPEC.get("createEntities", []), uri=uri | ||
) | ||
self._cluster_time = None | ||
# process initialData | ||
if "initialData" in self.TEST_SPEC: | ||
await self.insert_initial_data(self.TEST_SPEC["initialData"]) | ||
self._cluster_time = (await self.client.admin.command("ping")).get("$clusterTime") | ||
await self.entity_map.advance_cluster_times() | ||
self._cluster_time = self.client._topology.max_cluster_time() | ||
await self.entity_map.advance_cluster_times(self._cluster_time) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I refactored this to remove the "ping" command because it was causing problems with the failpoint for this new test. We can get the clusterTime via |
||
|
||
if "expectLogMessages" in spec: | ||
expect_log_messages = spec["expectLogMessages"] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
{ | ||
"description": "WaitQueueTimeoutError does not clear the pool", | ||
"schemaVersion": "1.9", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "4.4", | ||
"topologies": [ | ||
"single", | ||
"replicaset", | ||
"sharded" | ||
] | ||
} | ||
], | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "failPointClient", | ||
"useMultipleMongoses": false | ||
} | ||
}, | ||
{ | ||
"client": { | ||
"id": "client", | ||
"uriOptions": { | ||
"maxPoolSize": 1, | ||
"appname": "waitQueueTimeoutErrorTest" | ||
}, | ||
"useMultipleMongoses": false, | ||
"observeEvents": [ | ||
"commandStartedEvent", | ||
"poolClearedEvent" | ||
] | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database", | ||
"client": "client", | ||
"databaseName": "test" | ||
} | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "WaitQueueTimeoutError does not clear the pool", | ||
"operations": [ | ||
{ | ||
"name": "failPoint", | ||
"object": "testRunner", | ||
"arguments": { | ||
"client": "failPointClient", | ||
"failPoint": { | ||
"configureFailPoint": "failCommand", | ||
"mode": { | ||
"times": 1 | ||
}, | ||
"data": { | ||
"failCommands": [ | ||
"ping" | ||
], | ||
"blockConnection": true, | ||
"blockTimeMS": 500, | ||
"appName": "waitQueueTimeoutErrorTest" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "createEntities", | ||
"object": "testRunner", | ||
"arguments": { | ||
"entities": [ | ||
{ | ||
"thread": { | ||
"id": "thread0" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"name": "runOnThread", | ||
"object": "testRunner", | ||
"arguments": { | ||
"thread": "thread0", | ||
"operation": { | ||
"name": "runCommand", | ||
"object": "database", | ||
"arguments": { | ||
"command": { | ||
"ping": 1 | ||
}, | ||
"commandName": "ping" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "waitForEvent", | ||
"object": "testRunner", | ||
"arguments": { | ||
"client": "client", | ||
"event": { | ||
"commandStartedEvent": { | ||
"commandName": "ping" | ||
} | ||
}, | ||
"count": 1 | ||
} | ||
}, | ||
{ | ||
"name": "runCommand", | ||
"object": "database", | ||
"arguments": { | ||
"timeoutMS": 100, | ||
"command": { | ||
"hello": 1 | ||
}, | ||
"commandName": "hello" | ||
}, | ||
"expectError": { | ||
"isTimeoutError": true | ||
} | ||
}, | ||
{ | ||
"name": "waitForThread", | ||
"object": "testRunner", | ||
"arguments": { | ||
"thread": "thread0" | ||
} | ||
}, | ||
{ | ||
"name": "runCommand", | ||
"object": "database", | ||
"arguments": { | ||
"command": { | ||
"hello": 1 | ||
}, | ||
"commandName": "hello" | ||
} | ||
} | ||
], | ||
"expectEvents": [ | ||
{ | ||
"client": "client", | ||
"eventType": "command", | ||
"events": [ | ||
{ | ||
"commandStartedEvent": { | ||
"commandName": "ping", | ||
"databaseName": "test", | ||
"command": { | ||
"ping": 1 | ||
} | ||
} | ||
}, | ||
{ | ||
"commandStartedEvent": { | ||
"commandName": "hello", | ||
"databaseName": "test", | ||
"command": { | ||
"hello": 1 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"client": "client", | ||
"eventType": "cmap", | ||
"events": [] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Do we need to store this at the class level at all, or can this be a fully local variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we need it because the spec says it's the clusterTime from directly after initialData is inserted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.