Skip to content

PHPC-2135: Test with consistent version of crypt_shared #1353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ functions:
script: |
${PREPARE_SHELL}
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
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
# run-orchestration generates expansion file with MONGODB_URI and CRYPT_SHARED_LIB_PATH
- command: expansions.update
params:
file: mo-expansion.yml
Expand All @@ -388,8 +388,14 @@ functions:
working_dir: "src"
script: |
${PREPARE_SHELL}
export CRYPT_SHARED_LIB_PATH="${client_side_encryption_crypt_shared_lib_path}"
API_VERSION=${API_VERSION} TESTS=${TESTS} SSL=${SSL} MONGODB_URI="${MONGODB_URI}${APPEND_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
API_VERSION=${API_VERSION} \
CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH} \
MONGODB_URI="${MONGODB_URI}${APPEND_URI}" \
SKIP_CRYPT_SHARED=${SKIP_CRYPT_SHARED} \
SSL=${SSL} \
SSL_DIR=${SSL_DIR} \
TESTS=${TESTS} \
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this is a larger diff than required, but it should minimize future diffs if we introduce or otherwise change vars to run-tests.sh down the line. Alternatively, we could use export for everything and avoid the backslashes (as is already the case for $SSL_DIR), but being explicit here lets us more easily match up with the supported vars documented in run-tests.sh.


"cleanup":
- command: shell.exec
Expand Down Expand Up @@ -467,18 +473,6 @@ functions:
${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop
fi

"fetch crypt_shared":
- command: shell.exec
params:
script: |
# TODO: Specify same version provisioned by download-mongodb.sh (see: DRIVERS-2355)
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
- command: expansions.update
params:
updates:
- key: client_side_encryption_crypt_shared_lib_path
value: ${DRIVERS_TOOLS}/.evergreen/csfle/mongo_crypt_v1.so

pre:
- func: "fetch source"
- func: "prepare resources"
Expand Down Expand Up @@ -598,14 +592,15 @@ tasks:
vars:
TESTS: "tests/atlas.phpt"

- name: "test-crypt_shared"
- name: "test-skip_crypt_shared"
commands:
- func: "compile driver"
- func: "bootstrap mongo-orchestration"
vars:
TOPOLOGY: "replica_set"
- func: "fetch crypt_shared"
- func: "run tests"
vars:
SKIP_CRYPT_SHARED: "yes"

- name: "test-loadBalanced"
tags: ["loadbalanced"]
Expand Down Expand Up @@ -1256,9 +1251,9 @@ buildvariants:
tasks:
- name: "test-loadBalanced"

# CSFLE crypt_shared is available from MongoDB 6.0+
- matrix_name: "test-csfle-crypt_shared"
# CSFLE crypt_shared is available from MongoDB 6.0+, so explicitly test without it to allow use of mongocryptd
- matrix_name: "test-csfle-skip_crypt_shared"
matrix_spec: { "os": "debian11", "mongodb-versions": "6.0", "php-edge-versions": "latest-stable" }
display_name: "CSFLE crypt_shared - ${mongodb-versions}"
display_name: "CSFLE skip_crypt_shared - ${mongodb-versions}"
tasks:
- name: "test-crypt_shared"
- name: "test-skip_crypt_shared"
41 changes: 25 additions & 16 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/bin/sh
set -o errexit # Exit the script with error if any of the commands fail

# Supported/used environment variables:
# SSL Set to "yes" to enable SSL. Defaults to "nossl"
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
# TESTS Optional TESTS environment variable for run-tests.php
# API_VERSION Optional API_VERSION environment variable for run-tests.php

SSL=${SSL:-nossl}
MONGODB_URI=${MONGODB_URI:-}
TESTS=${TESTS:-}
API_VERSION=${API_VERSION:-}
# Supported environment variables
API_VERSION=${API_VERSION:-} # Optional API_VERSION environment variable for run-tests.php
CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH:-}" # Optional path to crypt_shared library
MONGODB_URI=${MONGODB_URI:-} # Connection string (including credentials and topology info)
SKIP_CRYPT_SHARED="${SKIP_CRYPT_SHARED:-no}" # Specify "yes" to ignore CRYPT_SHARED_LIB_PATH. Defaults to "no"
SSL=${SSL:-no} # Specify "yes" to enable SSL. Defaults to "no"
SSL_DIR=${SSL_DIR-} # Optional SSL_DIR environment variable for run-tests.php
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically redundant since $SSL_DIR is exported by $PREPARE_SHELL in the Evergreen config, but I appreciated that this lines up with the documented env vars in basic.inc and CONTRIBUTING.md.

TESTS=${TESTS:-} # Optional TESTS environment variable for run-tests.php
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another change intended to minimize future diffs as we add/remove params.


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

if [ "${SKIP_CRYPT_SHARED}" = "yes" ]; then
CRYPT_SHARED_LIB_PATH=""
echo "crypt_shared library is skipped"
elif [ -z "${CRYPT_SHARED_LIB_PATH}" ]; then
echo "crypt_shared library path is empty"
else
echo "crypt_shared library will be loaded from path: $CRYPT_SHARED_LIB_PATH"
fi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was adapted from the related changes in GODRIVER-2492.


echo "Running tests with URI: $MONGODB_URI"

# Run the tests, and store the results in a junit result file
case "$OS" in
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall when this case construct was actually used for OS-specific behavior, but it currently serves no purpose.

*)
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
;;
esac

API_VERSION="${API_VERSION}" \
CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH}" \
MONGODB_URI="${MONGODB_URI}" \
SSL_DIR="${SSL_DIR}" \
TEST_PHP_JUNIT="${PROJECT_DIRECTORY}/test-results.xml" \
TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" \
TESTS="$TESTS" \
make test
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although make does allow env vars to be specified after the command, I opted to put everything up front so we have everything on its own line as was done in the Evergreen task definition.