Skip to content

Commit 7e462c9

Browse files
durranaddaleaxbaileympearson
authored
test(NODE-4463): download shared lib in evergreen (#3333)
Co-authored-by: Anna Henningsen <[email protected]> Co-authored-by: Bailey Pearson <[email protected]>
1 parent 74fe82a commit 7e462c9

File tree

6 files changed

+207
-6
lines changed

6 files changed

+207
-6
lines changed

.evergreen/config.in.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,41 @@ functions:
789789
790790
MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-custom-csfle-tests.sh
791791
792+
"run custom csfle shared lib tests":
793+
- command: shell.exec
794+
type: test
795+
params:
796+
silent: true
797+
working_dir: "src"
798+
script: |
799+
${PREPARE_SHELL}
800+
cat <<EOT > prepare_client_encryption.sh
801+
export CLIENT_ENCRYPTION='${CLIENT_ENCRYPTION}'
802+
export CSFLE_KMS_PROVIDERS='${CSFLE_KMS_PROVIDERS}'
803+
export AWS_ACCESS_KEY_ID='${AWS_ACCESS_KEY_ID}'
804+
export AWS_SECRET_ACCESS_KEY='${AWS_SECRET_ACCESS_KEY}'
805+
export CSFLE_GIT_REF='${CSFLE_GIT_REF}'
806+
export CDRIVER_GIT_REF='${CDRIVER_GIT_REF}'
807+
EOT
808+
- command: shell.exec
809+
type: test
810+
params:
811+
working_dir: "src"
812+
timeout_secs: 60
813+
script: |
814+
${PREPARE_SHELL}
815+
816+
# Disable xtrace (just in case it was accidentally set).
817+
set +x
818+
. ./prepare_client_encryption.sh
819+
rm -f ./prepare_client_encryption.sh
820+
821+
VERSION=${VERSION} DRIVERS_TOOLS=${DRIVERS_TOOLS} \
822+
bash ${PROJECT_DIRECTORY}/.evergreen/prepare-crypt-shared-lib.sh
823+
824+
MONGODB_URI="${MONGODB_URI}" CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH}" \
825+
bash ${PROJECT_DIRECTORY}/.evergreen/run-custom-csfle-tests.sh
826+
792827
"run custom snappy tests":
793828
- command: subprocess.exec
794829
params:

