Skip to content

Commit 2b18411

Browse files
authored
chore(NODE-3186): ensure all aws tests are run (#2776)
1 parent f1afcc4 commit 2b18411

File tree

5 files changed

+185
-25
lines changed

5 files changed

+185
-25
lines changed

.evergreen/config.yml

Lines changed: 142 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ functions:
243243
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}"
244244
}
245245
EOF
246-
run aws auth test with regular aws credentials:
246+
setup aws env:
247247
- command: shell.exec
248248
type: test
249249
params:
@@ -252,6 +252,14 @@ functions:
252252
${PREPARE_SHELL}
253253
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
254254
. ./activate_venv.sh
255+
cd -
256+
run aws auth test with regular aws credentials:
257+
- command: shell.exec
258+
type: test
259+
params:
260+
working_dir: src
261+
script: |
262+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
255263
${MONGODB_BINARIES}/mongo aws_e2e_regular_aws.js
256264
- command: shell.exec
257265
type: test
@@ -329,6 +337,9 @@ functions:
329337
working_dir: src
330338
silent: true
331339
script: |
340+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
341+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_regular_aws.js
342+
cd -
332343
cat <<EOF > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
333344
export AWS_ACCESS_KEY_ID=${iam_auth_ecs_account}
334345
export AWS_SECRET_ACCESS_KEY=${iam_auth_ecs_secret_access_key}
@@ -348,6 +359,9 @@ functions:
348359
working_dir: src
349360
silent: true
350361
script: |
362+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
363+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_assume_role.js
364+
cd -
351365
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
352366
export AWS_ACCESS_KEY_ID=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
353367
export AWS_SECRET_ACCESS_KEY=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
@@ -387,7 +401,7 @@ functions:
387401
388402
cat setup.js
389403
. ./activate_venv.sh
390-
mongo --nodb setup.js aws_e2e_ecs.js
404+
${MONGODB_BINARIES}/mongo --nodb setup.js aws_e2e_ecs.js
391405
run-ocsp-test:
392406
- command: shell.exec
393407
type: test
@@ -1377,7 +1391,7 @@ tasks:
13771391
- func: run-ocsp-test
13781392
vars:
13791393
OCSP_TLS_SHOULD_SUCCEED: 0
1380-
- name: aws-latest-auth-test
1394+
- name: aws-latest-auth-test-run-aws-auth-test-with-regular-aws-credentials
13811395
commands:
13821396
- func: install dependencies
13831397
- func: bootstrap mongo-orchestration
@@ -1387,13 +1401,69 @@ tasks:
13871401
ORCHESTRATION_FILE: auth-aws.json
13881402
TOPOLOGY: server
13891403
- func: add aws auth variables to file
1404+
- func: setup aws env
13901405
- func: run aws auth test with regular aws credentials
1406+
- name: aws-latest-auth-test-run-aws-auth-test-with-assume-role-credentials
1407+
commands:
1408+
- func: install dependencies
1409+
- func: bootstrap mongo-orchestration
1410+
vars:
1411+
VERSION: latest
1412+
AUTH: auth
1413+
ORCHESTRATION_FILE: auth-aws.json
1414+
TOPOLOGY: server
1415+
- func: add aws auth variables to file
1416+
- func: setup aws env
13911417
- func: run aws auth test with assume role credentials
1418+
- name: aws-latest-auth-test-run-aws-auth-test-with-aws-EC2-credentials
1419+
commands:
1420+
- func: install dependencies
1421+
- func: bootstrap mongo-orchestration
1422+
vars:
1423+
VERSION: latest
1424+
AUTH: auth
1425+
ORCHESTRATION_FILE: auth-aws.json
1426+
TOPOLOGY: server
1427+
- func: add aws auth variables to file
1428+
- func: setup aws env
13921429
- func: run aws auth test with aws EC2 credentials
1430+
- name: aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
1431+
commands:
1432+
- func: install dependencies
1433+
- func: bootstrap mongo-orchestration
1434+
vars:
1435+
VERSION: latest
1436+
AUTH: auth
1437+
ORCHESTRATION_FILE: auth-aws.json
1438+
TOPOLOGY: server
1439+
- func: add aws auth variables to file
1440+
- func: setup aws env
13931441
- func: run aws auth test with aws credentials as environment variables
1442+
- name: aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
1443+
commands:
1444+
- func: install dependencies
1445+
- func: bootstrap mongo-orchestration
1446+
vars:
1447+
VERSION: latest
1448+
AUTH: auth
1449+
ORCHESTRATION_FILE: auth-aws.json
1450+
TOPOLOGY: server
1451+
- func: add aws auth variables to file
1452+
- func: setup aws env
13941453
- func: run aws auth test with aws credentials and session token as environment variables
1454+
- name: aws-latest-auth-test-run-aws-ECS-auth-test
1455+
commands:
1456+
- func: install dependencies
1457+
- func: bootstrap mongo-orchestration
1458+
vars:
1459+
VERSION: latest
1460+
AUTH: auth
1461+
ORCHESTRATION_FILE: auth-aws.json
1462+
TOPOLOGY: server
1463+
- func: add aws auth variables to file
1464+
- func: setup aws env
13951465
- func: run aws ECS auth test
1396-
- name: aws-4.4-auth-test
1466+
- name: aws-4.4-auth-test-run-aws-auth-test-with-regular-aws-credentials
13971467
commands:
13981468
- func: install dependencies
13991469
- func: bootstrap mongo-orchestration
@@ -1403,11 +1473,67 @@ tasks:
14031473
ORCHESTRATION_FILE: auth-aws.json
14041474
TOPOLOGY: server
14051475
- func: add aws auth variables to file
1476+
- func: setup aws env
14061477
- func: run aws auth test with regular aws credentials
1478+
- name: aws-4.4-auth-test-run-aws-auth-test-with-assume-role-credentials
1479+
commands:
1480+
- func: install dependencies
1481+
- func: bootstrap mongo-orchestration
1482+
vars:
1483+
VERSION: '4.4'
1484+
AUTH: auth
1485+
ORCHESTRATION_FILE: auth-aws.json
1486+
TOPOLOGY: server
1487+
- func: add aws auth variables to file
1488+
- func: setup aws env
14071489
- func: run aws auth test with assume role credentials
1490+
- name: aws-4.4-auth-test-run-aws-auth-test-with-aws-EC2-credentials
1491+
commands:
1492+
- func: install dependencies
1493+
- func: bootstrap mongo-orchestration
1494+
vars:
1495+
VERSION: '4.4'
1496+
AUTH: auth
1497+
ORCHESTRATION_FILE: auth-aws.json
1498+
TOPOLOGY: server
1499+
- func: add aws auth variables to file
1500+
- func: setup aws env
14081501
- func: run aws auth test with aws EC2 credentials
1502+
- name: aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
1503+
commands:
1504+
- func: install dependencies
1505+
- func: bootstrap mongo-orchestration
1506+
vars:
1507+
VERSION: '4.4'
1508+
AUTH: auth
1509+
ORCHESTRATION_FILE: auth-aws.json
1510+
TOPOLOGY: server
1511+
- func: add aws auth variables to file
1512+
- func: setup aws env
14091513
- func: run aws auth test with aws credentials as environment variables
1514+
- name: aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
1515+
commands:
1516+
- func: install dependencies
1517+
- func: bootstrap mongo-orchestration
1518+
vars:
1519+
VERSION: '4.4'
1520+
AUTH: auth
1521+
ORCHESTRATION_FILE: auth-aws.json
1522+
TOPOLOGY: server
1523+
- func: add aws auth variables to file
1524+
- func: setup aws env
14101525
- func: run aws auth test with aws credentials and session token as environment variables
1526+
- name: aws-4.4-auth-test-run-aws-ECS-auth-test
1527+
commands:
1528+
- func: install dependencies
1529+
- func: bootstrap mongo-orchestration
1530+
vars:
1531+
VERSION: '4.4'
1532+
AUTH: auth
1533+
ORCHESTRATION_FILE: auth-aws.json
1534+
TOPOLOGY: server
1535+
- func: add aws auth variables to file
1536+
- func: setup aws env
14111537
- func: run aws ECS auth test
14121538
- name: run-checks
14131539
tags:
@@ -1994,5 +2120,15 @@ buildvariants:
19942120
expansions:
19952121
NODE_LTS_NAME: carbon
19962122
tasks:
1997-
- aws-latest-auth-test
1998-
- aws-4.4-auth-test
2123+
- aws-latest-auth-test-run-aws-auth-test-with-regular-aws-credentials
2124+
- aws-latest-auth-test-run-aws-auth-test-with-assume-role-credentials
2125+
- aws-latest-auth-test-run-aws-auth-test-with-aws-EC2-credentials
2126+
- aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
2127+
- aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
2128+
- aws-latest-auth-test-run-aws-ECS-auth-test
2129+
- aws-4.4-auth-test-run-aws-auth-test-with-regular-aws-credentials
2130+
- aws-4.4-auth-test-run-aws-auth-test-with-assume-role-credentials
2131+
- aws-4.4-auth-test-run-aws-auth-test-with-aws-EC2-credentials
2132+
- aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
2133+
- aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
2134+
- aws-4.4-auth-test-run-aws-ECS-auth-test

