Skip to content

Commit 60b0727

Browse files
authored
RUST-1905 Add Kubernetes Support for OIDC (#1276)
1 parent 01fa1e9 commit 60b0727

File tree

10 files changed

+1146
-672
lines changed

10 files changed

+1146
-672
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
source ./.evergreen/env.sh
7+
8+
export RUSTFLAGS="-C target-feature=+crt-static"
9+
cargo test ${BUILD_FEATURES} --target x86_64-unknown-linux-gnu get_exe_name -- --ignored
10+
TEST_BINARY=$(cat exe_name.txt)
11+
TEST_TARBALL="/tmp/mongo-rust-driver.tar.gz"
12+
tar czvf ${TEST_TARBALL} ${TEST_BINARY} ./.evergreen
13+
14+
cat <<EOT > static-test-tarball-expansion.yml
15+
STATIC_TEST_BINARY: ${TEST_BINARY}
16+
STATIC_TEST_TARBALL: ${TEST_TARBALL}
17+
EOT

.evergreen/config.yml

Lines changed: 130 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,10 @@ buildvariants:
291291
AUTH: auth
292292
SSL: ssl
293293
tasks:
294-
- testoidc_task_group
295-
- testazureoidc_task_group
296-
- testgcpoidc_task_group
294+
- test-oidc-task-group
295+
- test-azure-oidc-task-group
296+
- test-gcp-oidc-task-group
297+
- test-k8s-oidc-task-group
297298

298299
- name: oidc-macos
299300
display_name: "OIDC Macos"
@@ -304,7 +305,7 @@ buildvariants:
304305
AUTH: auth
305306
SSL: ssl
306307
tasks:
307-
- testoidc_task_group
308+
- test-oidc-task-group
308309

309310
- name: oidc-windows
310311
disable: true
@@ -316,9 +317,9 @@ buildvariants:
316317
AUTH: auth
317318
SSL: ssl
318319
tasks:
319-
- testoidc_task_group
320-
- testazureoidc_task_group
321-
- testgcpoidc_task_group
320+
- test-oidc-task-group
321+
- test-azure-oidc-task-group
322+
- test-gcp-oidc-task-group
322323

323324
- name: in-use-encryption
324325
display_name: "In-Use Encryption"
@@ -636,7 +637,7 @@ task_groups:
636637
tasks:
637638
- test-aws-lambda-deployed
638639

639-
- name: testoidc_task_group
640+
- name: test-oidc-task-group
640641
setup_group:
641642
- func: fetch source
642643
- func: create expansions
@@ -665,14 +666,15 @@ task_groups:
665666
tasks:
666667
- oidc-auth-test-latest
667668

668-
- name: testazureoidc_task_group
669+
- name: test-azure-oidc-task-group
669670
setup_group:
670671
- func: fetch source
671672
- func: create expansions
672673
- func: prepare resources
673674
- func: fix absolute paths
674675
- func: init test-results
675676
- func: make files executable
677+
- func: install rust
676678
- command: subprocess.exec
677679
params:
678680
binary: bash
@@ -691,14 +693,15 @@ task_groups:
691693
tasks:
692694
- oidc-auth-test-azure-latest
693695

694-
- name: testgcpoidc_task_group
696+
- name: test-gcp-oidc-task-group
695697
setup_group:
696698
- func: fetch source
697699
- func: create expansions
698700
- func: prepare resources
699701
- func: fix absolute paths
700702
- func: init test-results
701703
- func: make files executable
704+
- func: install rust
702705
- command: subprocess.exec
703706
params:
704707
binary: bash
@@ -717,6 +720,31 @@ task_groups:
717720
tasks:
718721
- oidc-auth-test-gcp-latest
719722

723+
- name: test-k8s-oidc-task-group
724+
setup_group:
725+
- func: fetch source
726+
- func: create expansions
727+
- func: prepare resources
728+
- func: fix absolute paths
729+
- func: init test-results
730+
- func: make files executable
731+
- func: install rust
732+
- command: subprocess.exec
733+
params:
734+
binary: bash
735+
args:
736+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/setup.sh
737+
teardown_task:
738+
- command: subprocess.exec
739+
params:
740+
binary: bash
741+
args:
742+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/teardown.sh
743+
setup_group_can_fail_task: true
744+
setup_group_timeout_secs: 1800
745+
tasks:
746+
- oidc-auth-test-k8s-latest
747+
720748
- name: happy-eyeballs-task-group
721749
setup_group_can_fail_task: true
722750
setup_group_timeout_secs: 1800
@@ -1156,59 +1184,52 @@ tasks:
11561184

11571185
- name: "oidc-auth-test-azure-latest"
11581186
commands:
1159-
- command: shell.exec
1187+
- func: "build static test tarball"
1188+
vars:
1189+
BUILD_FEATURES: "--features azure-oidc"
1190+
- command: subprocess.exec
1191+
type: test
11601192
params:
11611193
working_dir: src
1162-
shell: bash
1163-
script: |-
1164-
set -o errexit
1165-
${PREPARE_SHELL}
1166-
./.evergreen/install-dependencies.sh rust
1167-
source .cargo/env
1168-
export AZUREOIDC_DRIVERS_TAR_FILE=/tmp/mongo-rust-driver.tar
1169-
rustup default stable
1170-
export RUSTFLAGS="-C target-feature=+crt-static"
1171-
cargo test --features azure-oidc --target x86_64-unknown-linux-gnu get_exe_name -- --ignored
1172-
export TEST_FILE=$(cat exe_name.txt)
1173-
rm "$AZUREOIDC_DRIVERS_TAR_FILE" || true
1174-
tar -cf $AZUREOIDC_DRIVERS_TAR_FILE $TEST_FILE
1175-
tar -uf $AZUREOIDC_DRIVERS_TAR_FILE ./.evergreen
1176-
rm "$AZUREOIDC_DRIVERS_TAR_FILE".gz || true
1177-
gzip $AZUREOIDC_DRIVERS_TAR_FILE
1178-
export AZUREOIDC_DRIVERS_TAR_FILE=/tmp/mongo-rust-driver.tar.gz
1179-
# Define the command to run on the azure VM.
1180-
# Ensure that we source the environment file created for us, set up any other variables we need,
1181-
# and then run our test suite on the vm.
1182-
export AZUREOIDC_TEST_CMD="ls -laR data && PROJECT_DIRECTORY='.' OIDC_ENV=azure OIDC=oidc TEST_FILE=./$TEST_FILE ./.evergreen/run-mongodb-oidc-test.sh"
1183-
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/azure/run-driver-test.sh
1194+
binary: bash
1195+
args:
1196+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/run-driver-test.sh
1197+
env:
1198+
AZUREOIDC_DRIVERS_TAR_FILE: ${STATIC_TEST_TARBALL}
1199+
AZUREOIDC_TEST_CMD: "ls -laR data && PROJECT_DIRECTORY='.' OIDC_ENV=azure OIDC=oidc TEST_FILE=./${STATIC_TEST_BINARY} ./.evergreen/run-mongodb-oidc-test.sh"
11841200

11851201
- name: "oidc-auth-test-gcp-latest"
11861202
commands:
1187-
- command: shell.exec
1203+
- func: "build static test tarball"
1204+
vars:
1205+
BUILD_FEATURES: "--features gcp-oidc"
1206+
- command: subprocess.exec
1207+
type: test
11881208
params:
11891209
working_dir: src
1190-
shell: bash
1191-
script: |-
1192-
set -o errexit
1193-
${PREPARE_SHELL}
1194-
./.evergreen/install-dependencies.sh rust
1195-
source .cargo/env
1196-
export GCPOIDC_DRIVERS_TAR_FILE=/tmp/mongo-rust-driver.tar
1197-
rustup default stable
1198-
export RUSTFLAGS="-C target-feature=+crt-static"
1199-
cargo test --features gcp-oidc --target x86_64-unknown-linux-gnu test::atlas_planned_maintenance_testing::get_exe_name -- --ignored
1200-
export TEST_FILE=$(cat exe_name.txt)
1201-
rm "$GCPOIDC_DRIVERS_TAR_FILE" || true
1202-
tar -cf $GCPOIDC_DRIVERS_TAR_FILE $TEST_FILE
1203-
tar -uf $GCPOIDC_DRIVERS_TAR_FILE ./.evergreen
1204-
rm "$GCPOIDC_DRIVERS_TAR_FILE".gz || true
1205-
gzip $GCPOIDC_DRIVERS_TAR_FILE
1206-
export GCPOIDC_DRIVERS_TAR_FILE=/tmp/mongo-rust-driver.tar.gz
1207-
# Define the command to run on the gcp VM.
1208-
# Ensure that we source the environment file created for us, set up any other variables we need,
1209-
# and then run our test suite on the vm.
1210-
export GCPOIDC_TEST_CMD="ls -la && PROJECT_DIRECTORY='.' OIDC_ENV=gcp OIDC=oidc TEST_FILE=./$TEST_FILE ./.evergreen/run-mongodb-oidc-test.sh"
1211-
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/gcp/run-driver-test.sh
1210+
binary: bash
1211+
args:
1212+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/gcp/run-driver-test.sh
1213+
env:
1214+
GCPOIDC_DRIVERS_TAR_FILE: ${STATIC_TEST_TARBALL}
1215+
GCPOIDC_TEST_CMD: "ls -la && PROJECT_DIRECTORY='.' OIDC_ENV=gcp OIDC=oidc TEST_FILE=./${STATIC_TEST_BINARY} ./.evergreen/run-mongodb-oidc-test.sh"
1216+
1217+
- name: "oidc-auth-test-k8s-latest"
1218+
commands:
1219+
- func: "build static test tarball"
1220+
- command: ec2.assume_role
1221+
params:
1222+
role_arn: ${aws_test_secrets_role}
1223+
duration_seconds: 1800
1224+
- func: "run oidc k8s test"
1225+
vars:
1226+
VARIANT: eks
1227+
- func: "run oidc k8s test"
1228+
vars:
1229+
VARIANT: gke
1230+
- func: "run oidc k8s test"
1231+
vars:
1232+
VARIANT: aks
12121233

12131234
- name: "test-happy-eyeballs"
12141235
commands:
@@ -1925,3 +1946,56 @@ functions:
19251946
- command: attach.xunit_results
19261947
params:
19271948
file: src/results.xml
1949+
1950+
"build static test tarball":
1951+
- command: subprocess.exec
1952+
params:
1953+
working_dir: src
1954+
binary: bash
1955+
args:
1956+
- .evergreen/build-static-test-tarball.sh
1957+
include_expansions_in_env:
1958+
- PROJECT_DIRECTORY
1959+
- BUILD_FEATURES
1960+
- command: expansions.update
1961+
params:
1962+
file: src/static-test-tarball-expansion.yml
1963+
1964+
"run oidc k8s test":
1965+
- command: subprocess.exec
1966+
params:
1967+
working_dir: src
1968+
binary: bash
1969+
args:
1970+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/setup-pod.sh
1971+
env:
1972+
K8S_VARIANT: ${VARIANT}
1973+
include_expansions_in_env:
1974+
- AWS_ACCESS_KEY_ID
1975+
- AWS_SECRET_ACCESS_KEY
1976+
- AWS_SESSION_TOKEN
1977+
- DRIVERS_TOOLS
1978+
- command: subprocess.exec
1979+
type: test
1980+
params:
1981+
working_dir: src
1982+
binary: bash
1983+
args:
1984+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/run-driver-test.sh
1985+
env:
1986+
K8S_DRIVERS_TAR_FILE: ${STATIC_TEST_TARBALL}
1987+
K8S_TEST_CMD: "ls -la && PROJECT_DIRECTORY='.' OIDC_ENV=k8s OIDC=oidc TEST_FILE=./${STATIC_TEST_BINARY} ./.evergreen/run-mongodb-oidc-test.sh"
1988+
include_expansions_in_env:
1989+
- AWS_ACCESS_KEY_ID
1990+
- AWS_SECRET_ACCESS_KEY
1991+
- AWS_SESSION_TOKEN
1992+
- command: subprocess.exec
1993+
params:
1994+
working_dir: src
1995+
binary: bash
1996+
args:
1997+
- ${DRIVERS_TOOLS}/.evergreen/auth_oidc/k8s/teardown-pod.sh
1998+
include_expansions_in_env:
1999+
- AWS_ACCESS_KEY_ID
2000+
- AWS_SECRET_ACCESS_KEY
2001+
- AWS_SESSION_TOKEN

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ elif [ $OIDC_ENV == "gcp" ]; then
3535

3636
$TEST_FILE test::spec::oidc::gcp --nocapture
3737
RESULT=$?
38+
elif [ $OIDC_ENV == "k8s" ]; then
39+
$TEST_FILE test::spec::oidc::k8s --nocapture
40+
RESULT=$?
3841
else
39-
echo "Unrecognized OIDC_ENV $OIDC_ENV"
42+
echo "Unrecognized OIDC_ENV '${OIDC_ENV}'"
4043
exit 1
4144
fi
4245

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ version = "0.11.5"
143143

144144
[dependencies.tokio]
145145
version = "1.17.0"
146-
features = ["io-util", "sync", "macros", "net", "process", "rt", "time"]
146+
features = ["io-util", "sync", "macros", "net", "process", "rt", "time", "fs"]
147147

148148
[dependencies.tokio-rustls]
149149
version = "0.24.1"

0 commit comments

Comments
 (0)