Skip to content

Commit 9a2d2a4

Browse files
authored
Remove legacy shell from test scripts (#1404) (#1560)
The legacy shell was only used in AWS authentication tests, so updating those gets rid of the last remaining use of the legacy shell. JAVA-4791 (cherry picked from commit 46fda2f) Co-authored-by: Jeff Yemin <[email protected]>
1 parent 50ac454 commit 9a2d2a4

File tree

2 files changed

+33
-184
lines changed

2 files changed

+33
-184
lines changed

.evergreen/.evg.yml

+31-171
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ functions:
150150
${PREPARE_SHELL}
151151
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} LOAD_BALANCER=${LOAD_BALANCER} MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
152152
AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
153-
INSTALL_LEGACY_SHELL=${INSTALL_LEGACY_SHELL} bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
153+
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
154154
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
155155
- command: expansions.update
156156
params:
@@ -345,241 +345,108 @@ functions:
345345
JAVA_VERSION="8" MONGODB_URI="${plain_auth_mongodb_uri}" .evergreen/run-plain-auth-test.sh
346346
347347
"add aws auth variables to file":
348+
- command: ec2.assume_role
349+
params:
350+
role_arn: ${aws_test_secrets_role}
348351
- command: shell.exec
349352
type: test
350353
params:
354+
include_expansions_in_env: [ "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN" ]
355+
shell: "bash"
351356
working_dir: "src"
352-
silent: true
353357
script: |
354-
cat <<EOF > ${DRIVERS_TOOLS}/.evergreen/auth_aws/aws_e2e_setup.json
355-
{
356-
"iam_auth_ecs_account" : "${iam_auth_ecs_account}",
357-
"iam_auth_ecs_secret_access_key" : "${iam_auth_ecs_secret_access_key}",
358-
"iam_auth_ecs_account_arn": "arn:aws:iam::557821124784:user/authtest_fargate_user",
359-
"iam_auth_ecs_cluster": "${iam_auth_ecs_cluster}",
360-
"iam_auth_ecs_task_definition": "${iam_auth_ecs_task_definition}",
361-
"iam_auth_ecs_subnet_a": "${iam_auth_ecs_subnet_a}",
362-
"iam_auth_ecs_subnet_b": "${iam_auth_ecs_subnet_b}",
363-
"iam_auth_ecs_security_group": "${iam_auth_ecs_security_group}",
364-
365-
"iam_auth_assume_aws_account" : "${iam_auth_assume_aws_account}",
366-
"iam_auth_assume_aws_secret_access_key" : "${iam_auth_assume_aws_secret_access_key}",
367-
"iam_auth_assume_role_name" : "${iam_auth_assume_role_name}",
368-
369-
"iam_auth_ec2_instance_account" : "${iam_auth_ec2_instance_account}",
370-
"iam_auth_ec2_instance_secret_access_key" : "${iam_auth_ec2_instance_secret_access_key}",
371-
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}",
372-
373-
"iam_auth_assume_web_role_name": "${iam_auth_assume_web_role_name}",
374-
"iam_web_identity_issuer": "${iam_web_identity_issuer}",
375-
"iam_web_identity_rsa_key": "${iam_web_identity_rsa_key}",
376-
"iam_web_identity_jwks_uri": "${iam_web_identity_jwks_uri}",
377-
"iam_web_identity_token_file": "${iam_web_identity_token_file}"
378-
}
379-
EOF
358+
${PREPARE_SHELL}
359+
cd $DRIVERS_TOOLS/.evergreen/auth_aws
360+
./setup_secrets.sh drivers/aws_auth
380361
381362
"run aws auth test with regular aws credentials":
382363
- command: shell.exec
383364
type: test
384365
params:
385-
working_dir: "src"
386366
shell: "bash"
387-
script: |
388-
${PREPARE_SHELL}
389-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
390-
. ./activate-authawsvenv.sh
391-
mongo aws_e2e_regular_aws.js
392-
- command: shell.exec
393-
type: test
394-
params:
395367
working_dir: "src"
396-
silent: true
397368
script: |
398-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
399-
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
400-
USER=$(urlencode ${iam_auth_ecs_account})
401-
PASS=$(urlencode ${iam_auth_ecs_secret_access_key})
402-
MONGODB_URI="mongodb://$USER:$PASS@localhost"
403-
EOF
404-
JAVA_VERSION=${JAVA_VERSION} PROJECT_DIRECTORY=${PROJECT_DIRECTORY} \
405-
AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} \
406-
.evergreen/run-mongodb-aws-test.sh
369+
${PREPARE_SHELL}
370+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh regular
407371
408372
"run aws auth test with assume role credentials":
409373
- command: shell.exec
410374
type: test
411375
params:
412-
working_dir: "src"
413376
shell: "bash"
414-
script: |
415-
${PREPARE_SHELL}
416-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
417-
. ./activate-authawsvenv.sh
418-
mongo aws_e2e_assume_role.js
419-
- command: shell.exec
420-
type: test
421-
params:
422377
working_dir: "src"
423-
silent: true
424378
script: |
425-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
426-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
427-
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
428-
USER=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
429-
USER=$(urlencode $USER)
430-
PASS=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
431-
PASS=$(urlencode $PASS)
432-
SESSION_TOKEN=$(jq -r '.SessionToken' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
433-
SESSION_TOKEN=$(urlencode $SESSION_TOKEN)
434-
MONGODB_URI="mongodb://$USER:$PASS@localhost"
435-
EOF
436-
JAVA_VERSION=${JAVA_VERSION} PROJECT_DIRECTORY=${PROJECT_DIRECTORY} DRIVERS_TOOLS=${DRIVERS_TOOLS} \
437-
AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} \
438-
.evergreen/run-mongodb-aws-test.sh
379+
${PREPARE_SHELL}
380+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh assume-role
439381
440382
"run aws auth test with aws EC2 credentials":
441383
- command: shell.exec
442384
type: test
443385
params:
444-
working_dir: "src"
445386
shell: "bash"
446-
script: |
447-
${PREPARE_SHELL}
448-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
449-
. ./activate-authawsvenv.sh
450-
mongo aws_e2e_ec2.js
451-
- command: shell.exec
452-
type: test
453-
params:
454387
working_dir: "src"
455-
shell: "bash"
456388
script: |
457389
${PREPARE_SHELL}
458-
# Write an empty prepare_mongodb_aws so no auth environment variables are set.
459-
echo "" > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
460-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh
390+
if [ "${SKIP_EC2_AUTH_TEST}" = "true" ]; then
391+
echo "This platform does not support the EC2 auth test, skipping..."
392+
exit 0
393+
fi
394+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh ec2
461395
462396
"run aws auth test with web identity credentials":
463397
- command: shell.exec
464398
type: test
465399
params:
466-
working_dir: "src"
467400
shell: "bash"
468-
script: |
469-
${PREPARE_SHELL}
470-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
471-
. ./activate-authawsvenv.sh
472-
mongo aws_e2e_web_identity.js
473-
- command: shell.exec
474-
type: test
475-
params:
476401
working_dir: "src"
477-
shell: "bash"
478-
silent: true
479-
script: |
480-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
481-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
482-
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
483-
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
484-
EOF
485-
- command: shell.exec
486-
type: test
487-
params:
488-
working_dir: "src"
489-
shell: "bash"
490402
script: |
491403
${PREPARE_SHELL}
492404
if [ "${AWS_CREDENTIAL_PROVIDER}" = "builtIn" ]; then
493405
echo "Built-in AWS credential provider does not support the web identity auth test, skipping..."
494406
exit 0
495407
fi
496-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
408+
if [ "${SKIP_WEB_IDENTITY_AUTH_TEST}" = "true" ]; then
409+
echo "This platform does not support the web identity auth test, skipping..."
410+
exit 0
411+
fi
412+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh web-identity
497413
- command: shell.exec
498414
type: test
499415
params:
500-
working_dir: "src"
501416
shell: "bash"
502-
silent: true
503-
script: |
504-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
505-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
506-
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
507-
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
508-
export AWS_ROLE_SESSION_NAME="test"
509-
EOF
510-
- command: shell.exec
511-
type: test
512-
params:
513417
working_dir: "src"
514-
shell: "bash"
515418
script: |
516419
${PREPARE_SHELL}
517420
if [ "${AWS_CREDENTIAL_PROVIDER}" = "builtIn" ]; then
518421
echo "Built-in AWS credential provider does not support the web identity auth test, skipping..."
519422
exit 0
520423
fi
521-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
424+
if [ "${SKIP_WEB_IDENTITY_AUTH_TEST}" = "true" ]; then
425+
echo "This platform does not support the web identity auth test, skipping..."
426+
exit 0
427+
fi
428+
export AWS_ROLE_SESSION_NAME="test"
429+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh web-identity
522430
523431
"run aws auth test with aws credentials as environment variables":
524432
- command: shell.exec
525433
type: test
526434
params:
527-
working_dir: "src"
528435
shell: "bash"
529-
script: |
530-
${PREPARE_SHELL}
531-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
532-
. ./activate-authawsvenv.sh
533-
mongo aws_e2e_regular_aws.js
534-
- command: shell.exec
535-
type: test
536-
params:
537-
working_dir: "src"
538-
silent: true
539-
script: |
540-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
541-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
542-
export AWS_ACCESS_KEY_ID=${iam_auth_ecs_account}
543-
export AWS_SECRET_ACCESS_KEY=${iam_auth_ecs_secret_access_key}
544-
EOF
545-
- command: shell.exec
546-
type: test
547-
params:
548436
working_dir: "src"
549437
script: |
550438
${PREPARE_SHELL}
551-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh
439+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh env-creds
552440
553441
"run aws auth test with aws credentials and session token as environment variables":
554442
- command: shell.exec
555443
type: test
556444
params:
557-
working_dir: "src"
558445
shell: "bash"
559-
script: |
560-
${PREPARE_SHELL}
561-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
562-
. ./activate-authawsvenv.sh
563-
mongo aws_e2e_assume_role.js
564-
- command: shell.exec
565-
type: test
566-
params:
567-
working_dir: "src"
568-
silent: true
569-
script: |
570-
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
571-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
572-
export AWS_ACCESS_KEY_ID=$(jq -r '.AccessKeyId' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
573-
export AWS_SECRET_ACCESS_KEY=$(jq -r '.SecretAccessKey' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
574-
export AWS_SESSION_TOKEN=$(jq -r '.SessionToken' ${DRIVERS_TOOLS}/.evergreen/auth_aws/creds.json)
575-
EOF
576-
- command: shell.exec
577-
type: test
578-
params:
579446
working_dir: "src"
580447
script: |
581448
${PREPARE_SHELL}
582-
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh
449+
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh session-creds
583450
584451
"run aws ECS auth test":
585452
- command: shell.exec
@@ -952,7 +819,6 @@ tasks:
952819
AUTH: "auth"
953820
ORCHESTRATION_FILE: "auth-aws.json"
954821
TOPOLOGY: "server"
955-
INSTALL_LEGACY_SHELL: "true"
956822
- func: "add aws auth variables to file"
957823
- func: "run aws auth test with regular aws credentials"
958824

@@ -963,7 +829,6 @@ tasks:
963829
AUTH: "auth"
964830
ORCHESTRATION_FILE: "auth-aws.json"
965831
TOPOLOGY: "server"
966-
INSTALL_LEGACY_SHELL: "true"
967832
- func: "add aws auth variables to file"
968833
- func: "run aws auth test with assume role credentials"
969834

@@ -974,7 +839,6 @@ tasks:
974839
AUTH: "auth"
975840
ORCHESTRATION_FILE: "auth-aws.json"
976841
TOPOLOGY: "server"
977-
INSTALL_LEGACY_SHELL: "true"
978842
- func: "add aws auth variables to file"
979843
- func: "run aws auth test with aws credentials as environment variables"
980844

@@ -985,7 +849,6 @@ tasks:
985849
AUTH: "auth"
986850
ORCHESTRATION_FILE: "auth-aws.json"
987851
TOPOLOGY: "server"
988-
INSTALL_LEGACY_SHELL: "true"
989852
- func: "add aws auth variables to file"
990853
- func: "run aws auth test with aws credentials and session token as environment variables"
991854

@@ -996,7 +859,6 @@ tasks:
996859
AUTH: "auth"
997860
ORCHESTRATION_FILE: "auth-aws.json"
998861
TOPOLOGY: "server"
999-
INSTALL_LEGACY_SHELL: "true"
1000862
- func: "add aws auth variables to file"
1001863
- func: "run aws auth test with aws EC2 credentials"
1002864

@@ -1007,7 +869,6 @@ tasks:
1007869
AUTH: "auth"
1008870
ORCHESTRATION_FILE: "auth-aws.json"
1009871
TOPOLOGY: "server"
1010-
INSTALL_LEGACY_SHELL: "true"
1011872
- func: "add aws auth variables to file"
1012873
- func: "run aws auth test with web identity credentials"
1013874

@@ -1018,7 +879,6 @@ tasks:
1018879
AUTH: "auth"
1019880
ORCHESTRATION_FILE: "auth-aws.json"
1020881
TOPOLOGY: "server"
1021-
INSTALL_LEGACY_SHELL: "true"
1022882
- func: "add aws auth variables to file"
1023883
- func: "run aws ECS auth test"
1024884

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

+2-13
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,8 @@ RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")"
1515

1616
echo "Running MONGODB-AWS authentication tests"
1717

18-
19-
# ensure no secrets are printed in log files
20-
set +x
21-
22-
# load the script
23-
shopt -s expand_aliases # needed for `urlencode` alias
24-
[ -s "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh" ] && source "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
25-
26-
MONGODB_URI=${MONGODB_URI:-"mongodb://localhost"}
27-
MONGODB_URI="${MONGODB_URI}/aws?authMechanism=MONGODB-AWS"
28-
if [[ -n ${SESSION_TOKEN} ]]; then
29-
MONGODB_URI="${MONGODB_URI}&authMechanismProperties=AWS_SESSION_TOKEN:${SESSION_TOKEN}"
30-
fi
18+
# Handle credentials and environment setup.
19+
. $DRIVERS_TOOLS/.evergreen/auth_aws/aws_setup.sh $1
3120

3221
# show test output
3322
set -x

0 commit comments

Comments
 (0)