From 8d2287ba93b4f0d2dfb957a15c89bee01d7f2311 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 12:32:50 -0600 Subject: [PATCH 01/18] PYTHON-4646 Improve usage of hatch in evergreen --- .evergreen/config.yml | 2 +- .evergreen/generated_configs/variants.yml | 9 ---- .evergreen/hatch.sh | 47 ++------------------- .evergreen/scripts/configure-env.sh | 1 - .evergreen/scripts/generate_config.py | 7 +--- .evergreen/scripts/install-dependencies.sh | 49 ++++++++++++++++++++-- .evergreen/scripts/run-tests.sh | 1 - .gitignore | 1 + 8 files changed, 53 insertions(+), 64 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index ac89270d84..5c0e2983ea 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -42,7 +42,7 @@ functions: # Make an evergreen expansion file with dynamic values - command: subprocess.exec params: - include_expansions_in_env: ["is_patch", "project", "version_id", "AUTH", "SSL", "test_encryption", "test_encryption_pyopenssl", "test_crypt_shared", "test_pyopenssl", "SETDEFAULTENCODING", "test_loadbalancer", "test_serverless", "SKIP_CSOT_TESTS", "MONGODB_STARTED", "DISABLE_TEST_COMMANDS", "GREEN_FRAMEWORK", "NO_EXT", "COVERAGE", "COMPRESSORS", "TEST_SUITES", "MONGODB_API_VERSION", "SKIP_HATCH", "skip_crypt_shared", "VERSION", "TOPOLOGY", "STORAGE_ENGINE", "ORCHESTRATION_FILE", "REQUIRE_API_VERSION", "LOAD_BALANCER", "skip_web_identity_auth_test", "skip_ECS_auth_test"] + include_expansions_in_env: ["is_patch", "project", "version_id", "AUTH", "SSL", "test_encryption", "test_encryption_pyopenssl", "test_crypt_shared", "test_pyopenssl", "SETDEFAULTENCODING", "test_loadbalancer", "test_serverless", "SKIP_CSOT_TESTS", "MONGODB_STARTED", "DISABLE_TEST_COMMANDS", "GREEN_FRAMEWORK", "NO_EXT", "COVERAGE", "COMPRESSORS", "TEST_SUITES", "MONGODB_API_VERSION", "skip_crypt_shared", "VERSION", "TOPOLOGY", "STORAGE_ENGINE", "ORCHESTRATION_FILE", "REQUIRE_API_VERSION", "LOAD_BALANCER", "skip_web_identity_auth_test", "skip_ECS_auth_test"] binary: bash working_dir: "src" args: diff --git a/.evergreen/generated_configs/variants.yml b/.evergreen/generated_configs/variants.yml index 928347f567..226f4238f2 100644 --- a/.evergreen/generated_configs/variants.yml +++ b/.evergreen/generated_configs/variants.yml @@ -8,7 +8,6 @@ buildvariants: - rhel79-small batchtime: 10080 expansions: - SKIP_HATCH: "true" PYTHON_BINARY: /opt/python/3.9/bin/python3 - name: other-hosts-rhel9-fips tasks: @@ -17,8 +16,6 @@ buildvariants: run_on: - rhel92-fips batchtime: 10080 - expansions: - SKIP_HATCH: "true" - name: other-hosts-rhel8-zseries tasks: - name: .6.0 .standalone !.sync_async @@ -26,8 +23,6 @@ buildvariants: run_on: - rhel8-zseries-small batchtime: 10080 - expansions: - SKIP_HATCH: "true" - name: other-hosts-rhel8-power8 tasks: - name: .6.0 .standalone !.sync_async @@ -35,8 +30,6 @@ buildvariants: run_on: - rhel8-power-small batchtime: 10080 - expansions: - SKIP_HATCH: "true" - name: other-hosts-rhel8-arm64 tasks: - name: .6.0 .standalone !.sync_async @@ -44,8 +37,6 @@ buildvariants: run_on: - rhel82-arm64-small batchtime: 10080 - expansions: - SKIP_HATCH: "true" # Atlas connect tests - name: atlas-connect-rhel8-python3.9 diff --git a/.evergreen/hatch.sh b/.evergreen/hatch.sh index 98cd9ed734..f0f20ac2fb 100755 --- a/.evergreen/hatch.sh +++ b/.evergreen/hatch.sh @@ -1,45 +1,6 @@ #!/bin/bash -set -o errexit # Exit the script with error if any of the commands fail -set -x +set -eu -. .evergreen/utils.sh - -if [ -z "$PYTHON_BINARY" ]; then - PYTHON_BINARY=$(find_python3) -fi - -# Check if we should skip hatch and run the tests directly. -if [ -n "$SKIP_HATCH" ]; then - ENV_NAME=testenv-$RANDOM - createvirtualenv "$PYTHON_BINARY" $ENV_NAME - # shellcheck disable=SC2064 - trap "deactivate; rm -rf $ENV_NAME" EXIT HUP - python -m pip install -e ".[test]" - run_hatch() { - bash ./.evergreen/run-tests.sh - } -else # Set up virtualenv before installing hatch - # Use a random venv name because the encryption tasks run this script multiple times in the same run. - ENV_NAME=hatchenv-$RANDOM - createvirtualenv "$PYTHON_BINARY" $ENV_NAME - # shellcheck disable=SC2064 - trap "deactivate; rm -rf $ENV_NAME" EXIT HUP - python -m pip install -q hatch - - # Ensure hatch does not write to user or global locations. - touch hatch_config.toml - HATCH_CONFIG=$(pwd)/hatch_config.toml - if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin - HATCH_CONFIG=$(cygpath -m "$HATCH_CONFIG") - fi - export HATCH_CONFIG - hatch config restore - hatch config set dirs.data "$(pwd)/.hatch/data" - hatch config set dirs.cache "$(pwd)/.hatch/cache" - - run_hatch() { - python -m hatch run "$@" - } -fi - -run_hatch "${@:1}" +. ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh +venvactivate .venv +python -m hatch run "$@" diff --git a/.evergreen/scripts/configure-env.sh b/.evergreen/scripts/configure-env.sh index 3c0a0436de..94fa11ce97 100755 --- a/.evergreen/scripts/configure-env.sh +++ b/.evergreen/scripts/configure-env.sh @@ -47,7 +47,6 @@ export NO_EXT="${NO_EXT:-}" export COVERAGE="${COVERAGE:-}" export COMPRESSORS="${COMPRESSORS:-}" export MONGODB_API_VERSION="${MONGODB_API_VERSION:-}" -export SKIP_HATCH="${SKIP_HATCH:-}" export skip_crypt_shared="${skip_crypt_shared:-}" export STORAGE_ENGINE="${STORAGE_ENGINE:-}" export REQUIRE_API_VERSION="${REQUIRE_API_VERSION:-}" diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index b7187b50db..c7f55fa946 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -744,7 +744,6 @@ def create_aws_auth_variants(): def create_alternative_hosts_variants(): - expansions = dict(SKIP_HATCH="true") batchtime = BATCHTIME_WEEK variants = [] @@ -752,11 +751,10 @@ def create_alternative_hosts_variants(): variants.append( create_variant( [".5.0 .standalone !.sync_async"], - get_display_name("OpenSSL 1.0.2", host, python=CPYTHONS[0], **expansions), + get_display_name("OpenSSL 1.0.2", host, python=CPYTHONS[0]), host=host, python=CPYTHONS[0], batchtime=batchtime, - expansions=expansions, ) ) @@ -765,8 +763,7 @@ def create_alternative_hosts_variants(): variants.append( create_variant( [".6.0 .standalone !.sync_async"], - display_name=get_display_name("Other hosts", host, **expansions), - expansions=expansions, + display_name=get_display_name("Other hosts", host), batchtime=batchtime, host=host, ) diff --git a/.evergreen/scripts/install-dependencies.sh b/.evergreen/scripts/install-dependencies.sh index ebcc8f3069..91eda05f96 100755 --- a/.evergreen/scripts/install-dependencies.sh +++ b/.evergreen/scripts/install-dependencies.sh @@ -1,6 +1,47 @@ #!/bin/bash -set -o xtrace -file="$PROJECT_DIRECTORY/.evergreen/install-dependencies.sh" -# Don't use ${file} syntax here because evergreen treats it as an empty expansion. -[ -f "$file" ] && bash "$file" || echo "$file not available, skipping" +set -eu + +CARGO_HOME=${CARGO_HOME:-${DRIVERS_TOOLS}/.cargo} +# Handle paths on Windows. +if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin + CARGO_HOME=$(cygpath -m $CARGO_HOME) +fi + +# Install a virtual env with "hatch" +# Ensure there is a python venv. +. ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh +VENV_DIR=.venv +if [ ! -d $VENV_DIR ]; then + echo "Creating virtual environment..." + . ${DRIVERS_TOOLS}/.evergreen/find-python3.sh + PYTHON_BINARY=$(ensure_python3) + venvcreate $PYTHON_BINARY $VENV_DIR + echo "Creating virtual environment... done." +fi + +venvactivate $VENV_DIR +python --version + +echo "Installing hatch..." +python -m pip install -U pip +python -m pip install hatch || { + # Install rust and try again. + export RUSTUP_HOME="${CARGO_HOME}/.rustup" + ${DRIVERS_TOOLS}/.evergreen/install-rust.sh + source "${CARGO_HOME}/env" + python -m pip install hatch +} +# Ensure hatch does not write to user or global locations. +touch hatch_config.toml +HATCH_CONFIG=$(pwd)/hatch_config.toml +if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin + HATCH_CONFIG=$(cygpath -m "$HATCH_CONFIG") +fi +export HATCH_CONFIG +hatch config restore +hatch config set dirs.data "$(pwd)/.hatch/data" +hatch config set dirs.cache "$(pwd)/.hatch/cache" + +echo "Installing hatch... done." +hatch --version diff --git a/.evergreen/scripts/run-tests.sh b/.evergreen/scripts/run-tests.sh index 495db83e70..6986a0bbee 100755 --- a/.evergreen/scripts/run-tests.sh +++ b/.evergreen/scripts/run-tests.sh @@ -51,5 +51,4 @@ GREEN_FRAMEWORK=${GREEN_FRAMEWORK} \ TEST_DATA_LAKE=${TEST_DATA_LAKE:-} \ TEST_SUITES=${TEST_SUITES:-} \ MONGODB_API_VERSION=${MONGODB_API_VERSION} \ - SKIP_HATCH=${SKIP_HATCH} \ bash "${PROJECT_DIRECTORY}"/.evergreen/hatch.sh test:test-eg diff --git a/.gitignore b/.gitignore index 69dd20efa3..a75d84430b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ secrets-export.sh libmongocrypt.tar.gz libmongocrypt/ libmongocrypt_git/ +hatch_config.toml # Lambda temp files test/lambda/.aws-sam From 2062c9b6248a3839ac1ad18788ac568c5287f071 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 13:21:37 -0600 Subject: [PATCH 02/18] use hatch if it is installed --- .evergreen/hatch.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.evergreen/hatch.sh b/.evergreen/hatch.sh index f0f20ac2fb..cba5c5f7c3 100755 --- a/.evergreen/hatch.sh +++ b/.evergreen/hatch.sh @@ -1,6 +1,8 @@ #!/bin/bash set -eu -. ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh -venvactivate .venv -python -m hatch run "$@" +if [ ! -x "$(command -v hatch)" ]; then + . ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh + venvactivate .venv +fi +hatch run "$@" From f8532f067d9390b77c5daf0c1ba360c628a9e0cb Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 13:44:37 -0600 Subject: [PATCH 03/18] try another way to ensure hatch --- .evergreen/hatch.sh | 5 +-- .evergreen/scripts/ensure-hatch.sh | 48 +++++++++++++++++++++ .evergreen/scripts/install-dependencies.sh | 49 ++-------------------- 3 files changed, 53 insertions(+), 49 deletions(-) create mode 100755 .evergreen/scripts/ensure-hatch.sh diff --git a/.evergreen/hatch.sh b/.evergreen/hatch.sh index cba5c5f7c3..74a708ccc4 100755 --- a/.evergreen/hatch.sh +++ b/.evergreen/hatch.sh @@ -1,8 +1,5 @@ #!/bin/bash set -eu -if [ ! -x "$(command -v hatch)" ]; then - . ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh - venvactivate .venv -fi +. .evergreen/ensure-hatch.sh hatch run "$@" diff --git a/.evergreen/scripts/ensure-hatch.sh b/.evergreen/scripts/ensure-hatch.sh new file mode 100755 index 0000000000..ddbae46242 --- /dev/null +++ b/.evergreen/scripts/ensure-hatch.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -eu + +# Install a virtual env with "hatch" +# Ensure there is a python venv. +if [ ! -x "$(command -v hatch)" ]; then + . ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh + VENV_DIR=.venv + if [ ! -d $VENV_DIR ]; then + echo "Creating virtual environment..." + . ${DRIVERS_TOOLS}/.evergreen/find-python3.sh + PYTHON_BINARY=$(ensure_python3) + venvcreate $PYTHON_BINARY $VENV_DIR + echo "Creating virtual environment... done." + fi + + venvactivate $VENV_DIR + python --version + + echo "Installing hatch..." + python -m pip install -U pip + python -m pip install hatch || { + # Install rust and try again. + CARGO_HOME=${CARGO_HOME:-${DRIVERS_TOOLS}/.cargo} + # Handle paths on Windows. + if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin + CARGO_HOME=$(cygpath -m $CARGO_HOME) + fi + export RUSTUP_HOME="${CARGO_HOME}/.rustup" + ${DRIVERS_TOOLS}/.evergreen/install-rust.sh + source "${CARGO_HOME}/env" + python -m pip install hatch + } + # Ensure hatch does not write to user or global locations. + touch hatch_config.toml + HATCH_CONFIG=$(pwd)/hatch_config.toml + if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin + HATCH_CONFIG=$(cygpath -m "$HATCH_CONFIG") + fi + export HATCH_CONFIG + hatch config restore + hatch config set dirs.data "$(pwd)/.hatch/data" + hatch config set dirs.cache "$(pwd)/.hatch/cache" + + echo "Installing hatch... done." +fi +hatch --version diff --git a/.evergreen/scripts/install-dependencies.sh b/.evergreen/scripts/install-dependencies.sh index 91eda05f96..ebcc8f3069 100755 --- a/.evergreen/scripts/install-dependencies.sh +++ b/.evergreen/scripts/install-dependencies.sh @@ -1,47 +1,6 @@ #!/bin/bash -set -eu - -CARGO_HOME=${CARGO_HOME:-${DRIVERS_TOOLS}/.cargo} -# Handle paths on Windows. -if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin - CARGO_HOME=$(cygpath -m $CARGO_HOME) -fi - -# Install a virtual env with "hatch" -# Ensure there is a python venv. -. ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh -VENV_DIR=.venv -if [ ! -d $VENV_DIR ]; then - echo "Creating virtual environment..." - . ${DRIVERS_TOOLS}/.evergreen/find-python3.sh - PYTHON_BINARY=$(ensure_python3) - venvcreate $PYTHON_BINARY $VENV_DIR - echo "Creating virtual environment... done." -fi - -venvactivate $VENV_DIR -python --version - -echo "Installing hatch..." -python -m pip install -U pip -python -m pip install hatch || { - # Install rust and try again. - export RUSTUP_HOME="${CARGO_HOME}/.rustup" - ${DRIVERS_TOOLS}/.evergreen/install-rust.sh - source "${CARGO_HOME}/env" - python -m pip install hatch -} -# Ensure hatch does not write to user or global locations. -touch hatch_config.toml -HATCH_CONFIG=$(pwd)/hatch_config.toml -if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin - HATCH_CONFIG=$(cygpath -m "$HATCH_CONFIG") -fi -export HATCH_CONFIG -hatch config restore -hatch config set dirs.data "$(pwd)/.hatch/data" -hatch config set dirs.cache "$(pwd)/.hatch/cache" - -echo "Installing hatch... done." -hatch --version +set -o xtrace +file="$PROJECT_DIRECTORY/.evergreen/install-dependencies.sh" +# Don't use ${file} syntax here because evergreen treats it as an empty expansion. +[ -f "$file" ] && bash "$file" || echo "$file not available, skipping" From d2010cb8a4d3810397b6048a8d949c758f7c41b7 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 13:48:24 -0600 Subject: [PATCH 04/18] fix invocation --- .evergreen/hatch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/hatch.sh b/.evergreen/hatch.sh index 74a708ccc4..c01dfcd19e 100755 --- a/.evergreen/hatch.sh +++ b/.evergreen/hatch.sh @@ -1,5 +1,5 @@ #!/bin/bash set -eu -. .evergreen/ensure-hatch.sh +. .evergreen/scripts/ensure-hatch.sh hatch run "$@" From fdcd12da36ff45add6cf68b54b2e52153944512a Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 16:16:53 -0600 Subject: [PATCH 05/18] fix hatch handling --- .evergreen/scripts/ensure-hatch.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.evergreen/scripts/ensure-hatch.sh b/.evergreen/scripts/ensure-hatch.sh index ddbae46242..c1b6c1c793 100755 --- a/.evergreen/scripts/ensure-hatch.sh +++ b/.evergreen/scripts/ensure-hatch.sh @@ -2,16 +2,19 @@ set -eu -# Install a virtual env with "hatch" -# Ensure there is a python venv. +# Ensure hatch is available. if [ ! -x "$(command -v hatch)" ]; then - . ${DRIVERS_TOOLS}/.evergreen/venv-utils.sh + # Install a virtual env with "hatch" + # Ensure there is a python venv. + . .evergreen/utils.sh + + if [ -z "$PYTHON_BINARY" ]; then + PYTHON_BINARY=$(find_python3) + fi VENV_DIR=.venv if [ ! -d $VENV_DIR ]; then echo "Creating virtual environment..." - . ${DRIVERS_TOOLS}/.evergreen/find-python3.sh - PYTHON_BINARY=$(ensure_python3) - venvcreate $PYTHON_BINARY $VENV_DIR + createvirtualenv "$PYTHON_BINARY" .venv echo "Creating virtual environment... done." fi From e18c2816d99cbe66e2a99a01e0b15aa1ddae0692 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 16:28:31 -0600 Subject: [PATCH 06/18] fix python binary handling --- .evergreen/scripts/ensure-hatch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/scripts/ensure-hatch.sh b/.evergreen/scripts/ensure-hatch.sh index c1b6c1c793..ac989ac321 100755 --- a/.evergreen/scripts/ensure-hatch.sh +++ b/.evergreen/scripts/ensure-hatch.sh @@ -8,7 +8,7 @@ if [ ! -x "$(command -v hatch)" ]; then # Ensure there is a python venv. . .evergreen/utils.sh - if [ -z "$PYTHON_BINARY" ]; then + if [ -z "${PYTHON_BINARY:-}" ]; then PYTHON_BINARY=$(find_python3) fi VENV_DIR=.venv From a7af0ced94ad457cf1af590255d066f2775d552b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 16:40:43 -0600 Subject: [PATCH 07/18] fix activation --- .evergreen/scripts/ensure-hatch.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.evergreen/scripts/ensure-hatch.sh b/.evergreen/scripts/ensure-hatch.sh index ac989ac321..830506567c 100755 --- a/.evergreen/scripts/ensure-hatch.sh +++ b/.evergreen/scripts/ensure-hatch.sh @@ -16,6 +16,10 @@ if [ ! -x "$(command -v hatch)" ]; then echo "Creating virtual environment..." createvirtualenv "$PYTHON_BINARY" .venv echo "Creating virtual environment... done." + elif [ -f . $VENV_DIR/Scripts/activate ]; then + . $VENV_DIR/Scripts/activate + else + . $VENV_DIR/bin/activate fi venvactivate $VENV_DIR From d6761b02bd88b777df968b46cfd6c4ba44f3b702 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 16:51:17 -0600 Subject: [PATCH 08/18] fix activation --- .evergreen/scripts/ensure-hatch.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.evergreen/scripts/ensure-hatch.sh b/.evergreen/scripts/ensure-hatch.sh index 830506567c..6a59b0cdb2 100755 --- a/.evergreen/scripts/ensure-hatch.sh +++ b/.evergreen/scripts/ensure-hatch.sh @@ -22,7 +22,6 @@ if [ ! -x "$(command -v hatch)" ]; then . $VENV_DIR/bin/activate fi - venvactivate $VENV_DIR python --version echo "Installing hatch..." From 0de391ca5c5f7b9b717f273a8a22f94323e023a8 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 19:26:41 -0600 Subject: [PATCH 09/18] fix activation --- .evergreen/scripts/ensure-hatch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/scripts/ensure-hatch.sh b/.evergreen/scripts/ensure-hatch.sh index 6a59b0cdb2..c6470cdc8d 100755 --- a/.evergreen/scripts/ensure-hatch.sh +++ b/.evergreen/scripts/ensure-hatch.sh @@ -16,7 +16,7 @@ if [ ! -x "$(command -v hatch)" ]; then echo "Creating virtual environment..." createvirtualenv "$PYTHON_BINARY" .venv echo "Creating virtual environment... done." - elif [ -f . $VENV_DIR/Scripts/activate ]; then + elif [ -f $VENV_DIR/Scripts/activate ]; then . $VENV_DIR/Scripts/activate else . $VENV_DIR/bin/activate From c3a53b478fbb8f3ed17277a5a6c285ac43b64503 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 19:38:17 -0600 Subject: [PATCH 10/18] fix activation --- .evergreen/run-mongodb-aws-ecs-test.sh | 1 - .evergreen/scripts/ensure-hatch.sh | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index 3905a08764..1c0e6d5d4b 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -30,5 +30,4 @@ export TEST_AUTH_AWS=1 export AUTH="auth" export SET_XTRACE_ON=1 cd src -$PYTHON_BINARY -m pip install -q --user hatch bash .evergreen/hatch.sh test:test-eg diff --git a/.evergreen/scripts/ensure-hatch.sh b/.evergreen/scripts/ensure-hatch.sh index c6470cdc8d..a57b705127 100755 --- a/.evergreen/scripts/ensure-hatch.sh +++ b/.evergreen/scripts/ensure-hatch.sh @@ -16,7 +16,8 @@ if [ ! -x "$(command -v hatch)" ]; then echo "Creating virtual environment..." createvirtualenv "$PYTHON_BINARY" .venv echo "Creating virtual environment... done." - elif [ -f $VENV_DIR/Scripts/activate ]; then + fi + if [ -f $VENV_DIR/Scripts/activate ]; then . $VENV_DIR/Scripts/activate else . $VENV_DIR/bin/activate From 383b2de8b96bdc1b5776c0697efc4a0c3170f444 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 2 Dec 2024 19:55:42 -0600 Subject: [PATCH 11/18] try an aws fix --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a75d84430b..e4587125e8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ libmongocrypt.tar.gz libmongocrypt/ libmongocrypt_git/ hatch_config.toml +.venv # Lambda temp files test/lambda/.aws-sam From e940205699662b195999ab7e1fa5015c4bdb2614 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Dec 2024 07:34:19 -0600 Subject: [PATCH 12/18] try an aws fix --- .evergreen/run-mongodb-aws-ecs-test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index 1c0e6d5d4b..aae32709c8 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -30,4 +30,5 @@ export TEST_AUTH_AWS=1 export AUTH="auth" export SET_XTRACE_ON=1 cd src +rm -rf .venv bash .evergreen/hatch.sh test:test-eg From e28c1ef1d8eba1367b01ad88f5e18254de9fe221 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Dec 2024 07:48:38 -0600 Subject: [PATCH 13/18] fix aws auth --- .evergreen/run-mongodb-aws-ecs-test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index aae32709c8..ed38bf6f0d 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -22,8 +22,8 @@ set -o xtrace # Install python with pip. PYTHON_VER="python3.9" -apt-get update -apt-get install $PYTHON_VER python3-pip build-essential $PYTHON_VER-dev -y +apt-get -qq update +apt-get --qq install $PYTHON_VER python3-pip python3-venv build-essential $PYTHON_VER-dev -y export PYTHON_BINARY=$PYTHON_VER export TEST_AUTH_AWS=1 From 51158baba403bbc37e857885fe3a54330432b72f Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Dec 2024 08:03:18 -0600 Subject: [PATCH 14/18] fix aws auth --- .evergreen/run-mongodb-aws-ecs-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index ed38bf6f0d..a0bad27305 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -23,7 +23,7 @@ set -o xtrace # Install python with pip. PYTHON_VER="python3.9" apt-get -qq update -apt-get --qq install $PYTHON_VER python3-pip python3-venv build-essential $PYTHON_VER-dev -y +apt-get -qq install $PYTHON_VER python3-pip python3-venv build-essential $PYTHON_VER-dev -y export PYTHON_BINARY=$PYTHON_VER export TEST_AUTH_AWS=1 From b906e9c9fdcf697e5ebb542018f3277070ddd071 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Dec 2024 08:19:17 -0600 Subject: [PATCH 15/18] fix aws auth --- .evergreen/run-mongodb-aws-ecs-test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index a0bad27305..498915f3b5 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -22,8 +22,8 @@ set -o xtrace # Install python with pip. PYTHON_VER="python3.9" -apt-get -qq update -apt-get -qq install $PYTHON_VER python3-pip python3-venv build-essential $PYTHON_VER-dev -y +apt-get -qq update < /dev/null > /dev/null +apt-get -qq install $PYTHON_VER $PYTHON_VER-pip $PYTHON_VER-venv build-essential $PYTHON_VER-dev -y < /dev/null > /dev/null export PYTHON_BINARY=$PYTHON_VER export TEST_AUTH_AWS=1 From 766cf800f09b1351c7995c83448fc2d57b4cb21d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Dec 2024 09:39:23 -0600 Subject: [PATCH 16/18] fix aws auth --- .evergreen/run-mongodb-aws-ecs-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index 498915f3b5..3189a6cc6c 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -23,7 +23,7 @@ set -o xtrace # Install python with pip. PYTHON_VER="python3.9" apt-get -qq update < /dev/null > /dev/null -apt-get -qq install $PYTHON_VER $PYTHON_VER-pip $PYTHON_VER-venv build-essential $PYTHON_VER-dev -y < /dev/null > /dev/null +apt-get -qq install $PYTHON_VER $PYTHON_VER-venv build-essential $PYTHON_VER-dev -y < /dev/null > /dev/null export PYTHON_BINARY=$PYTHON_VER export TEST_AUTH_AWS=1 From d618bdcb6a62e8a89475c159f7fb79dec1199f17 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Dec 2024 10:30:05 -0600 Subject: [PATCH 17/18] ensure hatch at startup --- .evergreen/install-dependencies.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index 9f4bcdbb59..4c0541a4e2 100755 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -8,6 +8,9 @@ cp ${PROJECT_DIRECTORY}/test/certificates/* ${DRIVERS_TOOLS}/.evergreen/x509gen/ # Replace MongoOrchestration's client certificate. cp ${PROJECT_DIRECTORY}/test/certificates/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem +# Ensure hatch is installed. +bash ${PROJECT_DIRECTORY}/scripts/ensure-hatch.sh + if [ -w /etc/hosts ]; then SUDO="" else From 9add9376e80ee5aea2e6d07fcaabdf14f5fe1b92 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Dec 2024 11:24:26 -0600 Subject: [PATCH 18/18] fix hatch handling --- .evergreen/scripts/configure-env.sh | 3 +++ .evergreen/scripts/run-enterprise-auth-tests.sh | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.evergreen/scripts/configure-env.sh b/.evergreen/scripts/configure-env.sh index 94fa11ce97..313f4c3c92 100755 --- a/.evergreen/scripts/configure-env.sh +++ b/.evergreen/scripts/configure-env.sh @@ -11,11 +11,13 @@ fi PROJECT_DIRECTORY="$(pwd)" DRIVERS_TOOLS="$(dirname $PROJECT_DIRECTORY)/drivers-tools" +CARGO_HOME=${CARGO_HOME:-${DRIVERS_TOOLS}/.cargo} # Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS) PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY) + CARGO_HOME=$(cygpath -m $CARGO_HOME) fi SCRIPT_DIR="$PROJECT_DIRECTORY/.evergreen/scripts" @@ -53,6 +55,7 @@ export REQUIRE_API_VERSION="${REQUIRE_API_VERSION:-}" export skip_web_identity_auth_test="${skip_web_identity_auth_test:-}" export skip_ECS_auth_test="${skip_ECS_auth_test:-}" +export CARGO_HOME="$CARGO_HOME" export TMPDIR="$MONGO_ORCHESTRATION_HOME/db" export PATH="$MONGODB_BINARIES:$PATH" # shellcheck disable=SC2154 diff --git a/.evergreen/scripts/run-enterprise-auth-tests.sh b/.evergreen/scripts/run-enterprise-auth-tests.sh index 31371ead45..11f8db22e1 100755 --- a/.evergreen/scripts/run-enterprise-auth-tests.sh +++ b/.evergreen/scripts/run-enterprise-auth-tests.sh @@ -2,5 +2,6 @@ # Disable xtrace for security reasons (just in case it was accidentally set). set +x -bash "${DRIVERS_TOOLS}"/.evergreen/auth_aws/setup_secrets.sh drivers/enterprise_auth +# Use the default python to bootstrap secrets. +PYTHON_BINARY="" bash "${DRIVERS_TOOLS}"/.evergreen/auth_aws/setup_secrets.sh drivers/enterprise_auth TEST_ENTERPRISE_AUTH=1 AUTH=auth bash "${PROJECT_DIRECTORY}"/.evergreen/hatch.sh test:test-eg