Skip to content

Commit 6e5126d

Browse files
authored
PYTHON-5196 Convert OIDC tests to use new test scripts (#2194)
1 parent e48365c commit 6e5126d

16 files changed

+237
-265
lines changed

.evergreen/config.yml

-153
Original file line numberDiff line numberDiff line change
@@ -289,28 +289,6 @@ functions:
289289
- .evergreen/scripts/run-with-env.sh
290290
- .evergreen/scripts/run-atlas-tests.sh
291291

292-
"run oidc auth test with test credentials":
293-
- command: subprocess.exec
294-
type: test
295-
params:
296-
working_dir: "src"
297-
binary: bash
298-
include_expansions_in_env: ["DRIVERS_TOOLS", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
299-
args:
300-
- .evergreen/run-mongodb-oidc-test.sh
301-
302-
"run oidc k8s auth test":
303-
- command: subprocess.exec
304-
type: test
305-
params:
306-
binary: bash
307-
working_dir: src
308-
env:
309-
OIDC_ENV: k8s
310-
include_expansions_in_env: ["DRIVERS_TOOLS", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "K8S_VARIANT"]
311-
args:
312-
- ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-oidc-remote-test.sh
313-
314292
"cleanup":
315293
- command: subprocess.exec
316294
params:
@@ -417,96 +395,6 @@ task_groups:
417395
tasks:
418396
- ".serverless"
419397

420-
- name: testazureoidc_task_group
421-
setup_group:
422-
- func: fetch source
423-
- func: setup system
424-
- command: subprocess.exec
425-
params:
426-
binary: bash
427-
env:
428-
AZUREOIDC_VMNAME_PREFIX: "PYTHON_DRIVER"
429-
args:
430-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/create-and-setup-vm.sh
431-
teardown_task:
432-
- command: subprocess.exec
433-
params:
434-
binary: bash
435-
args:
436-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/delete-vm.sh
437-
setup_group_can_fail_task: true
438-
setup_group_timeout_secs: 1800
439-
tasks:
440-
- oidc-auth-test-azure
441-
442-
- name: testgcpoidc_task_group
443-
setup_group:
444-
- func: fetch source
445-
- func: setup system
446-
- command: subprocess.exec
447-
params:
448-
binary: bash
449-
env:
450-
GCPOIDC_VMNAME_PREFIX: "PYTHON_DRIVER"
451-
args:
452-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/gcp/setup.sh
453-
teardown_task:
454-
- command: subprocess.exec
455-
params:
456-
binary: bash
457-
args:
458-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/gcp/teardown.sh
459-
setup_group_can_fail_task: true
460-
setup_group_timeout_secs: 1800
461-
tasks:
462-
- oidc-auth-test-gcp
463-
464-
- name: testk8soidc_task_group
465-
setup_group:
466-
- func: fetch source
467-
- func: setup system
468-
- command: ec2.assume_role
469-
params:
470-
role_arn: ${aws_test_secrets_role}
471-
duration_seconds: 1800
472-
- command: subprocess.exec
473-
params:
474-
binary: bash
475-
args:
476-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/setup.sh
477-
teardown_task:
478-
- command: subprocess.exec
479-
params:
480-
binary: bash
481-
args:
482-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/teardown.sh
483-
setup_group_can_fail_task: true
484-
setup_group_timeout_secs: 1800
485-
tasks:
486-
- oidc-auth-test-k8s
487-
488-
- name: testoidc_task_group
489-
setup_group:
490-
- func: fetch source
491-
- func: setup system
492-
- func: "assume ec2 role"
493-
- command: subprocess.exec
494-
params:
495-
binary: bash
496-
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
497-
args:
498-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/setup.sh
499-
teardown_task:
500-
- command: subprocess.exec
501-
params:
502-
binary: bash
503-
args:
504-
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/teardown.sh
505-
setup_group_can_fail_task: true
506-
setup_group_timeout_secs: 1800
507-
tasks:
508-
- oidc-auth-test
509-
510398
- name: test_aws_lambda_task_group
511399
setup_group:
512400
- func: fetch source
@@ -659,47 +547,6 @@ tasks:
659547
env:
660548
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
661549

662-
- name: "oidc-auth-test"
663-
commands:
664-
- func: "run oidc auth test with test credentials"
665-
666-
- name: "oidc-auth-test-azure"
667-
commands:
668-
- command: subprocess.exec
669-
type: test
670-
params:
671-
binary: bash
672-
working_dir: src
673-
env:
674-
OIDC_ENV: azure
675-
include_expansions_in_env: ["DRIVERS_TOOLS"]
676-
args:
677-
- ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-oidc-remote-test.sh
678-
679-
- name: "oidc-auth-test-gcp"
680-
commands:
681-
- command: subprocess.exec
682-
type: test
683-
params:
684-
binary: bash
685-
working_dir: src
686-
env:
687-
OIDC_ENV: gcp
688-
include_expansions_in_env: ["DRIVERS_TOOLS"]
689-
args:
690-
- ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-oidc-remote-test.sh
691-
692-
- name: "oidc-auth-test-k8s"
693-
commands:
694-
- func: "run oidc k8s auth test"
695-
vars:
696-
K8S_VARIANT: eks
697-
- func: "run oidc k8s auth test"
698-
vars:
699-
K8S_VARIANT: gke
700-
- func: "run oidc k8s auth test"
701-
vars:
702-
K8S_VARIANT: aks
703550
# }}}
704551
- name: "coverage-report"
705552
tags: ["coverage"]

.evergreen/generated_configs/tasks.yml

+44
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,50 @@ tasks:
10421042
TEST_NAME: ocsp
10431043
tags: [ocsp, ocsp-rsa]
10441044

1045+
# Oidc tests
1046+
- name: test-auth-oidc-default
1047+
commands:
1048+
- func: run tests
1049+
vars:
1050+
TEST_NAME: auth_oidc
1051+
SUB_TEST_NAME: default
1052+
tags: [auth_oidc]
1053+
- name: test-auth-oidc-azure
1054+
commands:
1055+
- func: run tests
1056+
vars:
1057+
TEST_NAME: auth_oidc
1058+
SUB_TEST_NAME: azure
1059+
tags: [auth_oidc, auth_oidc_remote]
1060+
- name: test-auth-oidc-gcp
1061+
commands:
1062+
- func: run tests
1063+
vars:
1064+
TEST_NAME: auth_oidc
1065+
SUB_TEST_NAME: gcp
1066+
tags: [auth_oidc, auth_oidc_remote]
1067+
- name: test-auth-oidc-eks
1068+
commands:
1069+
- func: run tests
1070+
vars:
1071+
TEST_NAME: auth_oidc
1072+
SUB_TEST_NAME: eks
1073+
tags: [auth_oidc, auth_oidc_remote]
1074+
- name: test-auth-oidc-aks
1075+
commands:
1076+
- func: run tests
1077+
vars:
1078+
TEST_NAME: auth_oidc
1079+
SUB_TEST_NAME: aks
1080+
tags: [auth_oidc, auth_oidc_remote]
1081+
- name: test-auth-oidc-gke
1082+
commands:
1083+
- func: run tests
1084+
vars:
1085+
TEST_NAME: auth_oidc
1086+
SUB_TEST_NAME: gke
1087+
tags: [auth_oidc, auth_oidc_remote]
1088+
10451089
# Server tests
10461090
- name: test-4.0-standalone-auth-ssl-sync
10471091
commands:

.evergreen/generated_configs/variants.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -920,24 +920,21 @@ buildvariants:
920920
# Oidc auth tests
921921
- name: auth-oidc-ubuntu-22
922922
tasks:
923-
- name: testoidc_task_group
924-
- name: testazureoidc_task_group
925-
- name: testgcpoidc_task_group
926-
- name: testk8soidc_task_group
923+
- name: .auth_oidc
927924
display_name: Auth OIDC Ubuntu-22
928925
run_on:
929926
- ubuntu2204-small
930927
batchtime: 10080
931928
- name: auth-oidc-macos
932929
tasks:
933-
- name: testoidc_task_group
930+
- name: .auth_oidc !.auth_oidc_remote
934931
display_name: Auth OIDC macOS
935932
run_on:
936933
- macos-14
937934
batchtime: 10080
938935
- name: auth-oidc-win64
939936
tasks:
940-
- name: testoidc_task_group
937+
- name: .auth_oidc !.auth_oidc_remote
941938
display_name: Auth OIDC Win64
942939
run_on:
943940
- windows-64-vsMulti-small

.evergreen/run-mongodb-oidc-remote-test.sh

-60
This file was deleted.

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

+7-24
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,14 @@
33
set +x # Disable debug trace
44
set -eu
55

6-
echo "Running MONGODB-OIDC authentication tests"
7-
8-
OIDC_ENV=${OIDC_ENV:-"test"}
9-
10-
if [ $OIDC_ENV == "test" ]; then
11-
# Make sure DRIVERS_TOOLS is set.
12-
if [ -z "$DRIVERS_TOOLS" ]; then
13-
echo "Must specify DRIVERS_TOOLS"
14-
exit 1
15-
fi
16-
source ${DRIVERS_TOOLS}/.evergreen/auth_oidc/secrets-export.sh
17-
18-
elif [ $OIDC_ENV == "azure" ]; then
19-
source ./env.sh
20-
21-
elif [ $OIDC_ENV == "gcp" ]; then
22-
source ./secrets-export.sh
23-
24-
elif [ $OIDC_ENV == "k8s" ]; then
25-
echo "Running oidc on k8s"
6+
echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}..."
267

8+
if [ ${OIDC_ENV} == "k8s" ]; then
9+
SUB_TEST_NAME=$K8S_VARIANT-remote
2710
else
28-
echo "Unrecognized OIDC_ENV $OIDC_ENV"
29-
exit 1
11+
SUB_TEST_NAME=$OIDC_ENV-remote
3012
fi
31-
32-
COVERAGE=1 bash ./.evergreen/just.sh setup-tests auth_oidc
13+
bash ./.evergreen/just.sh setup-tests auth_oidc $SUB_TEST_NAME
3314
bash ./.evergreen/just.sh run-tests "${@:1}"
15+
16+
echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}... done."

