diff --git a/test/__init__.py b/test/__init__.py index 4ecc3c9e9e..2a3e59adf9 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -759,6 +759,16 @@ def require_no_load_balancer(self, func): lambda: not self.load_balancer, "Must not be connected to a load balancer", func=func ) + def require_no_serverless(self, func): + """Run a test only if the client is not connected to serverless.""" + return self._require( + lambda: not self.serverless, "Must not be connected to serverless", func=func + ) + + def require_change_streams(self, func): + """Run a test only if the server supports change streams.""" + return self.require_no_mmap(self.require_no_standalone(self.require_no_serverless(func))) + def is_topology_type(self, topologies): unknown = set(topologies) - { "single", diff --git a/test/csot/gridfs-advanced.json b/test/csot/gridfs-advanced.json index 6bf0229a04..c6c0944d2f 100644 --- a/test/csot/gridfs-advanced.json +++ b/test/csot/gridfs-advanced.json @@ -3,7 +3,8 @@ "schemaVersion": "1.9", "runOnRequirements": [ { - "minServerVersion": "4.4" + "minServerVersion": "4.4", + "serverless": "forbid" } ], "createEntities": [ diff --git a/test/csot/gridfs-delete.json b/test/csot/gridfs-delete.json index 8701929ff3..9f4980114b 100644 --- a/test/csot/gridfs-delete.json +++ b/test/csot/gridfs-delete.json @@ -3,7 +3,8 @@ "schemaVersion": "1.9", "runOnRequirements": [ { - "minServerVersion": "4.4" + "minServerVersion": "4.4", + "serverless": "forbid" } ], "createEntities": [ diff --git a/test/csot/gridfs-download.json b/test/csot/gridfs-download.json index 2ab64010f8..8542f69e89 100644 --- a/test/csot/gridfs-download.json +++ b/test/csot/gridfs-download.json @@ -3,7 +3,8 @@ "schemaVersion": "1.9", "runOnRequirements": [ { - "minServerVersion": "4.4" + "minServerVersion": "4.4", + "serverless": "forbid" } ], "createEntities": [ diff --git a/test/csot/gridfs-find.json b/test/csot/gridfs-find.json index 45bb7066d6..7409036284 100644 --- a/test/csot/gridfs-find.json +++ b/test/csot/gridfs-find.json @@ -3,7 +3,8 @@ "schemaVersion": "1.9", "runOnRequirements": [ { - "minServerVersion": "4.4" + "minServerVersion": "4.4", + "serverless": "forbid" } ], "createEntities": [ diff --git a/test/csot/gridfs-upload.json b/test/csot/gridfs-upload.json index 690fdda77f..b3f174973d 100644 --- a/test/csot/gridfs-upload.json +++ b/test/csot/gridfs-upload.json @@ -3,7 +3,8 @@ "schemaVersion": "1.9", "runOnRequirements": [ { - "minServerVersion": "4.4" + "minServerVersion": "4.4", + "serverless": "forbid" } ], "createEntities": [ diff --git a/test/test_change_stream.py b/test/test_change_stream.py index a8b793333e..18a0ec84c4 100644 --- a/test/test_change_stream.py +++ b/test/test_change_stream.py @@ -430,8 +430,7 @@ def test_start_after_resume_process_with_changes(self): self.assertEqual(change["fullDocument"], {"_id": 3}) @no_type_check - @client_context.require_no_mongos # Remove after SERVER-41196 - @client_context.require_version_min(4, 1, 1) + @client_context.require_version_min(4, 2) def test_start_after_resume_process_without_changes(self): resume_token = self.get_resume_token(invalidate=True) @@ -767,8 +766,7 @@ class TestClusterChangeStream(TestChangeStreamBase, APITestsMixin): @classmethod @client_context.require_version_min(4, 0, 0, -1) - @client_context.require_no_mmap - @client_context.require_no_standalone + @client_context.require_change_streams def setUpClass(cls): super(TestClusterChangeStream, cls).setUpClass() cls.dbs = [cls.db, cls.client.pymongo_test_2] @@ -829,8 +827,7 @@ def test_full_pipeline(self): class TestDatabaseChangeStream(TestChangeStreamBase, APITestsMixin): @classmethod @client_context.require_version_min(4, 0, 0, -1) - @client_context.require_no_mmap - @client_context.require_no_standalone + @client_context.require_change_streams def setUpClass(cls): super(TestDatabaseChangeStream, cls).setUpClass() @@ -915,9 +912,7 @@ def test_isolation(self): class TestCollectionChangeStream(TestChangeStreamBase, APITestsMixin, ProseSpecTestsMixin): @classmethod - @client_context.require_version_min(3, 5, 11) - @client_context.require_no_mmap - @client_context.require_no_standalone + @client_context.require_change_streams def setUpClass(cls): super(TestCollectionChangeStream, cls).setUpClass() diff --git a/test/test_csot.py b/test/test_csot.py index 7b82a49caf..a9cf7a0124 100644 --- a/test/test_csot.py +++ b/test/test_csot.py @@ -73,9 +73,7 @@ def test_timeout_nested(self): self.assertEqual(_csot.get_deadline(), float("inf")) self.assertEqual(_csot.get_rtt(), 0.0) - @client_context.require_version_min(3, 6) - @client_context.require_no_mmap - @client_context.require_no_standalone + @client_context.require_change_streams def test_change_stream_can_resume_after_timeouts(self): coll = self.db.test with coll.watch(max_await_time_ms=150) as stream: diff --git a/test/test_custom_types.py b/test/test_custom_types.py index e11b5ebe00..868756c67d 100644 --- a/test/test_custom_types.py +++ b/test/test_custom_types.py @@ -896,8 +896,7 @@ def run_test(doc_cls): class TestCollectionChangeStreamsWCustomTypes(IntegrationTest, ChangeStreamsWCustomTypesTestMixin): @classmethod - @client_context.require_no_mmap - @client_context.require_no_standalone + @client_context.require_change_streams def setUpClass(cls): super(TestCollectionChangeStreamsWCustomTypes, cls).setUpClass() cls.db.test.delete_many({}) @@ -916,8 +915,7 @@ def create_targets(self, *args, **kwargs): class TestDatabaseChangeStreamsWCustomTypes(IntegrationTest, ChangeStreamsWCustomTypesTestMixin): @classmethod @client_context.require_version_min(4, 0, 0) - @client_context.require_no_mmap - @client_context.require_no_standalone + @client_context.require_change_streams def setUpClass(cls): super(TestDatabaseChangeStreamsWCustomTypes, cls).setUpClass() cls.db.test.delete_many({}) @@ -936,8 +934,7 @@ def create_targets(self, *args, **kwargs): class TestClusterChangeStreamsWCustomTypes(IntegrationTest, ChangeStreamsWCustomTypesTestMixin): @classmethod @client_context.require_version_min(4, 0, 0) - @client_context.require_no_mmap - @client_context.require_no_standalone + @client_context.require_change_streams def setUpClass(cls): super(TestClusterChangeStreamsWCustomTypes, cls).setUpClass() cls.db.test.delete_many({}) diff --git a/test/test_examples.py b/test/test_examples.py index e23abe104f..9c1adda69c 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -740,8 +740,7 @@ def test_delete(self): self.assertEqual(db.inventory.count_documents({}), 0) - @client_context.require_replica_set - @client_context.require_no_mmap + @client_context.require_change_streams def test_change_streams(self): db = self.db done = False