Skip to content

Commit 0fe1a0f

Browse files
authored
PHPLIB-911: Test with consistent version of crypt_shared (#965)
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, and restructures run-tests.sh a bit.
1 parent 6ca0384 commit 0fe1a0f

File tree

2 files changed

+50
-42
lines changed

2 files changed

+50
-42
lines changed

.evergreen/config.yml

+26-23
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ functions:
176176
script: |
177177
${PREPARE_SHELL}
178178
MONGODB_VERSION=${VERSION} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} LOAD_BALANCER=${LOAD_BALANCER} REQUIRE_API_VERSION=${REQUIRE_API_VERSION} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
179-
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
179+
# run-orchestration generates expansion file with MONGODB_URI and CRYPT_SHARED_LIB_PATH
180180
- command: expansions.update
181181
params:
182182
file: mo-expansion.yml
@@ -246,9 +246,16 @@ functions:
246246
export KMS_ENDPOINT_REQUIRE_CLIENT_CERT="${client_side_encryption_kms_endpoint_require_client_cert}"
247247
export KMS_TLS_CA_FILE="${client_side_encryption_kms_tls_ca_file}"
248248
export KMS_TLS_CERTIFICATE_KEY_FILE="${client_side_encryption_kms_tls_certificate_key_file}"
249-
export CRYPT_SHARED_LIB_PATH="${client_side_encryption_crypt_shared_lib_path}"
250249
export PATH="${PHP_PATH}/bin:$PATH"
251-
API_VERSION=${API_VERSION} PHP_VERSION=${PHP_VERSION} TESTS=${TESTS} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
250+
251+
API_VERSION=${API_VERSION} \
252+
CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH} \
253+
MONGODB_URI="${MONGODB_URI}" \
254+
PHP_VERSION=${PHP_VERSION} \
255+
SKIP_CRYPT_SHARED=${SKIP_CRYPT_SHARED} \
256+
SSL=${SSL} \
257+
TESTS=${TESTS} \
258+
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
252259
253260
"run atlas data lake test":
254261
- command: shell.exec
@@ -258,7 +265,10 @@ functions:
258265
script: |
259266
${PREPARE_SHELL}
260267
export PATH="${PHP_PATH}/bin:$PATH"
261-
PHP_VERSION=${PHP_VERSION} TESTS="atlas-data-lake" AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
268+
269+
MONGODB_URI="mongodb://mhuser:[email protected]:27017" \
270+
TESTS="atlas-data-lake" \
271+
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
262272
263273
"run serverless tests":
264274
- command: shell.exec
@@ -271,7 +281,12 @@ functions:
271281
export MONGODB_USERNAME=${SERVERLESS_ATLAS_USER}
272282
export MONGODB_PASSWORD=${SERVERLESS_ATLAS_PASSWORD}
273283
export PATH="${PHP_PATH}/bin:$PATH"
274-
PHP_VERSION=${PHP_VERSION} TESTS="serverless" MONGODB_URI="${SERVERLESS_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
284+
285+
CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH} \
286+
MONGODB_URI="${SERVERLESS_URI}" \
287+
SKIP_CRYPT_SHARED=${SKIP_CRYPT_SHARED} \
288+
TESTS="serverless" \
289+
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
275290
276291
"cleanup":
277292
- command: shell.exec
@@ -378,18 +393,6 @@ functions:
378393
- key: client_side_encryption_kmip_endpoint
379394
value: localhost:5698
380395

381-
"fetch crypt_shared":
382-
- command: shell.exec
383-
params:
384-
script: |
385-
# TODO: Specify same version provisioned by download-mongodb.sh (see: DRIVERS-2355)
386-
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
387-
- command: expansions.update
388-
params:
389-
updates:
390-
- key: client_side_encryption_crypt_shared_lib_path
391-
value: ${DRIVERS_TOOLS}/.evergreen/csfle/mongo_crypt_v1.so
392-
393396
pre:
394397
- func: "fetch source"
395398
- func: "prepare resources"
@@ -521,15 +524,15 @@ tasks:
521524
SSL: "yes"
522525
# Note: "stop load balancer" will be called from "post"
523526

524-
- name: "test-crypt_shared"
527+
- name: "test-skip_crypt_shared"
525528
commands:
526529
- func: "bootstrap mongo-orchestration"
527530
vars:
528531
TOPOLOGY: "replica_set"
529532
- func: "start kms servers"
530-
- func: "fetch crypt_shared"
531533
- func: "run tests"
532534
vars:
535+
SKIP_CRYPT_SHARED: "yes"
533536
TESTS: "csfle"
534537

535538
# }}}
@@ -792,9 +795,9 @@ buildvariants:
792795
tasks:
793796
- name: "test-loadBalanced"
794797

