Skip to content

GODRIVER-1686 Add tests against Atlas Data Lake #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ functions:
content_type: ${content_type|application/x-gzip}
display_name: "mongodb-logs.tar.gz"

bootstrap-mongohoused:
- command: shell.exec
params:
script: |
${PREPARE_SHELL}

cd $DRIVERS_TOOLS/.evergreen/atlas_data_lake
DRIVERS_TOOLS="${DRIVERS_TOOLS}" sh build-mongohouse-local.sh
- command: shell.exec
params:
background: true
script: |
${PREPARE_SHELL}

cd $DRIVERS_TOOLS/.evergreen/atlas_data_lake
DRIVERS_TOOLS="${DRIVERS_TOOLS}" sh run-mongohouse-local.sh

bootstrap-mongo-orchestration:
- command: shell.exec
params:
Expand Down Expand Up @@ -414,6 +431,20 @@ functions:
OCSP_TLS_SHOULD_SUCCEED="${OCSP_TLS_SHOULD_SUCCEED}" \
make evg-test-ocsp

run-atlas-data-lake-test:
- command: shell.exec
type: test
params:
working_dir: src/go.mongodb.org/mongo-driver
script: |
${PREPARE_SHELL}
set +o xtrace
AUTH="auth" \
SSL="nossl" \
TOPOLOGY="server" \
MONGODB_URI="mongodb://mhuser:pencil@localhost" \
make evg-test-atlas-data-lake

run-valid-ocsp-server:
- command: shell.exec
params:
Expand Down Expand Up @@ -1221,6 +1252,11 @@ tasks:
OCSP_ALGORITHM: "ecdsa"
OCSP_TLS_SHOULD_SUCCEED: "false"

- name: test-atlas-data-lake
commands:
- func: bootstrap-mongohoused
- func: run-atlas-data-lake-test

- name: test-replicaset-noauth-nossl
tags: ["test", "replicaset"]
commands:
Expand Down Expand Up @@ -1622,6 +1658,15 @@ buildvariants:
tasks:
- name: "atlas-test"

- name: atlas-data-lake-test
display_name: "Atlas Data Lake Test"
run_on:
- ubuntu1604-build
expansions:
GO_DIST: "/opt/golang/go1.13"
tasks:
- name: "test-atlas-data-lake"

- matrix_name: "tests-legacy-auth-ssl"
matrix_spec: { version: ["2.6", "3.0"], os-ssl-legacy: "*" }
display_name: "${version} ${os-ssl-legacy}"
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ evg-test-ocsp:
build-aws-ecs-test:
go build $(BUILD_TAGS) ./mongo/testaws/main.go

.PHONY: evg-test-atlas-data-lake
evg-test-atlas-data-lake:
ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestUnifiedSpecs/atlas-data-lake-testing >> spec_test.suite
ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestAtlasDataLake >> spec_test.suite

# benchmark specific targets and support
perf:driver-test-data.tar.gz
tar -zxf $< $(if $(eq $(UNAME_S),Darwin),-s , --transform=s)/data/perf/
Expand Down
85 changes: 85 additions & 0 deletions data/atlas-data-lake-testing/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
=====================
Atlas Data Lake Tests
=====================

.. contents::

----

Introduction
============

The YAML and JSON files in this directory tree are platform-independent tests
that drivers can use to assert compatibility with `Atlas Data Lake <https://docs.mongodb.com/datalake>`_.

Running these integration tests will require a running ``mongohoused``
with data available in its ``test.driverdata`` collection. See the
`ADL directory in drivers-evergreen-tools <https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/atlas_data_lake>`_
and `10gen/mongohouse README <https://github.com/10gen/mongohouse/blob/master/README.md>`_
for more information.

Several prose tests, which are not easily expressed in YAML, are also presented
in this file. Those tests will need to be manually implemented by each driver.

Test Format
===========

The same as the `CRUD Spec Test format <../../crud/tests/README.rst#Test-Format>`_.

Test Runner Implementation
==========================

The same as the `CRUD Spec Test Runner Implementation <../../crud/tests#test-runner-implementation>`_,
with one notable differences: the test runner for Atlas Data Lake Testing
MUST NOT drop the collection and/or database under test. In contrast to other
CRUD tests, which insert their own data fixtures into an empty collection, data
for these tests is specified in the ``mongohoused`` configuration file.

Prose Tests
===========

The following tests MUST be implemented to fully test compatibility with
Atlas Data Lake.

