Skip to content

Commit 8f4cce6

Browse files
nbbeekenljhaywar
authored andcommitted
chore(NODE-3186): ensure aws tests are run (#2777)
1 parent dd6a772 commit 8f4cce6

File tree

6 files changed

+193
-24
lines changed

6 files changed

+193
-24
lines changed

.evergreen/config.yml

Lines changed: 149 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@ functions:
277277
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}"
278278
}
279279
EOF
280+
setup aws env:
281+
- command: shell.exec
282+
type: test
283+
params:
284+
working_dir: src
285+
script: |
286+
${PREPARE_SHELL}
287+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
288+
. ./activate_venv.sh
289+
cd -
280290
run aws auth test with regular aws credentials:
281291
- command: shell.exec
282292
type: test
@@ -363,6 +373,9 @@ functions:
363373
working_dir: src
364374
silent: true
365375
script: |
376+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
377+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_regular_aws.js
378+
cd -
366379
cat <<EOF > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
367380
export AWS_ACCESS_KEY_ID=${iam_auth_ecs_account}
368381
export AWS_SECRET_ACCESS_KEY=${iam_auth_ecs_secret_access_key}
@@ -382,6 +395,9 @@ functions:
382395
working_dir: src
383396
silent: true
384397
script: |
398+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
399+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_assume_role.js
400+
cd -
385401
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
386402
export AWS_ACCESS_KEY_ID=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
387403
export AWS_SECRET_ACCESS_KEY=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
@@ -421,7 +437,7 @@ functions:
421437
422438
cat setup.js
423439
. ./activate_venv.sh
424-
mongo --nodb setup.js aws_e2e_ecs.js
440+
${MONGODB_BINARIES}/mongo --nodb setup.js aws_e2e_ecs.js
425441
run-ocsp-test:
426442
- command: shell.exec
427443
type: test
@@ -1164,7 +1180,7 @@ tasks:
11641180
- func: run-ocsp-test
11651181
vars:
11661182
OCSP_TLS_SHOULD_SUCCEED: 0
1167-
- name: aws-latest-auth-test
1183+
- name: aws-latest-auth-test-run-aws-auth-test-with-regular-aws-credentials
11681184
commands:
11691185
- func: install dependencies
11701186
- func: bootstrap mongo-orchestration
@@ -1174,10 +1190,69 @@ tasks:
11741190
ORCHESTRATION_FILE: auth-aws.json
11751191
TOPOLOGY: server
11761192
- func: add aws auth variables to file
1193+
- func: setup aws env
11771194
- func: run aws auth test with regular aws credentials
1195+
- name: aws-latest-auth-test-run-aws-auth-test-with-assume-role-credentials
1196+
commands:
1197+
- func: install dependencies
1198+
- func: bootstrap mongo-orchestration
1199+
vars:
1200+
VERSION: latest
1201+
AUTH: auth
1202+
ORCHESTRATION_FILE: auth-aws.json
1203+
TOPOLOGY: server
1204+
- func: add aws auth variables to file
1205+
- func: setup aws env
11781206
- func: run aws auth test with assume role credentials
1207+
- name: aws-latest-auth-test-run-aws-auth-test-with-aws-EC2-credentials
1208+
commands:
1209+
- func: install dependencies
1210+
- func: bootstrap mongo-orchestration
1211+
vars:
1212+
VERSION: latest
1213+
AUTH: auth
1214+
ORCHESTRATION_FILE: auth-aws.json
1215+
TOPOLOGY: server
1216+
- func: add aws auth variables to file
1217+
- func: setup aws env
11791218
- func: run aws auth test with aws EC2 credentials
1180-
- name: aws-4.4-auth-test
1219+
- name: aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
1220+
commands:
1221+
- func: install dependencies
1222+
- func: bootstrap mongo-orchestration
1223+
vars:
1224+
VERSION: latest
1225+
AUTH: auth
1226+
ORCHESTRATION_FILE: auth-aws.json
1227+
TOPOLOGY: server
1228+
- func: add aws auth variables to file
1229+
- func: setup aws env
1230+
- func: run aws auth test with aws credentials as environment variables
1231+
- name: aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
1232+
commands:
1233+
- func: install dependencies
1234+
- func: bootstrap mongo-orchestration
1235+
vars:
1236+
VERSION: latest
1237+
AUTH: auth
1238+
ORCHESTRATION_FILE: auth-aws.json
1239+
TOPOLOGY: server
1240+
- func: add aws auth variables to file
1241+
- func: setup aws env
1242+
- func: run aws auth test with aws credentials and session token as environment variables
1243+
- name: aws-latest-auth-test-run-aws-ECS-auth-test
1244+
commands:
1245+
- func: install dependencies
1246+
- func: bootstrap mongo-orchestration
1247+
vars:
1248+
VERSION: latest
1249+
AUTH: auth
1250+
ORCHESTRATION_FILE: auth-aws.json
1251+
TOPOLOGY: server
1252+
- func: add aws auth variables to file
1253+
- func: setup aws env
1254+
- func: run aws ECS auth test
1255+
- name: aws-4.4-auth-test-run-aws-auth-test-with-regular-aws-credentials
11811256
commands:
11821257
- func: install dependencies
11831258
- func: bootstrap mongo-orchestration
@@ -1187,9 +1262,68 @@ tasks:
11871262
ORCHESTRATION_FILE: auth-aws.json
11881263
TOPOLOGY: server
11891264
- func: add aws auth variables to file
1265+
- func: setup aws env
11901266
- func: run aws auth test with regular aws credentials
1267+
- name: aws-4.4-auth-test-run-aws-auth-test-with-assume-role-credentials
1268+
commands:
1269+
- func: install dependencies
1270+
- func: bootstrap mongo-orchestration
1271+
vars:
1272+
VERSION: '4.4'
1273+
AUTH: auth
1274+
ORCHESTRATION_FILE: auth-aws.json
1275+
TOPOLOGY: server
1276+
- func: add aws auth variables to file
1277+
- func: setup aws env
11911278
- func: run aws auth test with assume role credentials
1279+
- name: aws-4.4-auth-test-run-aws-auth-test-with-aws-EC2-credentials
1280+
commands:
1281+
- func: install dependencies
1282+
- func: bootstrap mongo-orchestration
1283+
vars:
1284+
VERSION: '4.4'
1285+
AUTH: auth
1286+
ORCHESTRATION_FILE: auth-aws.json
1287+
TOPOLOGY: server
1288+
- func: add aws auth variables to file
1289+
- func: setup aws env
11921290
- func: run aws auth test with aws EC2 credentials
1291+
- name: aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
1292+
commands:
1293+
- func: install dependencies
1294+
- func: bootstrap mongo-orchestration
1295+
vars:
1296+
VERSION: '4.4'
1297+
AUTH: auth
1298+
ORCHESTRATION_FILE: auth-aws.json
1299+
TOPOLOGY: server
1300+
- func: add aws auth variables to file
1301+
- func: setup aws env
1302+
- func: run aws auth test with aws credentials as environment variables
1303+
- name: aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
1304+
commands:
1305+
- func: install dependencies
1306+
- func: bootstrap mongo-orchestration
1307+
vars:
1308+
VERSION: '4.4'
1309+
AUTH: auth
1310+
ORCHESTRATION_FILE: auth-aws.json
1311+
TOPOLOGY: server
1312+
- func: add aws auth variables to file
1313+
- func: setup aws env
1314+
- func: run aws auth test with aws credentials and session token as environment variables
1315+
- name: aws-4.4-auth-test-run-aws-ECS-auth-test
1316+
commands:
1317+
- func: install dependencies
1318+
- func: bootstrap mongo-orchestration
1319+
vars:
1320+
VERSION: '4.4'
1321+
AUTH: auth
1322+
ORCHESTRATION_FILE: auth-aws.json
1323+
TOPOLOGY: server
1324+
- func: add aws auth variables to file
1325+
- func: setup aws env
1326+
- func: run aws ECS auth test
11931327
- name: run-checks
11941328
tags:
11951329
- run-checks
@@ -1562,5 +1696,15 @@ buildvariants:
15621696
expansions:
15631697
NODE_LTS_NAME: dubnium
15641698
tasks:
1565-
- aws-latest-auth-test
1566-
- aws-4.4-auth-test
1699+
- aws-latest-auth-test-run-aws-auth-test-with-regular-aws-credentials
1700+
- aws-latest-auth-test-run-aws-auth-test-with-assume-role-credentials
1701+
- aws-latest-auth-test-run-aws-auth-test-with-aws-EC2-credentials
1702+
- aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
1703+
- aws-latest-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
1704+
- aws-latest-auth-test-run-aws-ECS-auth-test
1705+
- aws-4.4-auth-test-run-aws-auth-test-with-regular-aws-credentials
1706+
- aws-4.4-auth-test-run-aws-auth-test-with-assume-role-credentials
1707+
- aws-4.4-auth-test-run-aws-auth-test-with-aws-EC2-credentials
1708+
- aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
1709+
- aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
1710+
- aws-4.4-auth-test-run-aws-ECS-auth-test