.evergreen/run-tests.sh

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fi
2626

2727
# Source the local secrets export file if available.
2828
if [ -f "./secrets-export.sh" ]; then
29+
echo "Sourcing local secrets file"
2930
. "./secrets-export.sh"
3031
fi
3132

.evergreen/scripts/generate_config.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,11 @@ def create_serverless_variants():
663663

664664
def create_oidc_auth_variants():
665665
variants = []
666-
other_tasks = ["testazureoidc_task_group", "testgcpoidc_task_group", "testk8soidc_task_group"]
667666
for host_name in ["ubuntu22", "macos", "win64"]:
668-
tasks = ["testoidc_task_group"]
669667
if host_name == "ubuntu22":
670-
tasks += other_tasks
668+
tasks = [".auth_oidc"]
669+
else:
670+
tasks = [".auth_oidc !.auth_oidc_remote"]
671671
host = HOSTS[host_name]
672672
variants.append(
673673
create_variant(
@@ -884,6 +884,19 @@ def create_aws_tasks():
884884
return tasks
885885

886886

887+
def create_oidc_tasks():
888+
tasks = []
889+
for sub_test in ["default", "azure", "gcp", "eks", "aks", "gke"]:
890+
vars = dict(TEST_NAME="auth_oidc", SUB_TEST_NAME=sub_test)
891+
test_func = FunctionCall(func="run tests", vars=vars)
892+
task_name = f"test-auth-oidc-{sub_test}"
893+
tags = ["auth_oidc"]
894+
if sub_test != "default":
895+
tags.append("auth_oidc_remote")
896+
tasks.append(EvgTask(name=task_name, tags=tags, commands=[test_func]))
897+
return tasks
898+
899+
887900
def _create_ocsp_task(algo, variant, server_type, base_task_name):
888901
file_name = f"{algo}-basic-tls-ocsp-{variant}.json"
889902

0 commit comments

Comments
 (0)