.evergreen/config.yml

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,40 @@ functions:
754754
rm -f ./prepare_client_encryption.sh
755755
756756
MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-custom-csfle-tests.sh
757+
run custom csfle shared lib tests:
758+
- command: shell.exec
759+
type: test
760+
params:
761+
silent: true
762+
working_dir: src
763+
script: |
764+
${PREPARE_SHELL}
765+
cat <<EOT > prepare_client_encryption.sh
766+
export CLIENT_ENCRYPTION='${CLIENT_ENCRYPTION}'
767+
export CSFLE_KMS_PROVIDERS='${CSFLE_KMS_PROVIDERS}'
768+
export AWS_ACCESS_KEY_ID='${AWS_ACCESS_KEY_ID}'
769+
export AWS_SECRET_ACCESS_KEY='${AWS_SECRET_ACCESS_KEY}'
770+
export CSFLE_GIT_REF='${CSFLE_GIT_REF}'
771+
export CDRIVER_GIT_REF='${CDRIVER_GIT_REF}'
772+
EOT
773+
- command: shell.exec
774+
type: test
775+
params:
776+
working_dir: src
777+
timeout_secs: 60
778+
script: |
779+
${PREPARE_SHELL}
780+
781+
# Disable xtrace (just in case it was accidentally set).
782+
set +x
783+
. ./prepare_client_encryption.sh
784+
rm -f ./prepare_client_encryption.sh
785+
786+
VERSION=${VERSION} DRIVERS_TOOLS=${DRIVERS_TOOLS} \
787+
bash ${PROJECT_DIRECTORY}/.evergreen/prepare-crypt-shared-lib.sh
788+
789+
MONGODB_URI="${MONGODB_URI}" CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH}" \
790+
bash ${PROJECT_DIRECTORY}/.evergreen/run-custom-csfle-tests.sh
757791
run custom snappy tests:
758792
- command: subprocess.exec
759793
params:
@@ -1653,7 +1687,7 @@ tasks:
16531687
- func: run bson-ext test
16541688
vars:
16551689
NODE_LTS_NAME: erbium
1656-
- name: run-custom-csfle-tests-pinned-commit
1690+
- name: run-custom-csfle-tests-mongocryptd-pinned-commit
16571691
tags:
16581692
- run-custom-dependency-tests
16591693
commands:
@@ -1668,7 +1702,7 @@ tasks:
16681702
- func: run custom csfle tests
16691703
vars:
16701704
CSFLE_GIT_REF: c2712248e9f4909cdad723607ea5291d2eb48b91
1671-
- name: run-custom-csfle-tests-master
1705+
- name: run-custom-csfle-tests-mongocryptd-master
16721706
tags:
16731707
- run-custom-dependency-tests
16741708
commands:
@@ -1683,6 +1717,38 @@ tasks:
16831717
- func: run custom csfle tests
16841718
vars:
16851719
CSFLE_GIT_REF: master
1720+
- name: run-custom-csfle-shared-lib-tests-pinned-commit
1721+
tags:
1722+
- run-custom-dependency-tests
1723+
commands:
1724+
- func: install dependencies
1725+
vars:
1726+
NODE_LTS_NAME: erbium
1727+
- func: bootstrap mongo-orchestration
1728+
vars:
1729+
VERSION: latest
1730+
TOPOLOGY: replica_set
1731+
- func: bootstrap kms servers
1732+
- func: run custom csfle shared lib tests
1733+
vars:
1734+
VERSION: latest
1735+
CSFLE_GIT_REF: c2712248e9f4909cdad723607ea5291d2eb48b91
1736+
- name: run-custom-csfle-shared-lib-tests-master
1737+
tags:
1738+
- run-custom-dependency-tests
1739+
commands:
1740+
- func: install dependencies
1741+
vars:
1742+
NODE_LTS_NAME: erbium
1743+
- func: bootstrap mongo-orchestration
1744+
vars:
1745+
VERSION: latest
1746+
TOPOLOGY: replica_set
1747+
- func: bootstrap kms servers
1748+
- func: run custom csfle shared lib tests
1749+
vars:
1750+
VERSION: latest
1751+
CSFLE_GIT_REF: master
16861752
- name: test-latest-server-noauth
16871753
tags:
16881754
- latest
@@ -2243,8 +2309,10 @@ buildvariants:
22432309
tasks:
22442310
- run-custom-snappy-tests
22452311
- run-bson-ext-test
2246-
- run-custom-csfle-tests-pinned-commit
2247-
- run-custom-csfle-tests-master
2312+
- run-custom-csfle-tests-mongocryptd-pinned-commit
2313+
- run-custom-csfle-tests-mongocryptd-master
2314+
- run-custom-csfle-shared-lib-tests-pinned-commit
2315+
- run-custom-csfle-shared-lib-tests-master
22482316
- name: ubuntu1804-test-serverless
22492317
display_name: Serverless Test
22502318
run_on: ubuntu1804-test

.evergreen/generate_evergreen_tasks.js

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ const oneOffFuncAsTasks = oneOffFuncs.map(oneOffFunc => ({
537537
}));
538538

