Skip to content

Commit 6604ae3

Browse files
authored
CDRIVER-4495 Test crypt_shared with older server versions (#1169)
* remove unused USE_CRYPT_SHARED expansion * add SKIP_CRYPT_SHARED_LIB expansion * rename asan-ubuntu-without-csfle to asan-ubuntu-with-mongocryptd * sync download-mongodb.sh to 1d7119eeb531e7fab60423e803a94f4a2f61ec0f * remove GENERIC_LINUX_URL check It does not provide much value. Calling get_mongodb_download_url_for now errors if a download is unavailable. Alternatively, this check can be limited to server versions < 4.2.
1 parent 9e37e3e commit 6604ae3

File tree

7 files changed

+65
-55
lines changed

7 files changed

+65
-55
lines changed

.evergreen/config.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ functions:
471471
export MONGOC_TEST_CSFLE_TLS_CA_FILE=../drivers-evergreen-tools/.evergreen/x509gen/ca.pem
472472
export MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=../drivers-evergreen-tools/.evergreen/x509gen/client.pem
473473
echo "Setting KMS credentials from the environment... done."
474+
export SKIP_CRYPT_SHARED_LIB="${SKIP_CRYPT_SHARED_LIB}"
474475
fi
475476
export LOADBALANCED=${LOADBALANCED}
476477
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"
@@ -1932,7 +1933,6 @@ tasks:
19321933
export SASL="AUTO"
19331934
export SKIP_MOCK_TESTS="ON"
19341935
export SSL="OPENSSL"
1935-
export USE_CRYPT_SHARED="${USE_CRYPT_SHARED}"
19361936
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh
19371937
rm CMakeCache.txt
19381938
set -o errexit
@@ -1965,7 +1965,6 @@ tasks:
19651965
export SASL="AUTO"
19661966
export SKIP_MOCK_TESTS="ON"
19671967
export SSL="OPENSSL_STATIC"
1968-
export USE_CRYPT_SHARED="${USE_CRYPT_SHARED}"
19691968
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh
19701969
rm CMakeCache.txt
19711970
set -o errexit
@@ -1998,7 +1997,6 @@ tasks:
19981997
export SASL="AUTO"
19991998
export SKIP_MOCK_TESTS="ON"
20001999
export SSL="DARWIN"
2001-
export USE_CRYPT_SHARED="${USE_CRYPT_SHARED}"
20022000
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh
20032001
rm CMakeCache.txt
20042002
set -o errexit
@@ -2031,7 +2029,6 @@ tasks:
20312029
export SASL="AUTO"
20322030
export SKIP_MOCK_TESTS="ON"
20332031
export SSL="WINDOWS"
2034-
export USE_CRYPT_SHARED="${USE_CRYPT_SHARED}"
20352032
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh
20362033
rm CMakeCache.txt
20372034
set -o errexit
@@ -2064,7 +2061,6 @@ tasks:
20642061
export SANITIZE="address"
20652062
export SKIP_MOCK_TESTS="ON"
20662063
export SSL="OPENSSL"
2067-
export USE_CRYPT_SHARED="${USE_CRYPT_SHARED}"
20682064
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh
20692065
rm CMakeCache.txt
20702066
set -o errexit
@@ -24879,11 +24875,11 @@ buildvariants:
2487924875
- .debug-compile .asan-clang
2488024876
- .test-asan !.3.6
2488124877
batchtime: 1440
24882-
- name: asan-ubuntu-without-csfle
24883-
display_name: ASAN Tests without csfle (Ubuntu 18.04)
24878+
- name: asan-ubuntu-with-mongocryptd
24879+
display_name: ASAN Tests with mongocryptd (Ubuntu 18.04)
2488424880
expansions:
2488524881
CC: clang
24886-
USE_CRYPT_SHARED: 'OFF'
24882+
SKIP_CRYPT_SHARED_LIB: 'on'
2488724883
run_on: ubuntu1804-test
2488824884
tasks:
2488924885
- debug-compile-asan-openssl-cse

.evergreen/download-mongodb.sh

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ get_mongodb_download_url_for ()
7373
case "$_DISTRO" in
7474
darwin--arm64)
7575
MONGODB_LATEST="http://downloads.10gen.com/osx/mongodb-macos-arm64-enterprise-latest.tgz"
76-
MONGODB_RAPID="http://downloads.10gen.com/osx/mongodb-macos-x86_64-enterprise-${VERSION_RAPID}.tgz"
76+
MONGODB_RAPID="http://downloads.10gen.com/osx/mongodb-macos-arm64-enterprise-${VERSION_RAPID}.tgz"
7777
MONGODB_60_LATEST="http://downloads.10gen.com/osx/mongodb-macos-arm64-enterprise-${VERSION_60_LATEST}.tgz"
7878
MONGODB_60="http://downloads.10gen.com/osx/mongodb-macos-arm64-enterprise-${VERSION_60}.tgz"
7979
MONGODB_50="http://downloads.10gen.com/osx/mongodb-macos-x86_64-enterprise-${VERSION_50}.tgz"
@@ -162,6 +162,7 @@ get_mongodb_download_url_for ()
162162
;;
163163
linux-rhel-7.1-ppc64le)
164164
MONGODB_LATEST="http://downloads.10gen.com/linux/mongodb-linux-ppc64le-enterprise-rhel71-latest.tgz"
165+
MONGODB_50="http://downloads.10gen.com/linux/mongodb-linux-ppc64le-enterprise-rhel71-${VERSION_50}.tgz"
165166
MONGODB_44="http://downloads.10gen.com/linux/mongodb-linux-ppc64le-enterprise-rhel71-${VERSION_44}.tgz"
166167
MONGODB_42="http://downloads.10gen.com/linux/mongodb-linux-ppc64le-enterprise-rhel71-${VERSION_42}.tgz"
167168
MONGODB_40="http://downloads.10gen.com/linux/mongodb-linux-ppc64le-enterprise-rhel71-${VERSION_40}.tgz"
@@ -486,46 +487,55 @@ get_mongodb_download_url_for ()
486487
;;
487488
esac
488489