.evergreen/config.yml.in

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ functions:
274274
}
275275
EOF
276276

277-
"run aws auth test with regular aws credentials":
277+
"setup aws env":
278278
- command: shell.exec
279279
type: test
280280
params:
@@ -283,6 +283,15 @@ functions:
283283
${PREPARE_SHELL}
284284
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
285285
. ./activate_venv.sh
286+
cd -
287+
288+
"run aws auth test with regular aws credentials":
289+
- command: shell.exec
290+
type: test
291+
params:
292+
working_dir: "src"
293+
script: |
294+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
286295
${MONGODB_BINARIES}/mongo aws_e2e_regular_aws.js
287296
- command: shell.exec
288297
type: test
@@ -363,6 +372,9 @@ functions:
363372
working_dir: "src"
364373
silent: true
365374
script: |
375+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
376+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_regular_aws.js
377+
cd -
366378
cat <<EOF > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
367379
export AWS_ACCESS_KEY_ID=${iam_auth_ecs_account}
368380
export AWS_SECRET_ACCESS_KEY=${iam_auth_ecs_secret_access_key}
@@ -383,6 +395,9 @@ functions:
383395
working_dir: "src"
384396
silent: true
385397
script: |
398+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
399+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_assume_role.js
400+
cd -
386401
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
387402
export AWS_ACCESS_KEY_ID=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
388403
export AWS_SECRET_ACCESS_KEY=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
@@ -423,7 +438,7 @@ functions:
423438