.evergreen/config.yml.in

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,17 @@ functions:
311311
}
312312
EOF
313313

314+
"setup aws env":
315+
- command: shell.exec
316+
type: test
317+
params:
318+
working_dir: "src"
319+
script: |
320+
${PREPARE_SHELL}
321+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
322+
. ./activate_venv.sh
323+
cd -
324+
314325
"run aws auth test with regular aws credentials":
315326
- command: shell.exec
316327
type: test
@@ -400,6 +411,9 @@ functions:
400411
working_dir: "src"
401412
silent: true
402413
script: |
414+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
415+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_regular_aws.js
416+
cd -
403417
cat <<EOF > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
404418
export AWS_ACCESS_KEY_ID=${iam_auth_ecs_account}
405419
export AWS_SECRET_ACCESS_KEY=${iam_auth_ecs_secret_access_key}
@@ -420,6 +434,9 @@ functions:
420434
working_dir: "src"
421435
silent: true
422436
script: |
437+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
438+
${MONGODB_BINARIES}/mongo --verbose aws_e2e_assume_role.js
439+
cd -
423440
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
424441
export AWS_ACCESS_KEY_ID=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
425442
export AWS_SECRET_ACCESS_KEY=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
@@ -460,7 +477,7 @@ functions:
460477

461478
cat setup.js
462479
. ./activate_venv.sh
463-
mongo --nodb setup.js aws_e2e_ecs.js
480+
${MONGODB_BINARIES}/mongo --nodb setup.js aws_e2e_ecs.js
464481