489-
# The crypt_shared package is available on server 6.0 and newer.
490-
VERSION_INCLUDES_CRYPT_SHARED=YES
491490
case "$_VERSION" in
492-
latest) MONGODB_DOWNLOAD_URL=$MONGODB_LATEST
493-
# If latest is not at least 6.0 on this OS, the crypt_shared package will not be available.
494-
if [ -z $MONGODB_60 ]; then
495-
VERSION_INCLUDES_CRYPT_SHARED=NO
496-
fi ;;
497-
rapid) MONGODB_DOWNLOAD_URL=$MONGODB_RAPID
498-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
491+
latest) MONGODB_DOWNLOAD_URL=$MONGODB_LATEST ;;
492+
rapid) MONGODB_DOWNLOAD_URL=$MONGODB_RAPID ;;
499493
v6.0-latest) MONGODB_DOWNLOAD_URL=$MONGODB_60_LATEST ;;
500494
6.0) MONGODB_DOWNLOAD_URL=$MONGODB_60 ;;
501-
5.0) MONGODB_DOWNLOAD_URL=$MONGODB_50
502-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
503-
4.4) MONGODB_DOWNLOAD_URL=$MONGODB_44
504-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
505-
4.2) MONGODB_DOWNLOAD_URL=$MONGODB_42
506-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
507-
4.0) MONGODB_DOWNLOAD_URL=$MONGODB_40
508-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
509-
3.6) MONGODB_DOWNLOAD_URL=$MONGODB_36
510-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
511-
3.4) MONGODB_DOWNLOAD_URL=$MONGODB_34
512-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
513-
3.2) MONGODB_DOWNLOAD_URL=$MONGODB_32
514-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
515-
3.0) MONGODB_DOWNLOAD_URL=$MONGODB_30
516-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
517-
2.6) MONGODB_DOWNLOAD_URL=$MONGODB_26
518-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
519-
2.4) MONGODB_DOWNLOAD_URL=$MONGODB_24
520-
VERSION_INCLUDES_CRYPT_SHARED=NO ;;
495+
5.0) MONGODB_DOWNLOAD_URL=$MONGODB_50 ;;
496+
4.4) MONGODB_DOWNLOAD_URL=$MONGODB_44 ;;
497+
4.2) MONGODB_DOWNLOAD_URL=$MONGODB_42 ;;
498+
4.0) MONGODB_DOWNLOAD_URL=$MONGODB_40 ;;
499+
3.6) MONGODB_DOWNLOAD_URL=$MONGODB_36 ;;
500+
3.4) MONGODB_DOWNLOAD_URL=$MONGODB_34 ;;
501+
3.2) MONGODB_DOWNLOAD_URL=$MONGODB_32 ;;
502+
3.0) MONGODB_DOWNLOAD_URL=$MONGODB_30 ;;
503+
2.6) MONGODB_DOWNLOAD_URL=$MONGODB_26 ;;
504+
2.4) MONGODB_DOWNLOAD_URL=$MONGODB_24 ;;
521505
esac
522506

