Skip to content

Commit

Permalink
chore(NODE-3719): adl spec compliance refactor (#3111)
Browse files Browse the repository at this point in the history
  • Loading branch information
dariakp authored Jan 20, 2022
1 parent 8970ac1 commit 1ab98f4
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 77 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
}
)
);
});
Original file line number Diff line number Diff line change
@@ -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);
});
76 changes: 0 additions & 76 deletions test/manual/data_lake.test.js

This file was deleted.

0 comments on commit 1ab98f4

Please sign in to comment.