Skip to content

Commit 548610c

Browse files
authored
CXX-2162 Use DET hygienic scripts for Python binary selection and venv creation (#913)
* Replace activate_venv.sh with activate-kmstlsvenv.sh * Replace manual Python selection in compile function * Use venv-utils.sh in stop_mongod function * Format collection.cpp and uri.cpp to address lint task failure * Guard cd to potentially missing DET repo * CXX-2628 Apply Python >=3.10 selection workaround used by C Driver * Remove special-casing of TLS test cert files
1 parent a10c3f0 commit 548610c

File tree

3 files changed

+44
-50
lines changed

3 files changed

+44
-50
lines changed

.mci.yml

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,12 @@ functions:
213213
script: |
214214
set -o errexit
215215
set -o pipefail
216-
cd drivers-evergreen-tools/.evergreen/orchestration
217-
if [ -f venv/bin/activate ]; then
218-
. venv/bin/activate
219-
elif [ -f venv/Scripts/activate ]; then
220-
. venv/Scripts/activate
216+
if cd drivers-evergreen-tools/.evergreen/orchestration; then
217+
. ../venv-utils.sh
218+
if venvactivate venv; then
219+
mongo-orchestration stop
220+
fi
221221
fi
222-
mongo-orchestration stop
223222
224223
"install_c_driver":
225224
- command: expansions.update
@@ -293,12 +292,22 @@ functions:
293292
set -o errexit
294293
echo "Preparing CSFLE venv environment..."
295294
cd ./drivers-evergreen-tools/.evergreen/csfle
296-
# This function ensures future invocations of activate_venv.sh conducted in
295+
# This function ensures future invocations of activate-kmstlsvenv.sh conducted in
297296
# parallel do not race to setup a venv environment; it has already been prepared.
298297
# This primarily addresses the situation where the "test" and "run_kms_servers"
299-
# functions invoke 'activate_venv.sh' simultaneously.
300-
. ./activate_venv.sh
301-
deactivate
298+
# functions invoke 'activate-kmstlsvenv.sh' simultaneously.
299+
if [[ "$OSTYPE" =~ cygwin && ! -d kmstlsvenv ]]; then
300+
# Avoid using Python 3.10 on Windows due to incompatible cipher suites.
301+
# See CXX-2628.
302+
. ../venv-utils.sh
303+
venvcreate "C:/python/Python39/python.exe" kmstlsvenv || # windows-2017
304+
venvcreate "C:/python/Python38/python.exe" kmstlsvenv # windows-2015
305+
python -m pip install --upgrade boto3~=1.19 pykmip~=0.10.0
306+
deactivate
307+
else
308+
. ./activate-kmstlsvenv.sh
309+
deactivate
310+
fi
302311
echo "Preparing CSFLE venv environment... done."
303312
- command: shell.exec
304313
params:
@@ -308,7 +317,7 @@ functions:
308317
set -o errexit
309318
echo "Starting mock KMS servers..."
310319
cd ./drivers-evergreen-tools/.evergreen/csfle
311-
. ./activate_venv.sh
320+
. ./activate-kmstlsvenv.sh
312321
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8999 &
313322
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 9000 &
314323
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 9001 &
@@ -346,21 +355,14 @@ functions:
346355
fi
347356
export CMAKE=${cmake}
348357
349-
if [ "x$(lsb_release -cs)" = "xtrusty" -a -f /opt/mongodbtoolchain/v2/bin/python ]; then
350-
/opt/mongodbtoolchain/v2/bin/python -m virtualenv venv
351-
elif ! python -m virtualenv venv 2>/dev/null; then
352-
/opt/mongodbtoolchain/v3/bin/python3 -m venv venv
358+
if [ ! -d ../drivers-evergreen-tools ]; then
359+
git clone --depth 1 [email protected]:mongodb-labs/drivers-evergreen-tools.git ../drivers-evergreen-tools
353360
fi
361+
. ../drivers-evergreen-tools/.evergreen/find-python3.sh
362+
. ../drivers-evergreen-tools/.evergreen/venv-utils.sh
354363
355-
cd venv
356-
if [ -f bin/activate ]; then
357-
. bin/activate
358-
./bin/pip install GitPython
359-
elif [ -f Scripts/activate ]; then
360-
. Scripts/activate
361-
./Scripts/pip install GitPython
362-
fi
363-
cd ..
364+
venvcreate "$(find_python3)" venv
365+
python -m pip install GitPython
364366
365367
export GENERATOR="${generator}"
366368
@@ -444,11 +446,11 @@ functions:
444446
export AWS_SECRET_ACCESS_KEY="${cse_aws_secret_access_key}"
445447
export AWS_ACCESS_KEY_ID="${cse_aws_access_key_id}"
446448
export AWS_DEFAULT_REGION="us-east-1"
447-
echo "Running activate_venv.sh..."
448-
. ./activate_venv.sh
449-
echo "Running activate_venv.sh... done."
449+
echo "Running activate-kmstlsvenv.sh..."
450+
. ./activate-kmstlsvenv.sh
451+
echo "Running activate-kmstlsvenv.sh... done."
450452
echo "Running set-temp-creds.sh..."
451-
PYTHON="$(type -P python)" . ./set-temp-creds.sh
453+
. ./set-temp-creds.sh
452454
echo "Running set-temp-creds.sh... done."
453455
deactivate
454456
popd # "$DRIVERS_TOOLS/.evergreen/csfle"
@@ -460,14 +462,8 @@ functions:
460462
exit 1
461463
fi
462464
463-
if [ "Windows_NT" == "$OS"]; then
464-
export MONGOCXX_TEST_CSFLE_TLS_CA_FILE=$DRIVERS_TOOLS\.evergreen\x509gen\ca.pem
465-
export MONGOCXX_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=$DRIVERS_TOOLS\.evergreen\x509gen\client.pem
466-
else
467-
export MONGOCXX_TEST_CSFLE_TLS_CA_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem
468-
export MONGOCXX_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/client.pem
469-
fi
470-
465+
export MONGOCXX_TEST_CSFLE_TLS_CA_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem
466+
export MONGOCXX_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/client.pem
471467
export MONGOCXX_TEST_AWS_TEMP_ACCESS_KEY_ID="$CSFLE_AWS_TEMP_ACCESS_KEY_ID"
472468
export MONGOCXX_TEST_AWS_TEMP_SECRET_ACCESS_KEY="$CSFLE_AWS_TEMP_SECRET_ACCESS_KEY"
473469
export MONGOCXX_TEST_AWS_TEMP_SESSION_TOKEN="$CSFLE_AWS_TEMP_SESSION_TOKEN"

src/mongocxx/test/collection.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,10 +2337,10 @@ TEST_CASE("read_concern is inherited from parent", "[collection]") {
23372337
}
23382338
}
23392339

