Skip to content

Commit 46d5d76

Browse files
author
Divjot Arora
authored
GODRIVER-1686 Add tests against Atlas Data Lake (#462)
1 parent bc196cf commit 46d5d76

23 files changed

+732
-19
lines changed

.evergreen/config.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,23 @@ functions:
162162
content_type: ${content_type|application/x-gzip}
163163
display_name: "mongodb-logs.tar.gz"
164164

165+
bootstrap-mongohoused:
166+
- command: shell.exec
167+
params:
168+
script: |
169+
${PREPARE_SHELL}
170+
171+
cd $DRIVERS_TOOLS/.evergreen/atlas_data_lake
172+
DRIVERS_TOOLS="${DRIVERS_TOOLS}" sh build-mongohouse-local.sh
173+
- command: shell.exec
174+
params:
175+
background: true
176+
script: |
177+
${PREPARE_SHELL}
178+
179+
cd $DRIVERS_TOOLS/.evergreen/atlas_data_lake
180+
DRIVERS_TOOLS="${DRIVERS_TOOLS}" sh run-mongohouse-local.sh
181+
165182
bootstrap-mongo-orchestration:
166183
- command: shell.exec
167184
params:
@@ -414,6 +431,20 @@ functions:
414431
OCSP_TLS_SHOULD_SUCCEED="${OCSP_TLS_SHOULD_SUCCEED}" \
415432
make evg-test-ocsp
416433
434+
run-atlas-data-lake-test:
435+
- command: shell.exec
436+
type: test
437+
params:
438+
working_dir: src/go.mongodb.org/mongo-driver
439+
script: |
440+
${PREPARE_SHELL}
441+
set +o xtrace
442+
AUTH="auth" \
443+
SSL="nossl" \
444+
TOPOLOGY="server" \
445+
MONGODB_URI="mongodb://mhuser:pencil@localhost" \
446+
make evg-test-atlas-data-lake
447+
417448
run-valid-ocsp-server:
418449
- command: shell.exec
419450
params:
@@ -1221,6 +1252,11 @@ tasks:
12211252
OCSP_ALGORITHM: "ecdsa"
12221253
OCSP_TLS_SHOULD_SUCCEED: "false"
12231254

1255+
- name: test-atlas-data-lake
1256+
commands:
1257+
- func: bootstrap-mongohoused
1258+
- func: run-atlas-data-lake-test
1259+
12241260
- name: test-replicaset-noauth-nossl
12251261
tags: ["test", "replicaset"]
12261262
commands:
@@ -1622,6 +1658,15 @@ buildvariants:
16221658
tasks:
16231659
- name: "atlas-test"
16241660

1661+
- name: atlas-data-lake-test
1662+
display_name: "Atlas Data Lake Test"
1663+
run_on:
1664+
- ubuntu1604-build
1665+
expansions:
1666+
GO_DIST: "/opt/golang/go1.13"
1667+
tasks:
1668+
- name: "test-atlas-data-lake"
1669+
16251670
- matrix_name: "tests-legacy-auth-ssl"
16261671
matrix_spec: { version: ["2.6", "3.0"], os-ssl-legacy: "*" }
16271672
display_name: "${version} ${os-ssl-legacy}"

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ evg-test-ocsp:
152152
build-aws-ecs-test:
153153
go build $(BUILD_TAGS) ./mongo/testaws/main.go
154154

155+
.PHONY: evg-test-atlas-data-lake
156+
evg-test-atlas-data-lake:
157+
ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestUnifiedSpecs/atlas-data-lake-testing >> spec_test.suite
158+
ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestAtlasDataLake >> spec_test.suite
159+
155160
# benchmark specific targets and support
156161
perf:driver-test-data.tar.gz
157162
tar -zxf $< $(if $(eq $(UNAME_S),Darwin),-s , --transform=s)/data/perf/
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
=====================
2+
Atlas Data Lake Tests
3+
=====================
4+
5+
.. contents::
6+
7+
----
8+
9+
Introduction
10+
============
11+
12+
The YAML and JSON files in this directory tree are platform-independent tests
13+
that drivers can use to assert compatibility with `Atlas Data Lake <https://docs.mongodb.com/datalake>`_.
14+
15+
Running these integration tests will require a running ``mongohoused``
16+
with data available in its ``test.driverdata`` collection. See the
17+
`ADL directory in drivers-evergreen-tools <https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/atlas_data_lake>`_
18+
and `10gen/mongohouse README <https://github.com/10gen/mongohouse/blob/master/README.md>`_
19+
for more information.
20+
21+
Several prose tests, which are not easily expressed in YAML, are also presented
22+
in this file. Those tests will need to be manually implemented by each driver.
23+
24+
Test Format
25+
===========
26+
27+
The same as the `CRUD Spec Test format <../../crud/tests/README.rst#Test-Format>`_.
28+
29+
Test Runner Implementation
30+
==========================
31+
32+
The same as the `CRUD Spec Test Runner Implementation <../../crud/tests#test-runner-implementation>`_,
33+
with one notable differences: the test runner for Atlas Data Lake Testing
34+
MUST NOT drop the collection and/or database under test. In contrast to other
35+
CRUD tests, which insert their own data fixtures into an empty collection, data
36+
for these tests is specified in the ``mongohoused`` configuration file.
37+
38+
Prose Tests
39+
===========
40+
41+
The following tests MUST be implemented to fully test compatibility with
42+
Atlas Data Lake.
43+
44+
#. Test that the driver properly constructs and issues a
45+
`killCursors <https://docs.mongodb.com/manual/reference/command/killCursors/>`_
46+
command to Atlas Data Lake. For this test, configure an APM listener on a
47+
client and execute a query on the ``test.driverdata`` collection that will
48+
leave a cursor open on the server (e.g. specify ``batchSize=2`` for a query
49+
that would match 3+ documents). Drivers MAY iterate the cursor if necessary
50+
to execute the initial ``find`` command but MUST NOT iterate further to avoid
51+
executing a ``getMore``.
52+
53+
Observe the CommandSucceededEvent event for the ``find`` command and extract
54+
the cursor's ID and namespace from the response document's ``cursor.id`` and
55+
``cursor.ns`` fields, respectively. Destroy the cursor object and observe
56+
a CommandStartedEvent and CommandSucceededEvent for the ``killCursors``
57+
command. Assert that the cursor ID and target namespace in the outgoing
58+
command match the values from the ``find`` command's CommandSucceededEvent.
59+
When matching the namespace, note that the ``killCursors`` field will contain
60+
the collection name and the database may be inferred from either the ``$db``
61+
field or accessed via the CommandStartedEvent directly. Finally, assert that
62+
the ``killCursors`` CommandSucceededEvent indicates that the expected cursor
63+
was killed in the ``cursorsKilled`` field.
64+
65+
Note: this test assumes that drivers only issue a ``killCursors`` command
66+
internally when destroying a cursor that may still exist on the server. If
67+
a driver constructs and issues ``killCursors`` commands in other ways (e.g.
68+
public API), this test MUST be adapted to test all such code paths.
69+
70+
#. Test that the driver can establish a connection with Atlas Data Lake
71+
without authentication. For these tests, create a MongoClient using a
72+
valid connection string without auth credentials and execute a ping
73+
command.
74+
75+
#. Test that the driver can establish a connection with Atlas Data Lake
76+
with authentication. For these tests, create a MongoClient using a
77+
valid connection string with SCRAM-SHA-1 and credentials from the
78+
drivers-evergreen-tools ADL configuration and execute a ping command.
79+
Repeat this test using SCRAM-SHA-256.
80+
81+
Changelog
82+
=========
83+
84+
:2020-07-15: Link to CRUD test runner implementation and note that the collection
85+
under test must not be dropped before each test.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "Aggregate with pipeline (project, sort, limit)",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "aggregate",
11+
"arguments": {
12+
"pipeline": [
13+
{
14+
"$project": {
15+
"_id": 0
16+
}
17+
},
18+
{
19+
"$sort": {
20+
"a": 1
21+
}
22+
},
23+
{
24+
"$limit": 2
25+
}
26+
]
27+
},
28+
"result": [
29+
{
30+
"a": 1,
31+
"b": 2,
32+
"c": 3
33+
},
34+
{
35+
"a": 2,
36+
"b": 3,
37+
"c": 4
38+
}
39+
]
40+
}
41+
],
42+
"expectations": [
43+
{
44+
"command_started_event": {
45+
"command": {
46+
"aggregate": "driverdata"
47+
}
48+
}
49+
}
50+
]
51+
}
52+
]
53+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
collection_name: &collection_name "driverdata"
2+
database_name: &database_name "test"
3+
4+
tests:
5+
-
6+
description: "Aggregate with pipeline (project, sort, limit)"
7+
operations:
8+
-
9+
object: collection
10+
name: aggregate
11+
arguments:
12+
pipeline:
13+
- $project: { _id: 0 }
14+
- $sort: { a: 1 }
15+
- $limit: 2
16+
result:
17+
- { a: 1, b: 2, c: 3 }
18+
- { a: 2, b: 3, c: 4 }
19+
expectations:
20+
-
21+
command_started_event:
22+
command:
23+
aggregate: *collection_name
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "estimatedDocumentCount succeeds",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "estimatedDocumentCount",
11+
"result": 15
12+
}
13+
],
14+
"expectations": [
15+
{
16+
"command_started_event": {
17+
"command": {
18+
"count": "driverdata"
19+
}
20+
}
21+
}
22+
]
23+
}
24+
]
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
collection_name: &collection_name "driverdata"
2+
database_name: &database_name "test"
3+
4+
tests:
5+
-
6+
description: "estimatedDocumentCount succeeds"
7+
operations:
8+
-
9+
object: collection
10+
name: estimatedDocumentCount
11+
result: 15
12+
expectations:
13+
-
14+
command_started_event:
15+
command:
16+
count: *collection_name
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"collection_name": "driverdata",
3+
"database_name": "test",
4+
"tests": [
5+
{
6+
"description": "Find with projection and sort",
7+
"operations": [
8+
{
9+
"object": "collection",
10+
"name": "find",
11+
"arguments": {
12+
"filter": {
13+
"b": {
14+
"$gt": 5
15+
}
16+
},
17+
"projection": {
18+
"_id": 0
19+
},
20+
"sort": {
21+
"a": 1
22+
},
23+
"limit": 5
24+
},
25+
"result": [
26+
{
27+
"a": 5,
28+
"b": 6,
29+
"c": 7
30+
},
31+
{
32+
"a": 6,
33+
"b": 7,
34+
"c": 8
35+
},
36+
{
37+
"a": 7,
38+
"b": 8,
39+
"c": 9
40+
},
41+
{
42+
"a": 8,
43+
"b": 9,
44+
"c": 10
45+
},
46+
{
47+
"a": 9,
48+
"b": 10,
49+
"c": 11
50+
}
51+
]
52+
}
53+
],
54+
"expectations": [
55+
{
56+
"command_started_event": {
57+
"command": {
58+
"find": "driverdata"
59+
}
60+
}
61+
}
62+
]
63+
}
64+
]
65+
}

data/atlas-data-lake-testing/find.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
collection_name: &collection_name "driverdata"
2+
database_name: &database_name "test"
3+
4+
tests:
5+
-
6+
description: "Find with projection and sort"
7+
operations:
8+
-
9+
object: collection
10+
name: find
11+
arguments:
12+
filter: { b: { $gt: 5 } }
13+
projection: { _id: 0 }
14+
sort: { a: 1 }
15+
limit: 5
16+
result:
17+
- {"a": 5, "b": 6, "c": 7}
18+
- {"a": 6, "b": 7, "c": 8}
19+
- {"a": 7, "b": 8, "c": 9}
20+
- {"a": 8, "b": 9, "c": 10}
21+
- {"a": 9, "b": 10, "c": 11}
22+
expectations:
23+
-
24+
command_started_event:
25+
command:
26+
find: *collection_name
27+

0 commit comments

Comments
 (0)