Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion test/csot/gridfs-advanced.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"schemaVersion": "1.9",
"runOnRequirements": [
{
"minServerVersion": "4.4"
"minServerVersion": "4.4",
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
3 changes: 2 additions & 1 deletion test/csot/gridfs-delete.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"schemaVersion": "1.9",
"runOnRequirements": [
{
"minServerVersion": "4.4"
"minServerVersion": "4.4",
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
3 changes: 2 additions & 1 deletion test/csot/gridfs-download.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"schemaVersion": "1.9",
"runOnRequirements": [
{
"minServerVersion": "4.4"
"minServerVersion": "4.4",
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
3 changes: 2 additions & 1 deletion test/csot/gridfs-find.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"schemaVersion": "1.9",
"runOnRequirements": [
{
"minServerVersion": "4.4"
"minServerVersion": "4.4",
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
3 changes: 2 additions & 1 deletion test/csot/gridfs-upload.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"schemaVersion": "1.9",
"runOnRequirements": [
{
"minServerVersion": "4.4"
"minServerVersion": "4.4",
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
13 changes: 4 additions & 9 deletions test/test_change_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
4 changes: 1 addition & 3 deletions test/test_csot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 3 additions & 6 deletions test/test_custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({})
Expand All @@ -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({})
Expand All @@ -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({})
Expand Down
3 changes: 1 addition & 2 deletions test/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down