Skip to content

Commit 2704ce8

Browse files
author
Thomas Reggi
authored
test: adds tests for atlas data lake
NODE-2691
1 parent 3155bcc commit 2704ce8

23 files changed

+626
-28
lines changed

.evergreen/config.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ functions:
8383
- command: expansions.update
8484
params:
8585
file: mo-expansion.yml
86+
bootstrap mongohoused:
87+
- command: shell.exec
88+
params:
89+
script: |
90+
${PREPARE_SHELL}
91+
DRIVERS_TOOLS="${DRIVERS_TOOLS}" bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/build-mongohouse-local.sh
92+
- command: shell.exec
93+
params:
94+
background: true
95+
script: |
96+
${PREPARE_SHELL}
97+
DRIVERS_TOOLS="${DRIVERS_TOOLS}" bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/run-mongohouse-local.sh
8698
run tests:
8799
- command: shell.exec
88100
type: test
@@ -189,6 +201,15 @@ functions:
189201
script: |
190202
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
191203
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh
204+
run data lake tests:
205+
- command: shell.exec
206+
type: test
207+
params:
208+
working_dir: src
209+
script: |
210+
${PREPARE_SHELL}
211+
MONGODB_URI='mongodb://mhuser:pencil@localhost' NODE_LTS_NAME='${NODE_LTS_NAME}' \
212+
bash ${PROJECT_DIRECTORY}/.evergreen/run-data-lake-tests.sh
192213
run tls tests:
193214
- command: shell.exec
194215
type: test
@@ -723,6 +744,11 @@ tasks:
723744
commands:
724745
- func: install dependencies
725746
- func: run atlas tests
747+
- name: test-atlas-data-lake
748+
commands:
749+
- func: install dependencies
750+
- func: bootstrap mongohoused
751+
- func: run data lake tests
726752
- name: test-auth-kerberos
727753
tags:
728754
- auth
@@ -1111,6 +1137,7 @@ buildvariants:
11111137
- test-2.6-replica_set
11121138
- test-2.6-sharded_cluster
11131139
- test-atlas-connectivity
1140+
- test-atlas-data-lake
11141141
- test-auth-kerberos
11151142
- test-auth-ldap
11161143
- test-tls-support
@@ -1178,6 +1205,7 @@ buildvariants:
11781205
- test-2.6-replica_set
11791206
- test-2.6-sharded_cluster
11801207
- test-atlas-connectivity
1208+
- test-atlas-data-lake
11811209
- test-auth-kerberos
11821210
- test-auth-ldap
11831211
- name: ubuntu-14.04-erbium
@@ -1215,6 +1243,7 @@ buildvariants:
12151243
- test-3.2-replica_set
12161244
- test-3.2-sharded_cluster
12171245
- test-atlas-connectivity
1246+
- test-atlas-data-lake
12181247
- test-auth-kerberos
12191248
- test-auth-ldap
12201249
- test-tls-support

.evergreen/config.yml.in

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ functions:
103103
params:
104104
file: mo-expansion.yml
105105

106+
bootstrap mongohoused:
107+
- command: shell.exec
108+
params:
109+
script: |
110+
${PREPARE_SHELL}
111+
DRIVERS_TOOLS="${DRIVERS_TOOLS}" bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/build-mongohouse-local.sh
112+
- command: shell.exec
113+
params:
114+
background: true
115+
script: |
116+
${PREPARE_SHELL}
117+
DRIVERS_TOOLS="${DRIVERS_TOOLS}" bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/run-mongohouse-local.sh
118+
106119
"run tests":
107120
- command: shell.exec
108121
type: test
@@ -229,8 +242,15 @@ functions:
229242
script: |
230243
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
231244
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh
232-
233-
"run tls tests":
245+
run data lake tests:
246+
- command: shell.exec
247+
type: test
248+
params:
249+
working_dir: src
250+
script: |
251+
MONGODB_URI='mongodb://mhuser:pencil@localhost' NODE_LTS_NAME='${NODE_LTS_NAME}' \
252+
bash ${PROJECT_DIRECTORY}/.evergreen/run-data-lake-tests.sh
253+
"run tls tests":
234254
- command: shell.exec
235255
type: test
236256
params:
@@ -424,7 +444,7 @@ functions:
424444
UNIFIED=${UNIFIED} \
425445
CA_FILE="$DRIVERS_TOOLS/.evergreen/ocsp/rsa/ca.pem" \
426446
OCSP_TLS_SHOULD_SUCCEED="${OCSP_TLS_SHOULD_SUCCEED}" \
427-
sh ${PROJECT_DIRECTORY}/.evergreen/run-ocsp-tests.sh
447+
bash ${PROJECT_DIRECTORY}/.evergreen/run-ocsp-tests.sh
428448

