Skip to content

Commit 87c5595

Browse files
committed
add spec tests
1 parent 8fca1aa commit 87c5595

File tree

92 files changed

+1970
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1970
-73
lines changed

test/spec/unified-test-format/Makefile

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
SCHEMA=../schema-1.5.json
1+
SCHEMA=../schema-1.20.json
22

3-
.PHONY: all invalid valid-fail valid-pass versioned-api load-balancers gridfs transactions crud collection-management sessions command-monitoring HAS_AJV
3+
.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
44

5-
all: invalid valid-fail valid-pass versioned-api load-balancers gridfs transactions crud collection-management sessions command-monitoring
5+
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
66

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

17+
atlas-data-lake: HAS_AJV
18+
@ajv test -s $(SCHEMA) -d "../../atlas-data-lake-testing/tests/unified/*.yml" --valid
19+
1720
versioned-api: HAS_AJV
1821
@ajv test -s $(SCHEMA) -d "../../versioned-api/tests/*.yml" --valid
1922

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

32+
transactions-convenient-api: HAS_AJV
33+
@ajv test -s $(SCHEMA) -d "../../transactions-convenient-api/tests/unified/*.yml" --valid
34+
35+
change-streams: HAS_AJV
36+
@ajv test -s $(SCHEMA) -d "../../change-streams/tests/unified/*.yml" --valid
37+
38+
client-side-operations-timeout: HAS_AJV
39+
@ajv test -s $(SCHEMA) -d "../../client-side-operations-timeout/tests/*.yml" --valid
40+
2941
crud: HAS_AJV
3042
@ajv test -s $(SCHEMA) -d "../../crud/tests/unified/*.yml" --valid
3143

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

47+
read-write-concern: HAS_AJV
48+
@ajv test -s $(SCHEMA) -d "../../read-write-concern/tests/operation/*.yml" --valid
49+
50+
retryable-reads: HAS_AJV
51+
@ajv test -s $(SCHEMA) -d "../../retryable-reads/tests/unified/*.yml" --valid
52+
53+
retryable-writes: HAS_AJV
54+
@ajv test -s $(SCHEMA) -d "../../retryable-writes/tests/unified/*.yml" --valid
55+
3556
sessions: HAS_AJV
36-
@ajv test -s $(SCHEMA) -d "../../sessions/tests/unified/*.yml" --valid
57+
@ajv test -s $(SCHEMA) -d "../../sessions/tests/*.yml" --valid
58+
59+
command-logging-and-monitoring: HAS_AJV
60+
@ajv test -s $(SCHEMA) -d "../../command-logging-and-monitoring/tests/logging/*.yml" --valid
61+
@ajv test -s $(SCHEMA) -d "../../command-logging-and-monitoring/tests/monitoring/*.yml" --valid
3762

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

4166
HAS_AJV:
4267
@if ! command -v ajv > /dev/null; then \
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Unified Test Format Tests
2+
3+
______________________________________________________________________
4+
5+
## Introduction
6+
7+
This directory contains tests for the Unified Test Format's schema and test runner implementation(s). Tests are
8+
organized in the following directories:
9+
10+
- `invalid`: These files do not validate against the schema and are used to test the schema itself.
11+
- `valid-pass`: These files validate against the schema and should pass when executed with a test runner.
12+
- `valid-fail`: These files validate against the schema but should produce runtime errors or failures when executed with
13+
a test runner. Some do so by violating the "SHOULD" and "SHOULD NOT" guidance in the spec (e.g. referencing an
14+
undefined entity).
15+
16+
## Validating Test Files
17+
18+
JSON and YAML test files can be validated using [Ajv](https://ajv.js.org/) and a schema from the parent directory (e.g.
19+
`schema-1.0.json`).
20+
21+
Test files can be validated individually like so:
22+
23+
```bash
24+
ajv -s ../schema-1.0.json -d path/to/test.yml
25+
```
26+
27+
Ajv can also be used to assert the validity of test files:
28+
29+
```bash
30+
ajv test -s ../schema-1.0.json -d "invalid/*.yml" --invalid
31+
ajv test -s ../schema-1.0.json -d "valid-*/*.yml" --valid
32+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"description": "clientEncryptionOpts-kmsProviders-invalidName",
3+
"schemaVersion": "1.18",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0"
8+
}
9+
},
10+
{
11+
"clientEncryption": {
12+
"id": "clientEncryption0",
13+
"clientEncryptionOpts": {
14+
"keyVaultClient": "client0",
15+
"keyVaultNamespace": "keyvault.datakeys",
16+
"kmsProviders": {
17+
"aws:name_with_invalid_character*": {}
18+
}
19+
}
20+
}
21+
}
22+
],
23+
"tests": [
24+
{
25+
"description": "",
26+
"operations": []
27+
}
28+
]
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
description: clientEncryptionOpts-kmsProviders-invalidName
2+
3+
schemaVersion: "1.18"
4+
5+
createEntities:
6+
- client:
7+
id: &client0 client0
8+
- clientEncryption:
9+
id: &clientEncryption0 clientEncryption0
10+
clientEncryptionOpts:
11+
keyVaultClient: *client0
12+
keyVaultNamespace: keyvault.datakeys
13+
kmsProviders:
14+
# The `*` is an invalid character.
15+
"aws:name_with_invalid_character*": {}
16+
17+
tests:
18+
- description: ""
19+
operations: []
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"description": "entity-client-observeLogMessages-minProperties",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeLogMessages": {}
9+
}
10+
}
11+
],
12+
"tests": [
13+
{
14+
"description": "foo",
15+
"operations": []
16+
}
17+
]
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
description: "entity-client-observeLogMessages-minProperties"
2+
3+
schemaVersion: "1.13"
4+
5+
createEntities:
6+
- client:
7+
id: &client0 "client0"
8+
observeLogMessages: {}
9+
10+
tests:
11+
- description: "foo"
12+
operations: []
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"description": "entity-client-observeLogMessages-property-type",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeLogMessages": {
9+
"command": {}
10+
}
11+
}
12+
}
13+
],
14+
"tests": [
15+
{
16+
"description": "foo",
17+
"operations": []
18+
}
19+
]
20+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: "entity-client-observeLogMessages-property-type"
2+
3+
schemaVersion: "1.13"
4+
5+
createEntities:
6+
- client:
7+
id: &client0 "client0"
8+
observeLogMessages:
9+
command: {}
10+
11+
tests:
12+
- description: "foo"
13+
operations: []
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"description": "entity-client-observeLogMessages-property-type",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeLogMessages": {
9+
"command": "notALogLevel"
10+
}
11+
}
12+
}
13+
],
14+
"tests": [
15+
{
16+
"description": "foo",
17+
"operations": []
18+
}
19+
]
20+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: "entity-client-observeLogMessages-property-type"
2+
3+
schemaVersion: "1.13"
4+
5+
createEntities:
6+
- client:
7+
id: &client0 "client0"
8+
observeLogMessages:
9+
command: notALogLevel
10+
11+
tests:
12+
- description: "foo"
13+
operations: []

0 commit comments

Comments
 (0)