| 645 | @client_context.require_test_commands |
| 646 | @client_context.require_no_mongos |
| 647 | def test_command_max_time_ms(self): |
| 648 | self.client.admin.command("configureFailPoint", "maxTimeAlwaysTimeOut", mode="alwaysOn") |
| 649 | try: |
| 650 | db = self.client.pymongo_test |
| 651 | db.command("count", "test") |
| 652 | with self.assertRaises(ExecutionTimeout): |
| 653 | db.command("count", "test", maxTimeMS=1) |
| 654 | pipeline = [{"$project": {"name": 1, "count": 1}}] |
| 655 | # Database command helper. |
| 656 | db.command("aggregate", "test", pipeline=pipeline, cursor={}) |
| 657 | with self.assertRaises(ExecutionTimeout): |
| 658 | db.command( |
| 659 | "aggregate", |
| 660 | "test", |
| 661 | pipeline=pipeline, |
| 662 | cursor={}, |
| 663 | maxTimeMS=1, |
| 664 | ) |
| 665 | # Collection helper. |
| 666 | db.test.aggregate(pipeline=pipeline) |
| 667 | with self.assertRaises(ExecutionTimeout): |
| 668 | db.test.aggregate(pipeline, maxTimeMS=1) |
| 669 | finally: |
| 670 | self.client.admin.command("configureFailPoint", "maxTimeAlwaysTimeOut", mode="off") |
| 671 | |
| 672 | def test_with_options(self): |
| 673 | codec_options = DECIMAL_CODECOPTS |