429449
run-valid-ocsp-server:
430450
- command: shell.exec

.evergreen/generate_evergreen_tasks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ Array.prototype.push.apply(TASKS, [
101101
{ func: 'run atlas tests' }
102102
]
103103
},
104+
{
105+
name: "test-atlas-data-lake",
106+
commands: [
107+
{ func: 'install dependencies' },
108+
{ func: 'bootstrap mongohoused' },
109+
{ func: 'run data lake tests' }
110+
]
111+
},
104112
{
105113
name: 'test-auth-kerberos',
106114
tags: ['auth', 'kerberos'],

.evergreen/run-data-lake-tests.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
export PROJECT_DIRECTORY="$(pwd)"
6+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
7+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
8+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
9+
10+
echo $MONGODB_URI;
11+
npm run check:adl

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"check:test": "mocha --recursive test/functional test/unit",
9797
"check:ts": "tsc -v && tsc --noEmit",
9898
"check:atlas": "mocha --config \"test/manual/mocharc.json\" test/manual/atlas_connectivity.test.js",
99+
"check:adl": "mocha test/manual/data_lake.test.js",
99100
"check:ocsp": "mocha --config \"test/manual/mocharc.json\" test/manual/ocsp_support.test.js",
100101
"check:kerberos": "mocha --config \"test/manual/mocharc.json\" test/manual/kerberos.test.js",
101102
"check:tls": "mocha --config \"test/manual/mocharc.json\" test/manual/tls_support.test.js",

test/functional/spec-runner/context.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,18 @@ class Thread {
3030
}
3131

3232
class TestRunnerContext {
33-
constructor() {
34-
this.url = null;
33+
constructor(opts) {
34+
const defaults = {
35+
password: undefined,
36+
user: undefined,
37+
useSessions: true,
38+
skipPrepareDatabase: false
39+
};
40+
opts = Object.assign({}, defaults, opts || {});
41+
this.skipPrepareDatabase = opts.skipPrepareDatabase;
42+
this.useSessions = opts.useSessions;
43+
this.user = opts.user;
44+
this.password = opts.password;
3545
this.sharedClient = null;
3646
this.failPointClients = [];
3747
this.appliedFailPoints = [];
@@ -57,9 +67,8 @@ class TestRunnerContext {
5767

5868
setup(config) {
5969
this.sharedClient = config.newClient(
60-
resolveConnectionString(config, { useMultipleMongoses: true })
70+
resolveConnectionString(config, { useMultipleMongoses: true }, this)
6171
);
62-
6372
if (config.topologyType === 'Sharded') {
6473
this.failPointClients = config.options.hosts.map(proxy =>
6574
config.newClient(`mongodb://${proxy.host}:${proxy.port}/`)

test/functional/spec-runner/index.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ function generateTopologyTests(testSuites, testContext, filter) {
149149
if (spec.failPoint) {
150150
testPromise = testPromise.then(() => testContext.disableFailPoint(spec.failPoint));
151151
}
152-
153152
return testPromise.then(() => validateOutcome(spec, testContext));
154153
});
155154
});
@@ -165,6 +164,9 @@ function prepareDatabaseForSuite(suite, context) {
165164
context.collectionName = suite.collection_name || 'spec_collection';
166165

167166
const db = context.sharedClient.db(context.dbName);
167+
168+
if (context.skipPrepareDatabase) return Promise.resolve();
169+
168170
const setupPromise = db
169171
.admin()
170172
.command({ killAllSessions: [] })
@@ -279,15 +281,22 @@ function runTestSuiteTest(configuration, spec, context) {
279281
)
280282
);
281283

282-
const url = resolveConnectionString(configuration, spec);
284+
const url = resolveConnectionString(configuration, spec, context);
283285
const client = configuration.newClient(url, clientOptions);
284286
CMAP_EVENTS.forEach(eventName => client.on(eventName, event => context.cmapEvents.push(event)));
285287
SDAM_EVENTS.forEach(eventName => client.on(eventName, event => context.sdamEvents.push(event)));
288+
let pingTracker = 0;
286289
client.on('commandStarted', event => {
287290
if (IGNORED_COMMANDS.has(event.commandName)) {
288291
return;
289292
}
290293

294+
// This gets rid of the first ping command
295+
if (event.commandName === 'ping') {
296+
pingTracker++;
297+
if (pingTracker === 1) return;
298+
}
299+
291300
context.commandEvents.push(event);
292301

293302
// very useful for debugging
@@ -305,22 +314,24 @@ function runTestSuiteTest(configuration, spec, context) {
305314

306315
let session0, session1;
307316
let savedSessionData;
308-
try {
309-
session0 = client.startSession(
310-
Object.assign({}, sessionOptions, parseSessionOptions(spec.sessionOptions.session0))
311-
);
312-
session1 = client.startSession(
313-
Object.assign({}, sessionOptions, parseSessionOptions(spec.sessionOptions.session1))
314-
);
315317

316-
savedSessionData = {
317-
session0: JSON.parse(EJSON.stringify(session0.id)),
318-
session1: JSON.parse(EJSON.stringify(session1.id))
319-
};
320-
} catch (err) {
321-
// ignore
322-
}
318+
if (context.useSessions) {
319+
try {
320+
session0 = client.startSession(
321+
Object.assign({}, sessionOptions, parseSessionOptions(spec.sessionOptions.session0))
322+
);
323+
session1 = client.startSession(
324+
Object.assign({}, sessionOptions, parseSessionOptions(spec.sessionOptions.session1))
325+
);
323326

327+
savedSessionData = {
328+
session0: JSON.parse(EJSON.stringify(session0.id)),
329+
session1: JSON.parse(EJSON.stringify(session1.id))
330+
};
331+
} catch (err) {
332+
// ignore
333+
}
334+
}
324335
// enable to see useful APM debug information at the time of actual test run
325336
// displayCommands = true;
326337

test/functional/spec-runner/utils.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
'use strict';
22

3-
function resolveConnectionString(configuration, spec) {
3+
function resolveConnectionString(configuration, spec, context) {
44
const isShardedEnvironment = configuration.topologyType === 'Sharded';
55
const useMultipleMongoses = spec && !!spec.useMultipleMongoses;
6-
7-
return isShardedEnvironment && !useMultipleMongoses
8-
? `mongodb://${configuration.host}:${configuration.port}/${configuration.db}?directConnection=false`
9-
: configuration.url();
6+
const user = context && context.user;
7+
const password = context && context.password;
8+
const connectionString =
9+
isShardedEnvironment && !useMultipleMongoses
10+
? `mongodb://${configuration.host}:${configuration.port}/${configuration.db}?directConnection=false`
11+
: configuration.url(user, password);
12+
return connectionString;
1013
}
1114

1215
module.exports = { resolveConnectionString };

test/manual/data_lake.test.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
'use strict';
2+
const { expect } = require('chai');
3+
const path = require('path');
4+
const { TestRunnerContext } = require('../functional/spec-runner');
5+
const { gatherTestSuites } = require('../functional/spec-runner');
6+
const { generateTopologyTests } = require('../functional/spec-runner');
7+
const { withClient } = require('../functional/shared');
8+
9+
describe('Atlas Data Lake', function () {
10+
context('spec tests', function () {
11+
const testContext = new TestRunnerContext({
12+
skipPrepareDatabase: true,
13+
useSessions: false,
14+
user: 'mhuser',
15+
password: 'pencil'
16+
});
17+
18+
let testSuites = gatherTestSuites(path.resolve(__dirname, '../spec/atlas-data-lake-testing'));
19+
20+
after(() => testContext.teardown());
21+
before(function () {
22+
return testContext.setup(this.configuration);
23+
});
24+
25+
generateTopologyTests(testSuites, testContext);
26+
});
27+
28+
describe('prose Tests', function () {
29+
it(
30+
'should properly constructs and issues a killCursors command',
31+
withClient('mongodb://mhuser:pencil@localhost', function (client, done) {
32+
const db = client.db('admin');
33+
db.command({ killCursors: 'kill_cursor_collection' }, err => {
34+
expect(err).to.not.exist;
35+
done();
36+
});
37+
})
38+
);
39+
it(
40+
'should connect without authentication',
41+
withClient('mongodb://localhost', function (client, done) {
42+
expect(client).to.exist;
43+
done();
44+
})
45+
);
46+
it(
47+
'should connect with auth SCRAM-SHA-1',
48+
withClient('mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-1', function (
49+
client,
50+
done
51+
) {
52+
const db = client.db('admin');
53+
db.command({ killCursors: 'kill_cursor_collection' }, err => {
54+
expect(err).to.not.exist;
55+
done();
56+
});
57+
})
58+
);
59+
it(
60+
'should connect with auth SCRAM-SHA-256',
61+
withClient('mongodb://mhuser:pencil@localhost?authMechanism=SCRAM-SHA-256', function (
62+
client,
63+
done
64+
) {
65+
const db = client.db('admin');
66+
db.command({ killCursors: 'kill_cursor_collection' }, err => {
67+
expect(err).to.not.exist;
68+
done();
69+
});
70+
})
71+
);
72+
});
73+
});

0 commit comments

Comments
 (0)