539539
oneOffFuncAsTasks.push({
540-
name: 'run-custom-csfle-tests-pinned-commit',
540+
name: 'run-custom-csfle-tests-mongocryptd-pinned-commit',
541541
tags: ['run-custom-dependency-tests'],
542542
commands: [
543543
{
@@ -564,7 +564,7 @@ oneOffFuncAsTasks.push({
564564
});
565565

566566
oneOffFuncAsTasks.push({
567-
name: 'run-custom-csfle-tests-master',
567+
name: 'run-custom-csfle-tests-mongocryptd-master',
568568
tags: ['run-custom-dependency-tests'],
569569
commands: [
570570
{
@@ -590,6 +590,62 @@ oneOffFuncAsTasks.push({
590590
]
591591
});
592592

593+
oneOffFuncAsTasks.push({
594+
name: 'run-custom-csfle-shared-lib-tests-pinned-commit',
595+
tags: ['run-custom-dependency-tests'],
596+
commands: [
597+
{
598+
func: 'install dependencies',
599+
vars: {
600+
NODE_LTS_NAME: LOWEST_LTS
601+
}
602+
},
603+
{
604+
func: 'bootstrap mongo-orchestration',
605+
vars: {
606+
VERSION: 'latest',
607+
TOPOLOGY: 'replica_set'
608+
}
609+
},
610+
{ func: 'bootstrap kms servers' },
611+
{
612+
func: 'run custom csfle shared lib tests',
613+
vars: {
614+
VERSION: 'latest',
615+
CSFLE_GIT_REF: 'c2712248e9f4909cdad723607ea5291d2eb48b91'
616+
}
617+
}
618+
]
619+
});
620+
621+
oneOffFuncAsTasks.push({
622+
name: 'run-custom-csfle-shared-lib-tests-master',
623+
tags: ['run-custom-dependency-tests'],
624+
commands: [
625+
{
626+
func: 'install dependencies',
627+
vars: {
628+
NODE_LTS_NAME: LOWEST_LTS
629+
}
630+
},
631+
{
632+
func: 'bootstrap mongo-orchestration',
633+
vars: {
634+
VERSION: 'latest',
635+
TOPOLOGY: 'replica_set'
636+
}
637+
},
638+
{ func: 'bootstrap kms servers' },
639+
{
640+
func: 'run custom csfle shared lib tests',
641+
vars: {
642+
VERSION: 'latest',
643+
CSFLE_GIT_REF: 'master'
644+
}
645+
}
646+
]
647+
});
648+
593649
// TODO NODE-3897 - generate combined coverage report
594650
const coverageTask = {
595651
name: 'download and merge coverage'.split(' ').join('-'),
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
MONGODB_VERSION=${VERSION}
2+
if [ -z "$MONGODB_VERSION" ]; then
3+
# default to latest to match behavior of run-orchestration.sh.
4+
MONGODB_VERSION=latest
5+
fi
6+
7+
. $DRIVERS_TOOLS/.evergreen/download-mongodb.sh
8+
get_distro
9+
# get_distro defines $DISTRO.
10+
echo "distro='$DISTRO' version='$MONGODB_VERSION'".
11+
get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION"
12+
# get_mongodb_download_url_for defines $MONGO_CRYPT_SHARED_DOWNLOAD_URL and $EXTRACT.
13+
if [ -z "$MONGO_CRYPT_SHARED_DOWNLOAD_URL" ]; then
14+
echo "There is no crypt_shared library for distro='$DISTRO' and version='$MONGODB_VERSION'".
15+
exit 1
16+
else
17+
echo "Downloading crypt_shared package from $MONGO_CRYPT_SHARED_DOWNLOAD_URL"
18+
download_and_extract_crypt_shared "$MONGO_CRYPT_SHARED_DOWNLOAD_URL" "$EXTRACT"
19+
CRYPT_SHARED_LIB_PATH="$(find $(pwd) -maxdepth 1 -type f \
20+
-name 'mongo_crypt_v1.so' -o \
21+
-name 'mongo_crypt_v1.dll' -o \
22+
-name 'mongo_crypt_v1.dylib')"
23+
# Expect that we always find a crypt_shared library file and set the CRYPT_SHARED_LIB_PATH
24+
# environment variable. If we didn't, print an error message and exit.
25+
if [ -z "$CRYPT_SHARED_LIB_PATH" ]; then
26+
echo 'CRYPT_SHARED_LIB_PATH is empty. Exiting.'
27+
exit 1
28+
fi
29+
# If we're on Windows, convert the "cygdrive" path to Windows-style paths.
30+
if [ "Windows_NT" = "$OS" ]; then
31+
CRYPT_SHARED_LIB_PATH=$(cygpath -m $CRYPT_SHARED_LIB_PATH)
32+
fi
33+
echo "CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH"
34+
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
35+
fi

.evergreen/run-custom-csfle-tests.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export MONGODB_URI=${MONGODB_URI}
6565
export KMIP_TLS_CA_FILE="${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem"
6666
export KMIP_TLS_CERT_FILE="${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem"
6767
export TEST_CSFLE=true
68+
69+
if [ -n "$CRYPT_SHARED_LIB_PATH" ]; then
70+
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
71+
fi
72+
6873
set +o errexit # We want to run both test suites even if the first fails
6974
npm run check:csfle
7075
DRIVER_CSFLE_TEST_RESULT=$?

test/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ The following steps will walk you through how to run the tests for CSFLE.
416416

417417
The output of the tests will include sections like "Client Side Encryption Corpus," "Client Side Encryption Functional," "Client Side Encryption Prose Tests," and "Client Side Encryption."
418418

419+
To run the functional tests using the crypt shared library instead of mongocryptd, download the appropriate version of the crypt shared library for the enterprise server version [here](https://www.mongodb.com/download-center/enterprise/releases) and then set the location of it in the environment variable `CRYPT_SHARED_LIB_PATH`.
420+
419421
#### KMIP FLE support tests
420422

421423
1. Install virtualenv: `pip install virtualenv`

0 commit comments

Comments
 (0)