PYTHON-4266 Migrate Atlas Data Lake tests to unified test format (#1760)
This commit is contained in:
parent
d4e5ee10fc
commit
000e50c076
@ -1,53 +0,0 @@
|
||||
{
|
||||
"collection_name": "driverdata",
|
||||
"database_name": "test",
|
||||
"tests": [
|
||||
{
|
||||
"description": "Aggregate with pipeline (project, sort, limit)",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection",
|
||||
"name": "aggregate",
|
||||
"arguments": {
|
||||
"pipeline": [
|
||||
{
|
||||
"$project": {
|
||||
"_id": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"$sort": {
|
||||
"a": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$limit": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"result": [
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 2,
|
||||
"b": 3,
|
||||
"c": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"expectations": [
|
||||
{
|
||||
"command_started_event": {
|
||||
"command": {
|
||||
"aggregate": "driverdata"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
{
|
||||
"collection_name": "driverdata",
|
||||
"database_name": "test",
|
||||
"tests": [
|
||||
{
|
||||
"description": "estimatedDocumentCount succeeds",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection",
|
||||
"name": "estimatedDocumentCount",
|
||||
"result": 15
|
||||
}
|
||||
],
|
||||
"expectations": [
|
||||
{
|
||||
"command_started_event": {
|
||||
"command": {
|
||||
"count": "driverdata"
|
||||
},
|
||||
"command_name": "count",
|
||||
"database_name": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
{
|
||||
"collection_name": "driverdata",
|
||||
"database_name": "test",
|
||||
"tests": [
|
||||
{
|
||||
"description": "A successful find event with getMore",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection",
|
||||
"name": "find",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"a": {
|
||||
"$gte": 2
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"a": 1
|
||||
},
|
||||
"batchSize": 3,
|
||||
"limit": 4
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectations": [
|
||||
{
|
||||
"command_started_event": {
|
||||
"command": {
|
||||
"find": "driverdata",
|
||||
"filter": {
|
||||
"a": {
|
||||
"$gte": 2
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"a": 1
|
||||
},
|
||||
"batchSize": 3,
|
||||
"limit": 4
|
||||
},
|
||||
"command_name": "find",
|
||||
"database_name": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command_started_event": {
|
||||
"command": {
|
||||
"batchSize": 1
|
||||
},
|
||||
"command_name": "getMore",
|
||||
"database_name": "cursors"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
{
|
||||
"database_name": "test",
|
||||
"tests": [
|
||||
{
|
||||
"description": "ListCollections succeeds",
|
||||
"operations": [
|
||||
{
|
||||
"name": "listCollections",
|
||||
"object": "database"
|
||||
}
|
||||
],
|
||||
"expectations": [
|
||||
{
|
||||
"command_started_event": {
|
||||
"command_name": "listCollections",
|
||||
"database_name": "test",
|
||||
"command": {
|
||||
"listCollections": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
{
|
||||
"tests": [
|
||||
{
|
||||
"description": "ListDatabases succeeds",
|
||||
"operations": [
|
||||
{
|
||||
"name": "listDatabases",
|
||||
"object": "client"
|
||||
}
|
||||
],
|
||||
"expectations": [
|
||||
{
|
||||
"command_started_event": {
|
||||
"command_name": "listDatabases",
|
||||
"database_name": "admin",
|
||||
"command": {
|
||||
"listDatabases": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
{
|
||||
"database_name": "test",
|
||||
"tests": [
|
||||
{
|
||||
"description": "ping succeeds using runCommand",
|
||||
"operations": [
|
||||
{
|
||||
"name": "runCommand",
|
||||
"object": "database",
|
||||
"command_name": "ping",
|
||||
"arguments": {
|
||||
"command": {
|
||||
"ping": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectations": [
|
||||
{
|
||||
"command_started_event": {
|
||||
"command_name": "ping",
|
||||
"database_name": "test",
|
||||
"command": {
|
||||
"ping": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
84
test/data_lake/unified/aggregate.json
Normal file
84
test/data_lake/unified/aggregate.json
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"description": "aggregate",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "driverdata"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Aggregate with pipeline (project, sort, limit)",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "aggregate",
|
||||
"arguments": {
|
||||
"pipeline": [
|
||||
{
|
||||
"$project": {
|
||||
"_id": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"$sort": {
|
||||
"a": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$limit": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectResult": [
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 2,
|
||||
"b": 3,
|
||||
"c": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"aggregate": "driverdata"
|
||||
},
|
||||
"commandName": "aggregate",
|
||||
"databaseName": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
56
test/data_lake/unified/estimatedDocumentCount.json
Normal file
56
test/data_lake/unified/estimatedDocumentCount.json
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"description": "estimatedDocumentCount",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "driverdata"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "estimatedDocumentCount succeeds",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "estimatedDocumentCount",
|
||||
"expectResult": 15
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"count": "driverdata"
|
||||
},
|
||||
"commandName": "count",
|
||||
"databaseName": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,12 +1,36 @@
|
||||
{
|
||||
"collection_name": "driverdata",
|
||||
"database_name": "test",
|
||||
"description": "find",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "driverdata"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "Find with projection and sort",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection",
|
||||
"object": "collection0",
|
||||
"name": "find",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
@ -22,7 +46,7 @@
|
||||
},
|
||||
"limit": 5
|
||||
},
|
||||
"result": [
|
||||
"expectResult": [
|
||||
{
|
||||
"a": 5,
|
||||
"b": 6,
|
||||
@ -51,13 +75,20 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"expectations": [
|
||||
"expectEvents": [
|
||||
{
|
||||
"command_started_event": {
|
||||
"command": {
|
||||
"find": "driverdata"
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"find": "driverdata"
|
||||
},
|
||||
"commandName": "find",
|
||||
"databaseName": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
95
test/data_lake/unified/getMore.json
Normal file
95
test/data_lake/unified/getMore.json
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
"description": "getMore",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "driverdata"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "A successful find event with getMore",
|
||||
"operations": [
|
||||
{
|
||||
"object": "collection0",
|
||||
"name": "find",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"a": {
|
||||
"$gte": 2
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"a": 1
|
||||
},
|
||||
"batchSize": 3,
|
||||
"limit": 4
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"find": "driverdata",
|
||||
"filter": {
|
||||
"a": {
|
||||
"$gte": 2
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"a": 1
|
||||
},
|
||||
"batchSize": 3,
|
||||
"limit": 4
|
||||
},
|
||||
"commandName": "find",
|
||||
"databaseName": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"getMore": {
|
||||
"$$type": [
|
||||
"int",
|
||||
"long"
|
||||
]
|
||||
},
|
||||
"collection": {
|
||||
"$$type": "string"
|
||||
},
|
||||
"batchSize": 1
|
||||
},
|
||||
"commandName": "getMore",
|
||||
"databaseName": "cursors"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
48
test/data_lake/unified/listCollections.json
Normal file
48
test/data_lake/unified/listCollections.json
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"description": "listCollections",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "ListCollections succeeds",
|
||||
"operations": [
|
||||
{
|
||||
"object": "database0",
|
||||
"name": "listCollections"
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"listCollections": 1
|
||||
},
|
||||
"commandName": "listCollections",
|
||||
"databaseName": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
41
test/data_lake/unified/listDatabases.json
Normal file
41
test/data_lake/unified/listDatabases.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"description": "listDatabases",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "ListCollections succeeds",
|
||||
"operations": [
|
||||
{
|
||||
"object": "client0",
|
||||
"name": "listDatabases"
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"listDatabases": 1
|
||||
},
|
||||
"commandName": "listDatabases",
|
||||
"databaseName": "admin"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
54
test/data_lake/unified/runCommand.json
Normal file
54
test/data_lake/unified/runCommand.json
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"description": "runCommand",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"observeEvents": [
|
||||
"commandStartedEvent"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "ping succeeds using runCommand",
|
||||
"operations": [
|
||||
{
|
||||
"object": "database0",
|
||||
"name": "runCommand",
|
||||
"arguments": {
|
||||
"command": {
|
||||
"ping": 1
|
||||
},
|
||||
"commandName": "ping"
|
||||
}
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
{
|
||||
"client": "client0",
|
||||
"events": [
|
||||
{
|
||||
"commandStartedEvent": {
|
||||
"command": {
|
||||
"ping": 1
|
||||
},
|
||||
"commandName": "ping",
|
||||
"databaseName": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -17,16 +17,16 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path[0:0] = [""]
|
||||
|
||||
from test import IntegrationTest, client_context, unittest
|
||||
from test.crud_v2_format import TestCrudV2
|
||||
from test.unified_format import generate_test_classes
|
||||
from test.utils import (
|
||||
OvertCommandListener,
|
||||
SpecTestCreator,
|
||||
rs_client_noauth,
|
||||
rs_or_single_client,
|
||||
)
|
||||
@ -100,30 +100,11 @@ class TestDataLakeProse(IntegrationTest):
|
||||
client[self.TEST_DB][self.TEST_COLLECTION].find_one()
|
||||
|
||||
|
||||
class DataLakeTestSpec(TestCrudV2):
|
||||
# Default test database and collection names.
|
||||
TEST_DB = "test"
|
||||
TEST_COLLECTION = "driverdata"
|
||||
# Location of JSON test specifications.
|
||||
TEST_PATH = Path(__file__).parent / "data_lake/unified"
|
||||
|
||||
@classmethod
|
||||
@client_context.require_data_lake
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
def setup_scenario(self, scenario_def):
|
||||
# Spec tests MUST NOT insert data/drop collection for
|
||||
# data lake testing.
|
||||
pass
|
||||
|
||||
|
||||
def create_test(scenario_def, test, name):
|
||||
def run_scenario(self):
|
||||
self.run_scenario(scenario_def, test)
|
||||
|
||||
return run_scenario
|
||||
|
||||
|
||||
SpecTestCreator(create_test, DataLakeTestSpec, _TEST_PATH).create_tests()
|
||||
# Generate unified tests.
|
||||
globals().update(generate_test_classes(TEST_PATH, module=__name__))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user