Skip to content

Commit 2d1927c

Browse files
committed
PHPC-2135: Test with consistent version of crypt_shared
Use the crypt_shared library provisioned by download-mongodb.sh and add an additional task to disable the library and fall back to mongocryptd. This also revises how we pass environment variables into run-tests.sh and the test suite. Everything is now explicitly passed instead of relying on export attributes from a parent context.
1 parent 7469195 commit 2d1927c

File tree

2 files changed

+41
-37
lines changed

2 files changed

+41
-37
lines changed

.evergreen/config.yml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ functions:
362362
script: |
363363
${PREPARE_SHELL}
364364
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} LOAD_BALANCER=${LOAD_BALANCER} REQUIRE_API_VERSION=${REQUIRE_API_VERSION} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
365-
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
365+
# run-orchestration generates expansion file with MONGODB_URI and CRYPT_SHARED_LIB_PATH
366366
- command: expansions.update
367367
params:
368368
file: mo-expansion.yml
@@ -388,8 +388,14 @@ functions:
388388
working_dir: "src"
389389
script: |
390390
${PREPARE_SHELL}
391-
export CRYPT_SHARED_LIB_PATH="${client_side_encryption_crypt_shared_lib_path}"
392-
API_VERSION=${API_VERSION} TESTS=${TESTS} SSL=${SSL} MONGODB_URI="${MONGODB_URI}${APPEND_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
391+
API_VERSION=${API_VERSION} \
392+
CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH} \
393+
MONGODB_URI="${MONGODB_URI}${APPEND_URI}" \
394+
SKIP_CRYPT_SHARED=${SKIP_CRYPT_SHARED} \
395+
SSL=${SSL} \
396+
SSL_DIR=${SSL_DIR} \
397+
TESTS=${TESTS} \
398+
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
393399
394400
"cleanup":
395401
- command: shell.exec
@@ -467,18 +473,6 @@ functions:
467473
${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop
468474
fi
469475
470-
"fetch crypt_shared":
471-
- command: shell.exec
472-
params:
473-
script: |
474-
# TODO: Specify same version provisioned by download-mongodb.sh (see: DRIVERS-2355)
475-
python3 ${DRIVERS_TOOLS}/.evergreen/mongodl.py --component crypt_shared --version latest --only "**/mongo_crypt_v1.so" --out ${DRIVERS_TOOLS}/.evergreen/csfle --strip-path-components 1
476-
- command: expansions.update
477-
params:
478-
updates:
479-
- key: client_side_encryption_crypt_shared_lib_path
480-
value: ${DRIVERS_TOOLS}/.evergreen/csfle/mongo_crypt_v1.so
481-
482476
pre:
483477
- func: "fetch source"
484478
- func: "prepare resources"
@@ -598,14 +592,15 @@ tasks:
598592
vars:
599593
TESTS: "tests/atlas.phpt"
600594

601-
- name: "test-crypt_shared"
595+
- name: "test-skip_crypt_shared"
602596
commands:
603597
- func: "compile driver"
604598
- func: "bootstrap mongo-orchestration"
605599
vars:
606600
TOPOLOGY: "replica_set"
607-
- func: "fetch crypt_shared"
608601
- func: "run tests"
602+
vars:
603+
SKIP_CRYPT_SHARED: "yes"
609604

610605
- name: "test-loadBalanced"
611606
tags: ["loadbalanced"]
@@ -1256,9 +1251,9 @@ buildvariants:
12561251
tasks:
12571252
- name: "test-loadBalanced"
12581253

1259-
# CSFLE crypt_shared is available from MongoDB 6.0+
1260-
- matrix_name: "test-csfle-crypt_shared"
1254+
# CSFLE crypt_shared is available from MongoDB 6.0+, so explicitly test without it to allow use of mongocryptd
1255+
- matrix_name: "test-csfle-skip_crypt_shared"
12611256
matrix_spec: { "os": "debian11", "mongodb-versions": "6.0", "php-edge-versions": "latest-stable" }
1262-
display_name: "CSFLE crypt_shared - ${mongodb-versions}"
1257+
display_name: "CSFLE skip_crypt_shared - ${mongodb-versions}"
12631258
tasks:
1264-
- name: "test-crypt_shared"
1259+
- name: "test-skip_crypt_shared"

.evergreen/run-tests.sh

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#!/bin/sh
22
set -o errexit # Exit the script with error if any of the commands fail
33

4-
# Supported/used environment variables:
5-
# SSL Set to "yes" to enable SSL. Defaults to "nossl"
6-
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
7-
# TESTS Optional TESTS environment variable for run-tests.php
8-
# API_VERSION Optional API_VERSION environment variable for run-tests.php
9-
10-
SSL=${SSL:-nossl}
11-
MONGODB_URI=${MONGODB_URI:-}
12-
TESTS=${TESTS:-}
13-
API_VERSION=${API_VERSION:-}
4+
# Supported environment variables
5+
API_VERSION=${API_VERSION:-} # Optional API_VERSION environment variable for run-tests.php
6+
CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH:-}" # Optional path to crypt_shared library
7+
MONGODB_URI=${MONGODB_URI:-} # Connection string (including credentials and topology info)
8+
SKIP_CRYPT_SHARED="${SKIP_CRYPT_SHARED:-no}" # Specify "yes" to ignore CRYPT_SHARED_LIB_PATH. Defaults to "no"
9+
SSL=${SSL:-no} # Specify "yes" to enable SSL. Defaults to "no"
10+
SSL_DIR=${SSL_DIR-} # Optional SSL_DIR environment variable for run-tests.php
11+
TESTS=${TESTS:-} # Optional TESTS environment variable for run-tests.php
1412

1513
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
1614
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
@@ -28,12 +26,23 @@ if [ "$SSL" = "yes" ]; then
2826
fi
2927
fi
3028

29+
if [ "${SKIP_CRYPT_SHARED}" = "yes" ]; then
30+
CRYPT_SHARED_LIB_PATH=""
31+
echo "crypt_shared library is skipped"
32+
elif [ -z "${CRYPT_SHARED_LIB_PATH}" ]; then
33+
echo "crypt_shared library path is empty"
34+
else
35+
echo "crypt_shared library will be loaded from path: $CRYPT_SHARED_LIB_PATH"
36+
fi
37+
3138
echo "Running tests with URI: $MONGODB_URI"
3239

3340
# Run the tests, and store the results in a junit result file
34-
case "$OS" in
35-
*)
36-
API_VERSION="${API_VERSION}" TEST_PHP_JUNIT="${PROJECT_DIRECTORY}/test-results.xml" TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test TESTS=$TESTS
37-
;;
38-
esac
39-
41+
API_VERSION="${API_VERSION}" \
42+
CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH}" \
43+
MONGODB_URI="${MONGODB_URI}" \
44+
SSL_DIR="${SSL_DIR}" \
45+
TEST_PHP_JUNIT="${PROJECT_DIRECTORY}/test-results.xml" \
46+
TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" \
47+
TESTS="$TESTS" \
48+
make test

0 commit comments

Comments
 (0)