2340-
void find_index_and_validate(
2341-
collection& coll,
2342-
stdx::string_view index_name,
2343-
const std::function<void(bsoncxx::document::view)>& validate = [](bsoncxx::document::view) {}) {
2340+
void find_index_and_validate(collection& coll,
2341+
stdx::string_view index_name,
2342+
const std::function<void(bsoncxx::document::view)>& validate =
2343+
[](bsoncxx::document::view) {}) {
23442344
auto cursor = coll.list_indexes();
23452345

23462346
for (auto&& index : cursor) {

src/mongocxx/test/uri.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,18 @@ TEST_CASE("uri::compressors()", "[uri]") {
333333

334334
// Zero is not allowed for heartbeatFrequencyMS.
335335
TEST_CASE("uri::heartbeat_frequency_ms()", "[uri]") {
336-
_test_int32_option(
337-
"heartbeatFrequencyMS",
338-
[](mongocxx::uri& uri) { return uri.heartbeat_frequency_ms(); },
339-
"1234",
340-
false);
336+
_test_int32_option("heartbeatFrequencyMS",
337+
[](mongocxx::uri& uri) { return uri.heartbeat_frequency_ms(); },
338+
"1234",
339+
false);
341340
}
342341

343342
// -1 to 9 are only valid values of zlib compression level.
344343
TEST_CASE("uri::zlib_compression_level()", "[uri]") {
345-
_test_int32_option(
346-
"zlibCompressionLevel",
347-
[](mongocxx::uri& uri) { return uri.zlib_compression_level(); },
348-
"5",
349-
true);
344+
_test_int32_option("zlibCompressionLevel",
345+
[](mongocxx::uri& uri) { return uri.zlib_compression_level(); },
346+
"5",
347+
true);
350348
}
351349

352350
// End special cases.

0 commit comments

Comments
 (0)