Skip to content

Commit

Permalink
test(NODE-6120): Implement Unified test runner changes for CSOT (#4121)
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James authored and baileympearson committed Oct 21, 2024
1 parent 14f40c8 commit 426d698
Show file tree
Hide file tree
Showing 25 changed files with 547 additions and 37 deletions.
37 changes: 31 additions & 6 deletions test/spec/unified-test-format/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SCHEMA=../schema-1.5.json
SCHEMA=../schema-1.21.json

.PHONY: all invalid valid-fail valid-pass versioned-api load-balancers gridfs transactions crud collection-management sessions command-monitoring HAS_AJV
.PHONY: all invalid valid-fail valid-pass atlas-data-lake versioned-api load-balancers gridfs transactions transactions-convenient-api crud collection-management read-write-concern retryable-reads retryable-writes sessions command-logging-and-monitoring client-side-operations-timeout HAS_AJV

all: invalid valid-fail valid-pass versioned-api load-balancers gridfs transactions crud collection-management sessions command-monitoring
all: invalid valid-fail valid-pass atlas-data-lake versioned-api load-balancers gridfs transactions transactions-convenient-api change-streams crud collection-management read-write-concern retryable-reads retryable-writes sessions command-logging-and-monitoring client-side-operations-timeout client-side-encryption

invalid: HAS_AJV
@# Redirect stdout to hide expected validation errors
Expand All @@ -14,6 +14,9 @@ valid-fail: HAS_AJV
valid-pass: HAS_AJV
@ajv test -s $(SCHEMA) -d "valid-pass/*.yml" --valid

atlas-data-lake: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../atlas-data-lake-testing/tests/unified/*.yml" --valid

versioned-api: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../versioned-api/tests/*.yml" --valid

Expand All @@ -26,17 +29,39 @@ gridfs: HAS_AJV
transactions: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../transactions/tests/unified/*.yml" --valid

transactions-convenient-api: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../transactions-convenient-api/tests/unified/*.yml" --valid

change-streams: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../change-streams/tests/unified/*.yml" --valid

client-side-operations-timeout: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../client-side-operations-timeout/tests/*.yml" --valid

crud: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../crud/tests/unified/*.yml" --valid

collection-management: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../collection-management/tests/*.yml" --valid

read-write-concern: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../read-write-concern/tests/operation/*.yml" --valid

retryable-reads: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../retryable-reads/tests/unified/*.yml" --valid

retryable-writes: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../retryable-writes/tests/unified/*.yml" --valid

sessions: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../sessions/tests/unified/*.yml" --valid
@ajv test -s $(SCHEMA) -d "../../sessions/tests/*.yml" --valid

command-logging-and-monitoring: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../command-logging-and-monitoring/tests/logging/*.yml" --valid
@ajv test -s $(SCHEMA) -d "../../command-logging-and-monitoring/tests/monitoring/*.yml" --valid

command-monitoring: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../command-monitoring/tests/unified/*.yml" --valid
client-side-encryption: HAS_AJV
@ajv test -s $(SCHEMA) -d "../../client-side-encryption/tests/unified/*.yml" --valid

HAS_AJV:
@if ! command -v ajv > /dev/null; then \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
description: collectionData-createOptions

schemaVersion: "1.9"

runOnRequirements:
- minServerVersion: "3.6"
# Capped collections cannot be created on serverless instances.
serverless: forbid

createEntities:
- client:
id: &client0 client0
Expand All @@ -18,7 +15,6 @@ createEntities:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- collectionName: *collection0Name
databaseName: *database0Name
Expand All @@ -28,7 +24,6 @@ initialData:
size: &cappedSize 4096
documents:
- { _id: 1, x: 11 }

tests:
- description: collection is created with the correct options
operations:
Expand All @@ -39,4 +34,4 @@ tests:
- $collStats: { storageStats: {} }
- $project: { capped: '$storageStats.capped', maxSize: '$storageStats.maxSize'}
expectResult:
- { capped: true, maxSize: *cappedSize }
- { capped: true, maxSize: *cappedSize }
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"description": "createEntities-operation",
"schemaVersion": "1.9",
"tests": [
{
"description": "createEntities operation",
"operations": [
{
"name": "createEntities",
"object": "testRunner",
"arguments": {
"entities": [
{
"client": {
"id": "client1",
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database1",
"client": "client1",
"databaseName": "database1"
}
},
{
"collection": {
"id": "collection1",
"database": "database1",
"collectionName": "coll1"
}
}
]
}
},
{
"name": "deleteOne",
"object": "collection1",
"arguments": {
"filter": {
"_id": 1
}
}
}
],
"expectEvents": [
{
"client": "client1",
"events": [
{
"commandStartedEvent": {
"command": {
"delete": "coll1",
"deletes": [
{
"q": {
"_id": 1
},
"limit": 1
}
]
},
"commandName": "delete",
"databaseName": "database1"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
description: createEntities-operation

# Note: createEntities is not technically in the 1.9 schema but was introduced at the same time.
schemaVersion: "1.9"

tests:
- description: createEntities operation
operations:
- name: createEntities
object: testRunner
arguments:
entities:
- client:
id: &client1 client1
observeEvents: [ commandStartedEvent ]
- database:
id: &database1 database1
client: *client1
databaseName: &database1Name database1
- collection:
id: &collection1 collection1
database: *database1
collectionName: &collection1Name coll1
- name: deleteOne
object: *collection1
arguments:
filter: { _id : 1 }
expectEvents:
- client: *client1
events:
- commandStartedEvent:
command:
delete: *collection1Name
deletes:
- q: { _id: 1 }
limit: 1
commandName: delete
databaseName: *database1Name
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"description": "entity-cursor-iterateOnce",
"schemaVersion": "1.9",
"createEntities": [
{
"client": {
"id": "client0",
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"databaseName": "database0",
"collectionName": "coll0",
"documents": [
{
"_id": 1
},
{
"_id": 2
},
{
"_id": 3
}
]
}
],
"tests": [
{
"description": "iterateOnce",
"operations": [
{
"name": "createFindCursor",
"object": "collection0",
"arguments": {
"filter": {},
"batchSize": 2
},
"saveResultAsEntity": "cursor0"
},
{
"name": "iterateUntilDocumentOrError",
"object": "cursor0",
"expectResult": {
"_id": 1
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "cursor0",
"expectResult": {
"_id": 2
}
},
{
"name": "iterateOnce",
"object": "cursor0"
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"find": "coll0",
"filter": {},
"batchSize": 2
},
"commandName": "find",
"databaseName": "database0"
}
},
{
"commandStartedEvent": {
"command": {
"getMore": {
"$$type": [
"int",
"long"
]
},
"collection": "coll0"
},
"commandName": "getMore"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
description: entity-cursor-iterateOnce

# Note: iterateOnce is not technically in the 1.9 schema but was introduced at the same time.
schemaVersion: "1.9"

createEntities:
- client:
id: &client0 client0
observeEvents: [ commandStartedEvent ]
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name database0
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- databaseName: *database0Name
collectionName: *collection0Name
documents:
- _id: 1
- _id: 2
- _id: 3

tests:
- description: iterateOnce
operations:
- name: createFindCursor
object: *collection0
arguments:
filter: {}
batchSize: 2
saveResultAsEntity: &cursor0 cursor0
- name: iterateUntilDocumentOrError
object: *cursor0
expectResult: { _id: 1 }
- name: iterateUntilDocumentOrError
object: *cursor0
expectResult: { _id: 2 }
# This operation could be iterateUntilDocumentOrError, but we use iterateOne to ensure that drivers support it.
- name: iterateOnce
object: *cursor0
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
find: *collection0Name
filter: {}
batchSize: 2
commandName: find
databaseName: *database0Name
- commandStartedEvent:
command:
getMore: { $$type: [ int, long ] }
collection: *collection0Name
commandName: getMore
Loading

0 comments on commit 426d698

Please sign in to comment.