#. Test that the driver properly constructs and issues a
`killCursors <https://docs.mongodb.com/manual/reference/command/killCursors/>`_
command to Atlas Data Lake. For this test, configure an APM listener on a
client and execute a query on the ``test.driverdata`` collection that will
leave a cursor open on the server (e.g. specify ``batchSize=2`` for a query
that would match 3+ documents). Drivers MAY iterate the cursor if necessary
to execute the initial ``find`` command but MUST NOT iterate further to avoid
executing a ``getMore``.

Observe the CommandSucceededEvent event for the ``find`` command and extract
the cursor's ID and namespace from the response document's ``cursor.id`` and
``cursor.ns`` fields, respectively. Destroy the cursor object and observe
a CommandStartedEvent and CommandSucceededEvent for the ``killCursors``
command. Assert that the cursor ID and target namespace in the outgoing
command match the values from the ``find`` command's CommandSucceededEvent.
When matching the namespace, note that the ``killCursors`` field will contain
the collection name and the database may be inferred from either the ``$db``
field or accessed via the CommandStartedEvent directly. Finally, assert that
the ``killCursors`` CommandSucceededEvent indicates that the expected cursor
was killed in the ``cursorsKilled`` field.

Note: this test assumes that drivers only issue a ``killCursors`` command
internally when destroying a cursor that may still exist on the server. If
a driver constructs and issues ``killCursors`` commands in other ways (e.g.
public API), this test MUST be adapted to test all such code paths.

#. Test that the driver can establish a connection with Atlas Data Lake
without authentication. For these tests, create a MongoClient using a
valid connection string without auth credentials and execute a ping
command.

#. Test that the driver can establish a connection with Atlas Data Lake
with authentication. For these tests, create a MongoClient using a
valid connection string with SCRAM-SHA-1 and credentials from the
drivers-evergreen-tools ADL configuration and execute a ping command.
Repeat this test using SCRAM-SHA-256.

Changelog
=========

:2020-07-15: Link to CRUD test runner implementation and note that the collection
under test must not be dropped before each test.
53 changes: 53 additions & 0 deletions data/atlas-data-lake-testing/aggregate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"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"
}
}
}
]
}
]
}
23 changes: 23 additions & 0 deletions data/atlas-data-lake-testing/aggregate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
collection_name: &collection_name "driverdata"
database_name: &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: *collection_name
25 changes: 25 additions & 0 deletions data/atlas-data-lake-testing/estimatedDocumentCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"collection_name": "driverdata",
"database_name": "test",
"tests": [
{
"description": "estimatedDocumentCount succeeds",
"operations": [
{
"object": "collection",
"name": "estimatedDocumentCount",
"result": 15
}
],
"expectations": [
{
"command_started_event": {
"command": {
"count": "driverdata"
}
}
}
]
}
]
}
16 changes: 16 additions & 0 deletions data/atlas-data-lake-testing/estimatedDocumentCount.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
collection_name: &collection_name "driverdata"
database_name: &database_name "test"

tests:
-
description: "estimatedDocumentCount succeeds"
operations:
-
object: collection
name: estimatedDocumentCount
result: 15
expectations:
-
command_started_event:
command:
count: *collection_name
65 changes: 65 additions & 0 deletions data/atlas-data-lake-testing/find.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"collection_name": "driverdata",
"database_name": "test",
"tests": [
{
"description": "Find with projection and sort",
"operations": [
{
"object": "collection",
"name": "find",
"arguments": {
"filter": {
"b": {
"$gt": 5
}
},
"projection": {
"_id": 0
},
"sort": {
"a": 1
},
"limit": 5
},
"result": [
{
"a": 5,
"b": 6,
"c": 7
},
{
"a": 6,
"b": 7,
"c": 8
},
{
"a": 7,
"b": 8,
"c": 9
},
{
"a": 8,
"b": 9,
"c": 10
},
{
"a": 9,
"b": 10,
"c": 11
}
]
}
],
"expectations": [
{
"command_started_event": {
"command": {
"find": "driverdata"
}
}
}
]
}
]
}
27 changes: 27 additions & 0 deletions data/atlas-data-lake-testing/find.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
collection_name: &collection_name "driverdata"
database_name: &database_name "test"

tests:
-
description: "Find with projection and sort"
operations:
-
object: collection
name: find
arguments:
filter: { b: { $gt: 5 } }
projection: { _id: 0 }
sort: { a: 1 }
limit: 5
result:
- {"a": 5, "b": 6, "c": 7}
- {"a": 6, "b": 7, "c": 8}
- {"a": 7, "b": 8, "c": 9}
- {"a": 8, "b": 9, "c": 10}
- {"a": 9, "b": 10, "c": 11}
expectations:
-
command_started_event:
command:
find: *collection_name

Loading