795-
# CSFLE crypt_shared is available from MongoDB 6.0+
796-
- matrix_name: "test-csfle-crypt_shared"
798+
# CSFLE crypt_shared is available from MongoDB 6.0+, so explicitly test without it to allow use of mongocryptd
799+
- matrix_name: "test-csfle-skip_crypt_shared"
797800
matrix_spec: { "os": "debian11", "mongodb-versions": "6.0", "php-edge-versions": "latest-stable", "driver-versions": "latest-stable" }
798-
display_name: "CSFLE crypt_shared - ${mongodb-versions}"
801+
display_name: "CSFLE skip_crypt_shared - ${mongodb-versions}"
799802
tasks:
800-
- name: "test-crypt_shared"
803+
- name: "test-skip_crypt_shared"

.evergreen/run-tests.sh

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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-
# API_VERSION Optional API_VERSION environment variable for run-tests.php
8-
# IS_MATRIX_TESTING Set to "true" to enable matrix testing. Defaults to empty string. If "true", DRIVER_MONGODB_VERSION and MONGODB_VERSION will also be checked.
9-
10-
SSL=${SSL:-nossl}
11-
MONGODB_URI=${MONGODB_URI:-}
12-
API_VERSION=${API_VERSION:-}
13-
IS_MATRIX_TESTING=${IS_MATRIX_TESTING:-}
4+
# Supported environment variables
5+
API_VERSION=${API_VERSION:-} # Optional API_VERSION environment variable
6+
CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH:-}" # Optional path to crypt_shared library
7+
DRIVER_MONGODB_VERSION={$DRIVER_MONGODB_VERSION:-} # Required if IS_MATRIX_TESTING is "true"
8+
IS_MATRIX_TESTING=${IS_MATRIX_TESTING:-} # Specify "true" to enable matrix testing. Defaults to empty string. If "true", DRIVER_MONGODB_VERSION and MONGODB_VERSION will also be checked.
9+
MONGODB_URI=${MONGODB_URI:-} # Connection string (including credentials and topology info)
10+
MONGODB_VERSION=${MONGODB_VERSION:-} # Required if IS_MATRIX_TESTING is "true"
11+
SKIP_CRYPT_SHARED="${SKIP_CRYPT_SHARED:-no}" # Specify "yes" to ignore CRYPT_SHARED_LIB_PATH. Defaults to "no"
12+
SSL=${SSL:-no} # Specify "yes" to enable SSL. Defaults to "no"
13+
TESTS=${TESTS:-} # Optional test group. Defaults to all tests
1414

1515
# For matrix testing, we have to determine the correct driver version
1616
if [ "${IS_MATRIX_TESTING}" = "true" ]; then
@@ -42,7 +42,7 @@ if [ "${IS_MATRIX_TESTING}" = "true" ]; then
4242
fi
4343

4444
# Enable verbose output to see skipped and incomplete tests
45-
PHPUNIT_OPTS="${PHPUNIT_OPTS} -v"
45+
PHPUNIT_OPTS="${PHPUNIT_OPTS} -v --configuration phpunit.evergreen.xml"
4646

4747
# Determine if MONGODB_URI already has a query string
4848
SUFFIX=$(echo "$MONGODB_URI" | grep -Eo "\?(.*)" | cat)
@@ -57,29 +57,34 @@ fi
5757

5858
echo "Running tests with URI: $MONGODB_URI"
5959

60-
# Disable failing PHPUnit due to deprecations
60+
# Disable PHPUnit test failures due to deprecations
61+
# See: https://symfony.com/doc/current/components/phpunit_bridge.html#internal-deprecations
6162
export SYMFONY_DEPRECATIONS_HELPER=999999
6263

63-
# Run the tests, and store the results in a Evergreen compatible JSON results file
64+
# Export environment vars that may be referenced by the test suite
65+
export API_VERSION="${API_VERSION}"
66+
export CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH}"
67+
export MONGODB_URI="${MONGODB_URI}"
68+
69+
# Run the tests, and store the results in a junit result file
6470
case "$TESTS" in
6571
atlas-data-lake*)
66-
MONGODB_URI="mongodb://mhuser:[email protected]:27017"
67-
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --testsuite "Atlas Data Lake Test Suite" $PHPUNIT_OPTS
72+
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --testsuite "Atlas Data Lake Test Suite"
6873
;;
6974

7075
csfle)
71-
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --group csfle $PHPUNIT_OPTS
76+
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group csfle
7277
;;
7378

7479
versioned-api)
75-
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --group versioned-api $PHPUNIT_OPTS
80+
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group versioned-api
7681
;;
7782

7883
serverless)
79-
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --group serverless $PHPUNIT_OPTS
84+
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group serverless
8085
;;
8186

8287
*)
83-
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml $PHPUNIT_OPTS
88+
php vendor/bin/simple-phpunit $PHPUNIT_OPTS
8489
;;
8590
esac

0 commit comments

Comments
 (0)