465482
"run-ocsp-test":
466483
- command: shell.exec

.evergreen/generate_evergreen_tasks.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,18 @@ OCSP_VERSIONS.forEach(VERSION => {
400400
const AWS_AUTH_TASKS = [];
401401

402402
AWS_AUTH_VERSIONS.forEach(VERSION => {
403-
const name = `aws-${VERSION}-auth-test`;
404-
AWS_AUTH_TASKS.push(name);
405-
TASKS.push({
406-
name: name,
403+
const name = (ex) => `aws-${VERSION}-auth-test-${ex.split(' ').join('-')}`;
404+
const aws_funcs = [
405+
{ func: 'run aws auth test with regular aws credentials' },
406+
{ func: 'run aws auth test with assume role credentials' },
407+
{ func: 'run aws auth test with aws EC2 credentials' },
408+
{ func: 'run aws auth test with aws credentials as environment variables' },
409+
{ func: 'run aws auth test with aws credentials and session token as environment variables' },
410+
{ func: 'run aws ECS auth test' }
411+
];
412+
413+
const aws_tasks = aws_funcs.map(fn => ({
414+
name: name(fn.func),
407415
commands: [
408416
{ func: 'install dependencies' },
409417
{
@@ -416,17 +424,16 @@ AWS_AUTH_VERSIONS.forEach(VERSION => {
416424
}
417425
},
418426
{ func: 'add aws auth variables to file' },
419-
{ func: 'run aws auth test with regular aws credentials' },
420-
{ func: 'run aws auth test with assume role credentials' },
421-
{ func: 'run aws auth test with aws EC2 credentials' },
422-
// FIXME: NODE-3113
423-
// { func: 'run aws auth test with aws credentials as environment variables' },
424-
// { func: 'run aws auth test with aws credentials and session token as environment variables' },
425-
// { func: 'run aws ECS auth test' }
427+
{ func: 'setup aws env' },
428+
fn
426429
]
427-
});
430+
}))
431+
432+
TASKS.push(...aws_tasks);
433+
AWS_AUTH_TASKS.push(...aws_tasks.map(t => t.name))
428434
});
429435

436+
430437
const BUILD_VARIANTS = [];
431438

432439
const getTaskList = (() => {

.evergreen/run-mongodb-aws-ecs-test.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -o xtrace # Write all commands first to stderr
33
set -o errexit # Exit the script with error if any of the commands fail
44

5-
MONGODB_URI="$1"
5+
export MONGODB_URI="$1"
66
PROJECT_DIRECTORY="$(pwd)/src"
77

88
# untar packed archive
@@ -16,5 +16,6 @@ export NVM_DIR="${PROJECT_DIRECTORY}/node-artifacts/nvm"
1616
set -x
1717

1818
# run the tests
19-
npm install aws4
20-
MONGODB_URI=$MONGODB_URI MONGODB_UNIFIED_TOPOLOGY=1 npx mocha test/functional/mongodb_aws.test.js
19+
npm install aws4
20+
21+
npx mocha test/functional/mongodb_aws.test.js

.evergreen/run-mongodb-aws-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ shopt -s expand_aliases # needed for `urlencode` alias
2222
set -x
2323

2424
npm install aws4
25-
MONGODB_UNIFIED_TOPOLOGY=1 npx mocha test/functional/mongodb_aws.test.js
25+
npx mocha test/functional/mongodb_aws.test.js

src/cmap/auth/mongodb_aws.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class MongoDBAWS extends AuthProvider {
4343
return;
4444
}
4545

46-
if (credentials.username == null) {
46+
if (!credentials.username) {
4747
makeTempCredentials(credentials, (err, tempCredentials) => {
4848
if (err || !tempCredentials) return callback(err);
4949

@@ -144,7 +144,7 @@ interface AWSCredentials {
144144

145145
function makeTempCredentials(credentials: MongoCredentials, callback: Callback<MongoCredentials>) {
146146
function done(creds: AWSCredentials) {
147-
if (creds.AccessKeyId == null || creds.SecretAccessKey == null || creds.Token == null) {
147+
if (!creds.AccessKeyId || !creds.SecretAccessKey || !creds.Token) {
148148
callback(new MongoError('Could not obtain temporary MONGODB-AWS credentials'));
149149
return;
150150
}

0 commit comments

Comments
 (0)