523-
[ -z "$MONGODB_DOWNLOAD_URL" ] && MONGODB_DOWNLOAD_URL="Unknown version: $_VERSION for $_DISTRO"
507+
if [ -z "$MONGODB_DOWNLOAD_URL" ]; then
508+
echo "Unknown version: $_VERSION for $_DISTRO"
509+
exit 1
510+
fi
511+
512+
# Get the download URL for crypt_shared.
513+
# The crypt_shared package is available on server 6.0 and newer.
514+
# Try to download a version of crypt_shared matching the server version.
515+
# If no matching version is available, try to download the latest Major release of crypt_shared.
516+
case "$_VERSION" in
517+
latest)
518+
# If latest is not at least 6.0 on this OS, the crypt_shared package will not be available.
519+
if [ -n "$MONGODB_60" ]; then
520+
MONGO_CRYPT_SHARED_DOWNLOAD_URL=$MONGODB_LATEST
521+
fi ;;
522+
rapid) MONGO_CRYPT_SHARED_DOWNLOAD_URL=$MONGODB_RAPID ;;
523+
v6.0-latest) MONGO_CRYPT_SHARED_DOWNLOAD_URL=$MONGODB_60_LATEST ;;
524+
6.0) MONGO_CRYPT_SHARED_DOWNLOAD_URL=$MONGODB_60 ;;
525+
5.0 | 4.4 | 4.2 | 4.0 | 3.6 | 3.4 | 3.2 | 3.0 | 2.6 | 2.4)
526+
# Default to using the latest Major release. Major releases are expected yearly.
527+
# MONGODB_60 may be empty if there is no 6.0 download available for this platform.
528+
MONGO_CRYPT_SHARED_DOWNLOAD_URL="$MONGODB_60"
529+
;;
530+
*) echo "Unknown version '$_VERSION'";
531+
exit 1;
532+
;;
533+
esac
524534

525-
if [ "$VERSION_INCLUDES_CRYPT_SHARED" = "YES" ]; then
535+
if [ -n "$MONGO_CRYPT_SHARED_DOWNLOAD_URL" ]; then
526536
# The crypt_shared package is simply the same file URL with the "mongodb-"
527537
# prefix replaced with "mongo_crypt_shared_v1-"
528-
MONGO_CRYPT_SHARED_DOWNLOAD_URL="$(printf '%s' "$MONGODB_DOWNLOAD_URL" | sed 's|/mongodb-|/mongo_crypt_shared_v1-|')"
538+
MONGO_CRYPT_SHARED_DOWNLOAD_URL="$(printf '%s' "$MONGO_CRYPT_SHARED_DOWNLOAD_URL" | sed 's|/mongodb-|/mongo_crypt_shared_v1-|')"
529539
fi
530540
echo $MONGODB_DOWNLOAD_URL
531541
}
@@ -563,12 +573,16 @@ download_and_extract ()
563573
# Download 5.0 package to get the legacy mongo shell as a workaround until DRIVERS-2328 is addressed.
564574
echo "Legacy 'mongo' shell not detected."
565575
echo "Download legacy shell from 5.0 ... begin"
566-
get_mongodb_download_url_for "$DISTRO" "5.0"
576+
# Use a subshell to avoid overwriting MONGODB_DOWNLOAD_URL and MONGO_CRYPT_SHARED_DOWNLOAD_URL.
577+
MONGODB50_DOWNLOAD_URL=$(
578+
get_mongodb_download_url_for "$DISTRO" "5.0" > /dev/null
579+
echo $MONGODB_DOWNLOAD_URL
580+
)
567581

568582
SAVED_DRIVERS_TOOLS=$DRIVERS_TOOLS
569583
mkdir $DRIVERS_TOOLS/legacy-shell-download
570584
DRIVERS_TOOLS=$DRIVERS_TOOLS/legacy-shell-download
571-
download_and_extract_package "$MONGODB_DOWNLOAD_URL" "$EXTRACT"
585+
download_and_extract_package "$MONGODB50_DOWNLOAD_URL" "$EXTRACT"
572586
if [ -e $DRIVERS_TOOLS/mongodb/bin/mongo ]; then
573587
cp $DRIVERS_TOOLS/mongodb/bin/mongo $SAVED_DRIVERS_TOOLS/mongodb/bin
574588
elif [ -e $DRIVERS_TOOLS/mongodb/bin/mongo.exe ]; then

