Skip to content

CXX-2612 Use DET hygienic scripts for Python binary selection and venv creation #913

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 10 commits into from
Dec 19, 2022
Merged
68 changes: 32 additions & 36 deletions .mci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,12 @@ functions:
script: |
set -o errexit
set -o pipefail
cd drivers-evergreen-tools/.evergreen/orchestration
if [ -f venv/bin/activate ]; then
. venv/bin/activate
elif [ -f venv/Scripts/activate ]; then
. venv/Scripts/activate
if cd drivers-evergreen-tools/.evergreen/orchestration; then
. ../venv-utils.sh
if venvactivate venv; then
mongo-orchestration stop
fi
fi
mongo-orchestration stop

"install_c_driver":
- command: expansions.update
Expand Down Expand Up @@ -293,12 +292,22 @@ functions:
set -o errexit
echo "Preparing CSFLE venv environment..."
cd ./drivers-evergreen-tools/.evergreen/csfle
# This function ensures future invocations of activate_venv.sh conducted in
# This function ensures future invocations of activate-kmstlsvenv.sh conducted in
# parallel do not race to setup a venv environment; it has already been prepared.
# This primarily addresses the situation where the "test" and "run_kms_servers"
# functions invoke 'activate_venv.sh' simultaneously.
. ./activate_venv.sh
deactivate
# functions invoke 'activate-kmstlsvenv.sh' simultaneously.
if [[ "$OSTYPE" =~ cygwin && ! -d kmstlsvenv ]]; then
# Avoid using Python 3.10 on Windows due to incompatible cipher suites.
# See CXX-2628.
. ../venv-utils.sh
venvcreate "C:/python/Python39/python.exe" kmstlsvenv || # windows-2017
venvcreate "C:/python/Python38/python.exe" kmstlsvenv # windows-2015
python -m pip install --upgrade boto3~=1.19 pykmip~=0.10.0
deactivate
else
. ./activate-kmstlsvenv.sh
deactivate
fi
echo "Preparing CSFLE venv environment... done."
- command: shell.exec
params:
Expand All @@ -308,7 +317,7 @@ functions:
set -o errexit
echo "Starting mock KMS servers..."
cd ./drivers-evergreen-tools/.evergreen/csfle
. ./activate_venv.sh
. ./activate-kmstlsvenv.sh
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8999 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 9000 &
python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 9001 &
Expand Down Expand Up @@ -346,21 +355,14 @@ functions:
fi
export CMAKE=${cmake}

if [ "x$(lsb_release -cs)" = "xtrusty" -a -f /opt/mongodbtoolchain/v2/bin/python ]; then
/opt/mongodbtoolchain/v2/bin/python -m virtualenv venv
elif ! python -m virtualenv venv 2>/dev/null; then
/opt/mongodbtoolchain/v3/bin/python3 -m venv venv
if [ ! -d ../drivers-evergreen-tools ]; then
git clone --depth 1 [email protected]:mongodb-labs/drivers-evergreen-tools.git ../drivers-evergreen-tools
fi
. ../drivers-evergreen-tools/.evergreen/find-python3.sh
. ../drivers-evergreen-tools/.evergreen/venv-utils.sh

cd venv
if [ -f bin/activate ]; then
. bin/activate
./bin/pip install GitPython
elif [ -f Scripts/activate ]; then
. Scripts/activate
./Scripts/pip install GitPython
fi
cd ..
venvcreate "$(find_python3)" venv
python -m pip install GitPython

export GENERATOR="${generator}"

Expand Down Expand Up @@ -444,11 +446,11 @@ functions:
export AWS_SECRET_ACCESS_KEY="${cse_aws_secret_access_key}"
export AWS_ACCESS_KEY_ID="${cse_aws_access_key_id}"
export AWS_DEFAULT_REGION="us-east-1"
echo "Running activate_venv.sh..."
. ./activate_venv.sh
echo "Running activate_venv.sh... done."
echo "Running activate-kmstlsvenv.sh..."
. ./activate-kmstlsvenv.sh
echo "Running activate-kmstlsvenv.sh... done."
echo "Running set-temp-creds.sh..."
PYTHON="$(type -P python)" . ./set-temp-creds.sh
. ./set-temp-creds.sh
echo "Running set-temp-creds.sh... done."
deactivate
popd # "$DRIVERS_TOOLS/.evergreen/csfle"
Expand All @@ -460,14 +462,8 @@ functions:
exit 1
fi

if [ "Windows_NT" == "$OS"]; then
export MONGOCXX_TEST_CSFLE_TLS_CA_FILE=$DRIVERS_TOOLS\.evergreen\x509gen\ca.pem
export MONGOCXX_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=$DRIVERS_TOOLS\.evergreen\x509gen\client.pem
else
export MONGOCXX_TEST_CSFLE_TLS_CA_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem
export MONGOCXX_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/client.pem
fi

export MONGOCXX_TEST_CSFLE_TLS_CA_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem
export MONGOCXX_TEST_CSFLE_TLS_CERTIFICATE_KEY_FILE=$DRIVERS_TOOLS/.evergreen/x509gen/client.pem
export MONGOCXX_TEST_AWS_TEMP_ACCESS_KEY_ID="$CSFLE_AWS_TEMP_ACCESS_KEY_ID"
export MONGOCXX_TEST_AWS_TEMP_SECRET_ACCESS_KEY="$CSFLE_AWS_TEMP_SECRET_ACCESS_KEY"
export MONGOCXX_TEST_AWS_TEMP_SESSION_TOKEN="$CSFLE_AWS_TEMP_SESSION_TOKEN"
Expand Down
8 changes: 4 additions & 4 deletions src/mongocxx/test/collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2337,10 +2337,10 @@ TEST_CASE("read_concern is inherited from parent", "[collection]") {
}
}

void find_index_and_validate(
collection& coll,
stdx::string_view index_name,
const std::function<void(bsoncxx::document::view)>& validate = [](bsoncxx::document::view) {}) {
void find_index_and_validate(collection& coll,
stdx::string_view index_name,
const std::function<void(bsoncxx::document::view)>& validate =
[](bsoncxx::document::view) {}) {
auto cursor = coll.list_indexes();

for (auto&& index : cursor) {
Expand Down
18 changes: 8 additions & 10 deletions src/mongocxx/test/uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,20 +333,18 @@ TEST_CASE("uri::compressors()", "[uri]") {

// Zero is not allowed for heartbeatFrequencyMS.
TEST_CASE("uri::heartbeat_frequency_ms()", "[uri]") {
_test_int32_option(
"heartbeatFrequencyMS",
[](mongocxx::uri& uri) { return uri.heartbeat_frequency_ms(); },
"1234",
false);
_test_int32_option("heartbeatFrequencyMS",
[](mongocxx::uri& uri) { return uri.heartbeat_frequency_ms(); },
"1234",
false);
}

// -1 to 9 are only valid values of zlib compression level.
TEST_CASE("uri::zlib_compression_level()", "[uri]") {
_test_int32_option(
"zlibCompressionLevel",
[](mongocxx::uri& uri) { return uri.zlib_compression_level(); },
"5",
true);
_test_int32_option("zlibCompressionLevel",
[](mongocxx::uri& uri) { return uri.zlib_compression_level(); },
"5",
true);
}

// End special cases.
Expand Down