Skip to content

Commit f839858

Browse files
committed
PYTHON-5398 Support for AWS EKS Pod Identity
1 parent 1366b91 commit f839858

File tree

9 files changed

+35
-12
lines changed

9 files changed

+35
-12
lines changed

.evergreen/generated_configs/tasks.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ tasks:
114114
SUB_TEST_NAME: ecs
115115
PYTHON_VERSION: "3.10"
116116
tags: [auth-aws, auth-aws-ecs]
117+
- name: test-auth-aws-4.4-eks-python3.11
118+
commands:
119+
- func: run server
120+
vars:
121+
AUTH_AWS: "1"
122+
VERSION: "4.4"
123+
- func: assume ec2 role
124+
- func: run tests
125+
vars:
126+
TEST_NAME: auth_aws
127+
SUB_TEST_NAME: eks
128+
PYTHON_VERSION: "3.11"
129+
tags: [auth-aws, auth-aws-eks]
117130

118131
# Backport pr tests
119132
- name: backport-pr

.evergreen/generated_configs/variants.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ buildvariants:
9898
tags: []
9999
- name: auth-aws-win64
100100
tasks:
101-
- name: .auth-aws !.auth-aws-ecs
101+
- name: .auth-aws !.auth-aws-ecs !.auth-aws-eks
102102
display_name: Auth AWS Win64
103103
run_on:
104104
- windows-64-vsMulti-small
105105
tags: []
106106
- name: auth-aws-macos
107107
tasks:
108-
- name: .auth-aws !.auth-aws-web-identity !.auth-aws-ecs !.auth-aws-ec2
108+
- name: .auth-aws !.auth-aws-web-identity !.auth-aws-ecs !.auth-aws-ec2 !.auth-aws-eks
109109
display_name: Auth AWS macOS
110110
run_on:
111111
- macos-14

.evergreen/scripts/configure-env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ EOT
7676
rm -rf $DRIVERS_TOOLS
7777
BRANCH=master
7878
ORG=mongodb-labs
79+
BRANCH=DRIVERS-2945
80+
ORG=blink1073
7981
git clone --branch $BRANCH https://github.com/$ORG/drivers-evergreen-tools.git $DRIVERS_TOOLS
8082

8183
cat <<EOT > ${DRIVERS_TOOLS}/.env

.evergreen/scripts/generate_config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,12 @@ def create_aws_auth_variants():
488488
tasks = [".auth-aws"]
489489
tags = []
490490
if host_name == "macos":
491-
tasks = [".auth-aws !.auth-aws-web-identity !.auth-aws-ecs !.auth-aws-ec2"]
491+
tasks = [
492+
".auth-aws !.auth-aws-web-identity !.auth-aws-ecs !.auth-aws-ec2 !.auth-aws-eks"
493+
]
492494
tags = ["pr"]
493495
elif host_name == "win64":
494-
tasks = [".auth-aws !.auth-aws-ecs"]
496+
tasks = [".auth-aws !.auth-aws-ecs !.auth-aws-eks"]
495497
host = HOSTS[host_name]
496498
variant = create_variant(
497499
tasks,
@@ -742,6 +744,7 @@ def create_aws_tasks():
742744
"session-creds",
743745
"web-identity",
744746
"ecs",
747+
"eks",
745748
]
746749
for version, test_type, python in zip_cycle(get_versions_from("4.4"), aws_test_types, CPYTHONS):
747750
base_name = f"test-auth-aws-{version}"

.evergreen/scripts/run_tests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from shutil import which
1212

1313
import pytest
14-
from utils import DRIVERS_TOOLS, LOGGER, ROOT, run_command
14+
from utils import DRIVERS_TOOLS, HERE, LOGGER, ROOT, run_command
1515

1616
AUTH = os.environ.get("AUTH", "noauth")
1717
SSL = os.environ.get("SSL", "nossl")
@@ -159,9 +159,12 @@ def run() -> None:
159159
result = main("-E -b doctest doc ./doc/_build/doctest".split())
160160
sys.exit(result)
161161

162-
# Send ecs tests to run remotely.
163-
if TEST_NAME == "auth_aws" and SUB_TEST_NAME == "ecs":
164-
run_command(f"{DRIVERS_TOOLS}/.evergreen/auth_aws/aws_setup.sh ecs")
162+
# Send ecs and eks tests to run remotely.
163+
if TEST_NAME == "auth_aws" and SUB_TEST_NAME in ["ecs", "eks"]:
164+
target = f"run-mongodb-aws-{SUB_TEST_NAME}-test.sh"
165+
text = (HERE / "run-aws-container-test.sh").read_text()
166+
(HERE.parent / target).write_text(text)
167+
run_command(f"{DRIVERS_TOOLS}/.evergreen/auth_aws/aws_setup.sh {SUB_TEST_NAME}")
165168
return
166169

167170
# Send OIDC tests to run remotely.

.evergreen/scripts/setup_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,11 @@ def handle_test_env() -> None:
415415

416416
setup_kms(sub_test_name)
417417

418-
if test_name == "auth_aws" and sub_test_name != "ecs-remote":
418+
if test_name == "auth_aws" and sub_test_name not in ["ecs-remote", "eks-remote"]:
419419
auth_aws_dir = f"{DRIVERS_TOOLS}/.evergreen/auth_aws"
420420
if "AWS_ROLE_SESSION_NAME" in os.environ:
421421
write_env("AWS_ROLE_SESSION_NAME")
422-
if sub_test_name != "ecs":
422+
if sub_test_name not in ["ecs", "eks"]:
423423
aws_setup = f"{auth_aws_dir}/aws_setup.sh"
424424
run_command(f"bash {aws_setup} {sub_test_name}")
425425
creds = read_env(f"{auth_aws_dir}/test-env.sh")

.evergreen/scripts/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def get_test_options(
143143
raise ValueError(f"Test '{test_name}' requires a sub_test_name")
144144
if "auth" in test_name or os.environ.get("AUTH") == "auth":
145145
opts.auth = True
146-
# 'auth_aws ecs' shouldn't have extra auth set.
147-
if test_name == "auth_aws" and sub_test_name == "ecs":
146+
# auth_aws ecs or eks shouldn't have extra auth set.
147+
if test_name == "auth_aws" and sub_test_name in ["ecs", "eks"]:
148148
opts.auth = False
149149
if os.environ.get("SSL") == "ssl":
150150
opts.ssl = True

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ expansion.yml
3030
.evergreen/scripts/test-env.sh
3131
specifications/
3232
results.json
33+
.evergreen/run-mongodb-aws-eks-test.sh
34+
.evergreen/run-mongodb-aws-ecs-test.sh
3335

3436
# Lambda temp files
3537
test/lambda/.aws-sam

0 commit comments

Comments
 (0)