Skip to content

Commit 1ab98f4

Browse files
authored
chore(NODE-3719): adl spec compliance refactor (#3111)
1 parent 8970ac1 commit 1ab98f4

File tree

4 files changed

+109
-77
lines changed

4 files changed

+109
-77
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"check:unit": "mocha test/unit/",
109109
"check:ts": "./node_modules/typescript/bin/tsc -v && ./node_modules/typescript/bin/tsc --noEmit",
110110
"check:atlas": "mocha --config \"test/manual/mocharc.json\" test/manual/atlas_connectivity.test.js",
111-
"check:adl": "mocha --file test/tools/runner test/manual/data_lake.test.js",
111+
"check:adl": "mocha --file test/tools/runner test/manual/atlas-data-lake-testing",
112112
"check:aws": "mocha --file test/tools/runner test/integration/auth/mongodb_aws.test.js",
113113
"check:ocsp": "mocha --config \"test/manual/mocharc.json\" test/manual/ocsp_support.test.js",
114114
"check:kerberos": "mocha --config \"test/manual/mocharc.json\" test/manual/kerberos.test.js",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
'use strict';
2+
const { expect } = require('chai');
3+
const { withClient } = require('../../integration/shared');
4+
5+
// TODO(NODE-3880): These tests are not fully implemented per the spec
6+
describe('Atlas Data Lake - prose', function () {
7+
it(
8+
'1. Test that the driver properly constructs and issues a killCursors command to Atlas Data Lake.',
9+
/**
10+
* For this test, configure an APM listener on a client and execute a query on the test.driverdata collection
11+
* that will leave a cursor open on the server (e.g. specify batchSize=2 for a query that would match 3+ documents).
12+
* Drivers MAY iterate the cursor if necessary to execute the initial find command but MUST NOT iterate further to avoid executing a getMore.
13+
*
14+
* Observe the CommandSucceededEvent event for the find command and extract the cursor's ID and namespace from the response document's cursor.id
15+
* and cursor.ns fields, respectively. Destroy the cursor object and observe a CommandStartedEvent and CommandSucceededEvent for the killCursors command.
16+
*
17+
* Assert that the cursor ID and target namespace in the outgoing command match the values from the find command's CommandSucceededEvent.
18+
* When matching the namespace, note that the killCursors field will contain the collection name and the database may be inferred from either
19+
* the $db field or accessed via the CommandStartedEvent directly.
20+
*
21+
* Finally, assert that the killCursors CommandSucceededEvent indicates that the expected cursor was killed in the cursorsKilled field.
22+
*
23+
* Note: this test assumes that drivers only issue a killCursors command internally when destroying a cursor that may still exist on the server.
24+
* 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.
25+
*/
26+
withClient('mongodb://mhuser:pencil@localhost', function (client, done) {
27+
const db = client.db('admin');
28+
db.command({ killCursors: 'kill_cursor_collection' }, err => {
29+
expect(err).to.not.exist;
30+
done();
31+
});
32+
})
33+
);
34+
35+
it(
36+
'2. Test that the driver can establish a connection with Atlas Data Lake without authentication.',
37+
/**
38+
* For these tests, create a MongoClient using a valid connection string without auth credentials and execute a ping command.
39+
*/
40+
withClient('mongodb://localhost', function (client, done) {
41+
expect(client).to.exist;
42+
done();
43+
})
44+
);
45+
46+
it(
47+
'3a. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-1)',
48+
/**
49+
* For these tests, create a MongoClient using a valid connection string with SCRAM-SHA-1 and credentials
50+
* from the drivers-evergreen-tools ADL configuration and execute a ping command.
51+
*/
52+
withClient(
53+
'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-1',
54+
function (client, done) {
55+
const db = client.db('admin');
56+
db.command({ killCursors: 'kill_cursor_collection' }, err => {
57+
expect(err).to.not.exist;
58+
done();
59+
});
60+
}
61+
)
62+
);
63+
64+
it(
65+
'3b. Test that the driver can establish a connection with Atlas Data Lake with authentication. (SCRAM-SHA-256)',
66+
/**
67+
* Repeat the authentication test using SCRAM-SHA-256.
68+
*/
69+
withClient(
70+
'mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-256',
71+
function (client, done) {
72+
const db = client.db('admin');
73+
db.command({ killCursors: 'kill_cursor_collection' }, err => {
74+
expect(err).to.not.exist;
75+
done();
76+
});
77+
}
78+
)
79+
);
80+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const path = require('path');
3+
const {
4+
TestRunnerContext,
5+
gatherTestSuites,
6+
generateTopologyTests
7+
} = require('../../tools/spec-runner');
8+
9+
describe('Atlas Data Lake - spec', function () {
10+
const testContext = new TestRunnerContext({
11+
skipPrepareDatabase: true,
12+
useSessions: false,
13+
user: 'mhuser',
14+
password: 'pencil',
15+
authSource: 'admin'
16+
});
17+
18+
const testSuites = gatherTestSuites(
19+
path.resolve(__dirname, '../../spec/atlas-data-lake-testing')
20+
);
21+
22+
after(() => testContext.teardown());
23+
before(function () {
24+
return testContext.setup(this.configuration);
25+
});
26+
27+
generateTopologyTests(testSuites, testContext);
28+
});

test/manual/data_lake.test.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)