From 1ab98f4ccfdf20568d8e7f62a6b883a2cf5517ca Mon Sep 17 00:00:00 2001 From: Daria Pardue Date: Thu, 20 Jan 2022 17:04:38 -0500 Subject: [PATCH] chore(NODE-3719): adl spec compliance refactor (#3111) --- package.json | 2 +- .../atlas_data_lake_testing.prose.js | 80 +++++++++++++++++++ .../atlas_data_lake_testing.spec.js | 28 +++++++ test/manual/data_lake.test.js | 76 ------------------ 4 files changed, 109 insertions(+), 77 deletions(-) create mode 100644 test/manual/atlas-data-lake-testing/atlas_data_lake_testing.prose.js create mode 100644 test/manual/atlas-data-lake-testing/atlas_data_lake_testing.spec.js delete mode 100644 test/manual/data_lake.test.js diff --git a/package.json b/package.json index 811f41d9af..d4b1b2441a 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "check:unit": "mocha test/unit/", "check:ts": "./node_modules/typescript/bin/tsc -v && ./node_modules/typescript/bin/tsc --noEmit", "check:atlas": "mocha --config \"test/manual/mocharc.json\" test/manual/atlas_connectivity.test.js", - "check:adl": "mocha --file test/tools/runner test/manual/data_lake.test.js", + "check:adl": "mocha --file test/tools/runner test/manual/atlas-data-lake-testing", "check:aws": "mocha --file test/tools/runner test/integration/auth/mongodb_aws.test.js", "check:ocsp": "mocha --config \"test/manual/mocharc.json\" test/manual/ocsp_support.test.js", "check:kerberos": "mocha --config \"test/manual/mocharc.json\" test/manual/kerberos.test.js", diff --git a/test/manual/atlas-data-lake-testing/atlas_data_lake_testing.prose.js b/test/manual/atlas-data-lake-testing/atlas_data_lake_testing.prose.js new file mode 100644 index 0000000000..584e823a25 --- /dev/null +++ b/test/manual/atlas-data-lake-testing/atlas_data_lake_testing.prose.js @@ -0,0 +1,80 @@ +'use strict'; +const { expect } = require('chai'); +const { withClient } = require('../../integration/shared'); + +// TODO(NODE-3880): These tests are not fully implemented per the spec +describe('Atlas Data Lake - prose', function () { + it( + '1. Test that the driver properly constructs and issues a 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. + */ + withClient('mongodb://mhuser:pencil@localhost', function (client, done) { + const db = client.db('admin'); + db.command({ killCursors: 'kill_cursor_collection' }, err => { + expect(err).to.not.exist; + done(); + }); + }) + ); + + it( + '2. 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. + */ + withClient('mongodb://localhost', function (client, done) { + expect(client).to.exist; + done(); + }) + ); + + it( + '3a. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-1)', + /** + * 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. + */ + withClient( + 'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-1', + function (client, done) { + const db = client.db('admin'); + db.command({ killCursors: 'kill_cursor_collection' }, err => { + expect(err).to.not.exist; + done(); + }); + } + ) + ); + + it( + '3b. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-256)', + /** + * Repeat the authentication test using SCRAM-SHA-256. + */ + withClient( + 'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-256', + function (client, done) { + const db = client.db('admin'); + db.command({ killCursors: 'kill_cursor_collection' }, err => { + expect(err).to.not.exist; + done(); + }); + } + ) + ); +}); diff --git a/test/manual/atlas-data-lake-testing/atlas_data_lake_testing.spec.js b/test/manual/atlas-data-lake-testing/atlas_data_lake_testing.spec.js new file mode 100644 index 0000000000..f374213399 --- /dev/null +++ b/test/manual/atlas-data-lake-testing/atlas_data_lake_testing.spec.js @@ -0,0 +1,28 @@ +'use strict'; +const path = require('path'); +const { + TestRunnerContext, + gatherTestSuites, + generateTopologyTests +} = require('../../tools/spec-runner'); + +describe('Atlas Data Lake - spec', function () { + const testContext = new TestRunnerContext({ + skipPrepareDatabase: true, + useSessions: false, + user: 'mhuser', + password: 'pencil', + authSource: 'admin' + }); + + const testSuites = gatherTestSuites( + path.resolve(__dirname, '../../spec/atlas-data-lake-testing') + ); + + after(() => testContext.teardown()); + before(function () { + return testContext.setup(this.configuration); + }); + + generateTopologyTests(testSuites, testContext); +}); diff --git a/test/manual/data_lake.test.js b/test/manual/data_lake.test.js deleted file mode 100644 index ea66202088..0000000000 --- a/test/manual/data_lake.test.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict'; -const { expect } = require('chai'); -const path = require('path'); -const { - TestRunnerContext, - gatherTestSuites, - generateTopologyTests -} = require('../tools/spec-runner'); -const { withClient } = require('../integration/shared'); - -describe('Atlas Data Lake', function () { - context('spec tests', function () { - const testContext = new TestRunnerContext({ - skipPrepareDatabase: true, - useSessions: false, - user: 'mhuser', - password: 'pencil', - authSource: 'admin' - }); - - let testSuites = gatherTestSuites(path.resolve(__dirname, '../spec/atlas-data-lake-testing')); - - after(() => testContext.teardown()); - before(function () { - return testContext.setup(this.configuration); - }); - - generateTopologyTests(testSuites, testContext); - }); - - describe('prose Tests', function () { - it( - 'should properly constructs and issues a killCursors command', - withClient('mongodb://mhuser:pencil@localhost', function (client, done) { - const db = client.db('admin'); - db.command({ killCursors: 'kill_cursor_collection' }, err => { - expect(err).to.not.exist; - done(); - }); - }) - ); - it( - 'should connect without authentication', - withClient('mongodb://localhost', function (client, done) { - expect(client).to.exist; - done(); - }) - ); - it( - 'should connect with auth SCRAM-SHA-1', - withClient( - 'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-1', - function (client, done) { - const db = client.db('admin'); - db.command({ killCursors: 'kill_cursor_collection' }, err => { - expect(err).to.not.exist; - done(); - }); - } - ) - ); - it( - 'should connect with auth SCRAM-SHA-256', - withClient( - 'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-256', - function (client, done) { - const db = client.db('admin'); - db.command({ killCursors: 'kill_cursor_collection' }, err => { - expect(err).to.not.exist; - done(); - }); - } - ) - ); - }); -});