.evergreen/integration-tests.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ DIR=$(dirname $0)
2828
. $DIR/download-mongodb.sh
2929

3030
get_distro
31-
GENERIC_LINUX_URL=$(get_mongodb_download_url_for "linux-x86_64" "$MONGODB_VERSION")
3231
get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION"
33-
if [ "$MONGODB_DOWNLOAD_URL" = "$GENERIC_LINUX_URL" -a ! "$SSL" = "nossl" ]; then
34-
echo "Requested a version of MongoDB with SSL, but only generic (non-SSL) Linux version available"
35-
exit 1;
36-
fi
3732
DRIVERS_TOOLS=./ download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT"
3833

3934

.evergreen/run-tests.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,16 @@ if [ "$CLIENT_SIDE_ENCRYPTION" = "on" ]; then
110110
wait_for_kms_server 9002
111111
wait_for_kms_server 5698
112112
echo "Waiting for mock KMS servers to start... done."
113-
if ! test -d /cygdrive/c; then
113+
114+
# Check if tests should use the crypt_shared library.
115+
if [ "$SKIP_CRYPT_SHARED_LIB" = "on" ]; then
116+
echo "crypt_shared library is skipped due to SKIP_CRYPT_SHARED_LIB=on"
117+
elif test -d /cygdrive/c; then
114118
# We have trouble with this test on Windows. only set cryptSharedLibPath on other platforms
119+
echo "crypt_shared library is skipped due to running on Windows"
120+
else
115121
export MONGOC_TEST_CRYPT_SHARED_LIB_PATH="$CRYPT_SHARED_LIB_PATH"
116-
echo "Setting env cryptSharedLibPath: [$MONGOC_TEST_CRYPT_SHARED_LIB_PATH]"
122+
echo "crypt_shared library will be loaded with cryptSharedLibPath: [$MONGOC_TEST_CRYPT_SHARED_LIB_PATH]"
117123
fi
118124
fi
119125

build/evergreen_config_lib/functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
export MONGOC_TEST_CSFLE_TLS_CA_FILE=../drivers-evergreen-tools/.evergreen/x509gen/ca.pem
347347
export MONGOC_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=../drivers-evergreen-tools/.evergreen/x509gen/client.pem
348348
echo "Setting KMS credentials from the environment... done."
349+
export SKIP_CRYPT_SHARED_LIB="${SKIP_CRYPT_SHARED_LIB}"
349350
fi
350351
export LOADBALANCED=${LOADBALANCED}
351352
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}"

build/evergreen_config_lib/tasks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def __init__(self, *args, **kwargs):
112112
extra_script=extra_script,
113113
EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON -DENABLE_MONGOC=OFF",
114114
SKIP_MOCK_TESTS="ON",
115-
USE_CRYPT_SHARED="${USE_CRYPT_SHARED}",
116115
**kwargs)
117116
self.add_tags('client-side-encryption', 'special')
118117

@@ -140,7 +139,6 @@ def __init__(self, *args, **kwargs):
140139
EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON -DENABLE_MONGOC=OFF -DENABLE_EXTRA_ALIGNMENT=OFF",
141140
PATH='/usr/lib/llvm-3.8/bin:$PATH',
142141
SKIP_MOCK_TESTS="ON",
143-
USE_CRYPT_SHARED="${USE_CRYPT_SHARED}",
144142
**kwargs)
145143
self.add_tags('client-side-encryption')
146144

build/evergreen_config_lib/variants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,12 @@ def days(n):
594594
'.test-asan !.3.6'],
595595
{'CC': 'clang'},
596596
batchtime=days(1)),
597-
Variant('asan-ubuntu-without-csfle',
598-
'ASAN Tests without csfle (Ubuntu 18.04)',
597+
Variant('asan-ubuntu-with-mongocryptd',
598+
'ASAN Tests with mongocryptd (Ubuntu 18.04)',
599599
'ubuntu1804-test',
600600
['debug-compile-asan-openssl-cse',
601601
'.test-asan !.3.6 .client-side-encryption'],
602-
{'CC': 'clang', 'USE_CRYPT_SHARED': 'OFF'},
602+
{'CC': 'clang', 'SKIP_CRYPT_SHARED_LIB': 'on'},
603603
batchtime=days(1)),
604604
# There is no MongoDB < 4.0 with SSL available on Ubuntu post 16.04.
605605
# So have a variant for ASAN to test against MongoDB 3.6.

0 commit comments

Comments
 (0)