-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NODE-840 Added CRUD specification test cases and fix minor issues wit…
…h upserts reporting matchedCount > 0
- Loading branch information
Showing
68 changed files
with
4,324 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
========== | ||
CRUD Tests | ||
========== | ||
|
||
The YAML and JSON files in this directory tree are platform-independent tests | ||
meant to exercise the translation from the API to underlying commands that | ||
MongoDB understands. Given the variety of languages and implementations and | ||
limited nature of a description of a test, there are a number of things | ||
that aren't testable. For instance, none of these tests assert that maxTimeMS | ||
was properly sent to the server. This would involve a lot of infrastructure to | ||
define and setup. Therefore, these YAML tests are in no way a replacement for | ||
more thorough testing. However, they can provide an initial verification of | ||
your implementation. | ||
|
||
|
||
Converting to JSON | ||
================== | ||
|
||
The tests are written in YAML | ||
because it is easier for humans to write and read, | ||
and because YAML includes a standard comment format. | ||
A JSONified version of each YAML file is included in this repository. | ||
Whenever you change the YAML, re-convert to JSON. | ||
One method to convert to JSON is using | ||
`yamljs <https://www.npmjs.com/package/yamljs>`_:: | ||
|
||
npm install -g yamljs | ||
yaml2json -s -p -r . | ||
|
||
Version | ||
======= | ||
|
||
Files in the "specifications" repository have no version scheme. | ||
They are not tied to a MongoDB server version, | ||
and it is our intention that each specification moves from "draft" to "final" | ||
with no further revisions; it is superseded by a future spec, not revised. | ||
|
||
However, implementers must have stable sets of tests to target. | ||
As test files evolve they will occasionally be tagged like | ||
"crud-tests-YYYY-MM-DD", until the spec is final. | ||
|
||
Format | ||
====== | ||
|
||
Each YAML file has the following keys: | ||
|
||
- data: The data that should exist in the collection under test before each test run. | ||
- minServerVersion: OPTIONAL: The minimum server version required to successfully run the test. If this field is not | ||
present, it should be assumed that there is no lower bound on the server version required. | ||
- maxServerVersion: OPTIONAL: The max server version against which this test can run successfully. If this field is not | ||
present, it should be assumed that there is no upper bound on the server version required. | ||
- tests: | ||
An array of tests that are to be run independently of each other. Each test will | ||
have some or all of the following fields | ||
|
||
- description: The name of the test | ||
- operation: | ||
|
||
- name: The name of the operation as defined in the specification. | ||
- arguments: The names and values of arguments from the specification. | ||
- outcome: | ||
|
||
- result: The return value from the operation. | ||
- collection: | ||
|
||
- name: OPTIONAL: The collection name to verify. If this isn't present | ||
then use the collection under test. | ||
- data: The data that should exist in the collection after the | ||
operation has been run. | ||
|
||
|
||
Use as integration tests | ||
======================== | ||
|
||
Running these as integration tests will require a running mongod server. | ||
Each of these tests is valid against a standalone mongod, a replica set, and a | ||
sharded system for server version 3.0.0. Many of them will run against 2.4 and | ||
2.6, but some will require conditional code. For instance, $out is not supported | ||
in an aggregation pipeline in server 2.4, so that test must be skipped. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"_id": 1, | ||
"x": "ping" | ||
} | ||
], | ||
"minServerVersion": "3.4", | ||
"tests": [ | ||
{ | ||
"description": "Aggregate with collation", | ||
"operation": { | ||
"arguments": { | ||
"collation": { | ||
"locale": "en_US", | ||
"strength": 2 | ||
}, | ||
"pipeline": [ | ||
{ | ||
"$match": { | ||
"x": "PING" | ||
} | ||
} | ||
] | ||
}, | ||
"name": "aggregate" | ||
}, | ||
"outcome": { | ||
"result": [ | ||
{ | ||
"_id": 1, | ||
"x": "ping" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
data: | ||
- {_id: 1, x: 'ping'} | ||
minServerVersion: '3.4' | ||
|
||
tests: | ||
- | ||
description: "Aggregate with collation" | ||
operation: | ||
name: aggregate | ||
arguments: | ||
pipeline: | ||
- $match: | ||
x: 'PING' | ||
collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document | ||
outcome: | ||
result: | ||
- {_id: 1, x: 'ping'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"_id": 1, | ||
"x": 11 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 33 | ||
} | ||
], | ||
"minServerVersion": "2.6", | ||
"tests": [ | ||
{ | ||
"description": "Aggregate with $out", | ||
"operation": { | ||
"arguments": { | ||
"batchSize": 2, | ||
"pipeline": [ | ||
{ | ||
"$sort": { | ||
"x": 1 | ||
} | ||
}, | ||
{ | ||
"$match": { | ||
"_id": { | ||
"$gt": 1 | ||
} | ||
} | ||
}, | ||
{ | ||
"$out": "other_test_collection" | ||
} | ||
] | ||
}, | ||
"name": "aggregate" | ||
}, | ||
"outcome": { | ||
"collection": { | ||
"data": [ | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 33 | ||
} | ||
], | ||
"name": "other_test_collection" | ||
}, | ||
"result": [ | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 33 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
data: | ||
- {_id: 1, x: 11} | ||
- {_id: 2, x: 22} | ||
- {_id: 3, x: 33} | ||
minServerVersion: '2.6' | ||
|
||
tests: | ||
- | ||
description: "Aggregate with $out" | ||
operation: | ||
name: aggregate | ||
arguments: | ||
pipeline: | ||
- $sort: {x: 1} | ||
- $match: | ||
_id: {$gt: 1} | ||
- $out: "other_test_collection" | ||
batchSize: 2 | ||
|
||
outcome: | ||
result: | ||
- {_id: 2, x: 22} | ||
- {_id: 3, x: 33} | ||
collection: | ||
name: "other_test_collection" | ||
data: | ||
- {_id: 2, x: 22} | ||
- {_id: 3, x: 33} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"_id": 1, | ||
"x": 11 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 33 | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "Aggregate with multiple stages", | ||
"operation": { | ||
"arguments": { | ||
"batchSize": 2, | ||
"pipeline": [ | ||
{ | ||
"$sort": { | ||
"x": 1 | ||
} | ||
}, | ||
{ | ||
"$match": { | ||
"_id": { | ||
"$gt": 1 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"name": "aggregate" | ||
}, | ||
"outcome": { | ||
"result": [ | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 33 | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.
Is this a breaking change? Made an issue on the JIRA for it here.