424439
cat setup.js
425440
. ./activate_venv.sh
426-
mongo --nodb setup.js aws_e2e_ecs.js
441+
${MONGODB_BINARIES}/mongo --nodb setup.js aws_e2e_ecs.js
427442

428443
"run-ocsp-test":
429444
- command: shell.exec

.evergreen/generate_evergreen_tasks.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,20 @@ OCSP_VERSIONS.forEach(VERSION => {
296296
const AWS_AUTH_TASKS = [];
297297

298298
AWS_AUTH_VERSIONS.forEach(VERSION => {
299-
const name = `aws-${VERSION}-auth-test`;
300-
AWS_AUTH_TASKS.push(name);
301-
TASKS.push({
302-
name: name,
299+
const name = (ex) => `aws-${VERSION}-auth-test-${ex.split(' ').join('-')}`;
300+
// AWS_AUTH_TASKS.push(name);
301+
302+
const aws_funcs = [
303+
{ func: 'run aws auth test with regular aws credentials' },
304+
{ func: 'run aws auth test with assume role credentials' },
305+
{ func: 'run aws auth test with aws EC2 credentials' },
306+
{ func: 'run aws auth test with aws credentials as environment variables' },
307+
{ func: 'run aws auth test with aws credentials and session token as environment variables' },
308+
{ func: 'run aws ECS auth test' }
309+
];
310+
311+
const aws_tasks = aws_funcs.map(fn => ({
312+
name: name(fn.func),
303313
commands: [
304314
{ func: 'install dependencies' },
305315
{
@@ -312,14 +322,13 @@ AWS_AUTH_VERSIONS.forEach(VERSION => {
312322
}
313323
},
314324
{ func: 'add aws auth variables to file' },
315-
{ func: 'run aws auth test with regular aws credentials' },
316-
{ func: 'run aws auth test with assume role credentials' },
317-
{ func: 'run aws auth test with aws EC2 credentials' },
318-
{ func: 'run aws auth test with aws credentials as environment variables' },
319-
{ func: 'run aws auth test with aws credentials and session token as environment variables' },
320-
{ func: 'run aws ECS auth test' }
325+
{ func: 'setup aws env' },
326+
fn
321327
]
322-
});
328+
}))
329+
330+
TASKS.push(...aws_tasks);
331+
AWS_AUTH_TASKS.push(...aws_tasks.map(t => t.name))
323332
});
324333

325334
const BUILD_VARIANTS = [];

lib/core/auth/mongo_credentials.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ class MongoCredentials {
4949
this.mechanism = options.mechanism || 'default';
5050
this.mechanismProperties = options.mechanismProperties || {};
5151

52-
if (this.mechanism.match(/MONGODB-AWS/i)) {
53-
if (this.username == null && process.env.AWS_ACCESS_KEY_ID) {
52+
if (/MONGODB-AWS/i.test(this.mechanism)) {
53+
if (!this.username && process.env.AWS_ACCESS_KEY_ID) {
5454
this.username = process.env.AWS_ACCESS_KEY_ID;
5555
}
5656

57-
if (this.password == null && process.env.AWS_SECRET_ACCESS_KEY) {
57+
if (!this.password && process.env.AWS_SECRET_ACCESS_KEY) {
5858
this.password = process.env.AWS_SECRET_ACCESS_KEY;
5959
}
6060

61-
if (this.mechanismProperties.AWS_SESSION_TOKEN == null && process.env.AWS_SESSION_TOKEN) {
61+
if (!this.mechanismProperties.AWS_SESSION_TOKEN && process.env.AWS_SESSION_TOKEN) {
6262
this.mechanismProperties.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN;
6363
}
6464
}
@@ -90,7 +90,7 @@ class MongoCredentials {
9090
*/
9191
resolveAuthMechanism(ismaster) {
9292
// If the mechanism is not "default", then it does not need to be resolved
93-
if (this.mechanism.match(/DEFAULT/i)) {
93+
if (/DEFAULT/i.test(this.mechanism)) {
9494
return new MongoCredentials({
9595
username: this.username,
9696
password: this.password,

test/tools/runner/plugins/client_leak_checker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function unifiedTopologyIsConnected(client) {
3030
}
3131

3232
after(function() {
33-
const isUnifiedTopology = this.configuration.usingUnifiedTopology;
33+
const isUnifiedTopology = !!(this.configuration && this.configuration.usingUnifiedTopology);
3434
const traces = [];
3535
const openClientCount = activeClients.reduce((count, client) => {
3636
const isConnected = isUnifiedTopology

0 commit comments

Comments
 (0)