Skip to content

Commit

Permalink
add async_set_fail_point
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyStick committed Sep 27, 2024
1 parent 6d657c1 commit b00c64e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/asynchronous/test_retryable_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from test.utils import (
CMAPListener,
OvertCommandListener,
set_fail_point,
async_set_fail_point,
)

from pymongo.monitoring import (
Expand Down Expand Up @@ -167,7 +167,7 @@ async def test_retryable_reads_in_sharded_cluster_multiple_available(self):

for mongos in async_client_context.mongos_seeds().split(","):
client = await self.async_rs_or_single_client(mongos)
set_fail_point(client, fail_command)
await async_set_fail_point(client, fail_command)
self.addAsyncCleanup(client.close)
mongos_clients.append(client)

Expand All @@ -186,7 +186,7 @@ async def test_retryable_reads_in_sharded_cluster_multiple_available(self):
# Disable failpoints on each mongos
for client in mongos_clients:
fail_command["mode"] = "off"
set_fail_point(client, fail_command)
await async_set_fail_point(client, fail_command)

self.assertEqual(len(listener.failed_events), 2)
self.assertEqual(len(listener.succeeded_events), 0)
Expand Down
6 changes: 6 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,3 +1157,9 @@ def set_fail_point(client, command_args):
cmd = SON([("configureFailPoint", "failCommand")])
cmd.update(command_args)
client.admin.command(cmd)


async def async_set_fail_point(client, command_args):
cmd = SON([("configureFailPoint", "failCommand")])
cmd.update(command_args)
await client.admin.command(cmd)
1 change: 1 addition & 0 deletions tools/synchro.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"PyMongo|async": "PyMongo",
"AsyncTestGridFile": "TestGridFile",
"AsyncTestGridFileNoConnect": "TestGridFileNoConnect",
"async_set_fail_point": "set_fail_point",
}

docstring_replacements: dict[tuple[str, str], str] = {
Expand Down

0 comments on commit b00c64e

Please sign in to comment.