From b9af21c86f15aa6f653436c2dcdd8699f84b408a Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 06:06:28 -0600 Subject: [PATCH 01/10] INTPYTHON-407 Add evergreen configuration for django-mongodb --- .evergreen/config.yml | 73 +++++++++++++++++++++++++++++++++++++++++ .evergreen/run-tests.sh | 24 ++++++++++++++ .evergreen/setup.sh | 48 +++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 .evergreen/config.yml create mode 100644 .evergreen/run-tests.sh create mode 100644 .evergreen/setup.sh diff --git a/.evergreen/config.yml b/.evergreen/config.yml new file mode 100644 index 000000000..ccdf30805 --- /dev/null +++ b/.evergreen/config.yml @@ -0,0 +1,73 @@ +exec_timeout_secs: 3600 + +# Mark a failure as a system/bootstrap failure (purple box) rather then a task +# failure by default. +# Actual testing tasks are marked with `type: test` +command_type: system + +functions: + "setup": + - command: git.get_project + params: + directory: src + - command: subprocess.exec + params: + binary: bash + working_dir: "src" + add_expansions_to_env: true + args: + - ./.evergreen/setup.sh + - command: expansions.update + params: + file: src/expansion.yml + + "bootstrap mongo-orchestration": + - command: subprocess.exec + params: + binary: bash + env: + MONGODB_VERSION: 5.0 + TOPOLOGY: server + AUTH: "auth" + SSL: "ssl" + args: + - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh + + "run unit tests": + - command: subprocess.exec + type: test + params: + binary: bash + working_dir: "src" + include_expansions_in_env: ["DRIVERS_TOOLS"] + args: + - ./.evergreen/run-tests.sh + + "teardown": + - command: subprocess.exec + params: + binary: bash + args: + - ${DRIVERS_TOOLS}/.evergreen/teardown.sh + +pre: + - func: setup + - func: bootstrap mongo-orchestration + +post: + - func: teardown + - command: attach.xunit_results + params: + file: "mongo-python-driver/xunit-results/TEST-*.xml" + +tasks: +- name: run-tests + commands: + - func: "run unit tests" + +buildvariants: +- name: tests + display_name: Run Tests + run_on: rhel87-small + tasks: + - name: run-tests diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh new file mode 100644 index 000000000..046a45e1b --- /dev/null +++ b/.evergreen/run-tests.sh @@ -0,0 +1,24 @@ +#!/usr/bin/bash + +set -eux + +# Install the django-mongodb backend +/opt/mongodbtoolchain/v4/bin/python3 -m venv venv +. venv/bin/activate +python -m pip install -U pip +pip install -e . + +# Install django and test dependencies +git clone --branch mongodb-5.0.x https://github.com/mongodb-forks/django django_repo +cd django_repo/tests/ +pip install -e .. +pip install -r requirements/py3.txt + +# Copy the test settings file +cp .github/workflows/mongodb_settings.py django_repo/tests/ + +# Copy the test runner file +cp .github/workflows/runtests.py django_repo/tests/runtests_.py + +# Run tests +python django_repo/tests/runtests_.py diff --git a/.evergreen/setup.sh b/.evergreen/setup.sh new file mode 100644 index 000000000..638bd57d8 --- /dev/null +++ b/.evergreen/setup.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash + +set -eux + +# Get the current unique version of this checkout +# shellcheck disable=SC2154 +if [ "${is_patch}" = "true" ]; then + # shellcheck disable=SC2154 + CURRENT_VERSION=$(git describe)-patch-${version_id} +else + CURRENT_VERSION=latest +fi + +# Python has cygwin path problems on Windows. +DRIVERS_TOOLS="$(dirname "$(pwd)")/drivers-tools" +PROJECT_DIRECTORY="$(pwd)" + +if [ "Windows_NT" = "${OS:-}" ]; then + DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS) + PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY) +fi +export PROJECT_DIRECTORY +export DRIVERS_TOOLS + +export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" +export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" +# shellcheck disable=SC2154 +export UPLOAD_BUCKET="${project}" + +cat < expansion.yml +CURRENT_VERSION: "$CURRENT_VERSION" +DRIVERS_TOOLS: "$DRIVERS_TOOLS" +MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME" +MONGODB_BINARIES: "$MONGODB_BINARIES" +UPLOAD_BUCKET: "$UPLOAD_BUCKET" +PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" +EOT + +# Set up drivers-tools with a .env file. +git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git ${DRIVERS_TOOLS} +cat < ${DRIVERS_TOOLS}/.env +CURRENT_VERSION="$CURRENT_VERSION" +DRIVERS_TOOLS="$DRIVERS_TOOLS" +MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" +MONGODB_BINARIES="$MONGODB_BINARIES" +UPLOAD_BUCKET="$UPLOAD_BUCKET" +PROJECT_DIRECTORY="$PROJECT_DIRECTORY" +EOT From 4f3a6d8ff7d9677321df9068a068821996fafd5e Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 06:12:31 -0600 Subject: [PATCH 02/10] fix config --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index ccdf30805..a5faf4906 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -26,7 +26,7 @@ functions: params: binary: bash env: - MONGODB_VERSION: 5.0 + MONGODB_VERSION: "5.0" TOPOLOGY: server AUTH: "auth" SSL: "ssl" From 6b4a072be56c0845eea28c5c137f3eb3d87f6142 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 06:22:25 -0600 Subject: [PATCH 03/10] fix dir handling --- .evergreen/run-tests.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 046a45e1b..4a9896891 100644 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -10,15 +10,16 @@ pip install -e . # Install django and test dependencies git clone --branch mongodb-5.0.x https://github.com/mongodb-forks/django django_repo -cd django_repo/tests/ +pushd django_repo/tests/ pip install -e .. pip install -r requirements/py3.txt +popd # Copy the test settings file -cp .github/workflows/mongodb_settings.py django_repo/tests/ +cp ./.github/workflows/mongodb_settings.py django_repo/tests/ # Copy the test runner file -cp .github/workflows/runtests.py django_repo/tests/runtests_.py +cp ./.github/workflows/runtests.py django_repo/tests/runtests_.py # Run tests python django_repo/tests/runtests_.py From c3614089f7347bb854e1b61b28f3a34ea5902691 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 06:34:10 -0600 Subject: [PATCH 04/10] fix setup --- .evergreen/config.yml | 6 ++++++ .evergreen/setup.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index a5faf4906..bf0d2bda3 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -5,6 +5,12 @@ exec_timeout_secs: 3600 # Actual testing tasks are marked with `type: test` command_type: system +# Ensure that setup and teardown is working as expected. +pre_error_fails_task: true +pre_timeout_secs: 1800 # 5 minutes +post_error_fails_task: true +post_timeout_secs: 1800 # 5 minutes + functions: "setup": - command: git.get_project diff --git a/.evergreen/setup.sh b/.evergreen/setup.sh index 638bd57d8..4709ed9bd 100644 --- a/.evergreen/setup.sh +++ b/.evergreen/setup.sh @@ -6,7 +6,7 @@ set -eux # shellcheck disable=SC2154 if [ "${is_patch}" = "true" ]; then # shellcheck disable=SC2154 - CURRENT_VERSION=$(git describe)-patch-${version_id} + CURRENT_VERSION=$(git describe || echo "null")-patch-${version_id} else CURRENT_VERSION=latest fi From 6ea2aa9da5988c9af9e24316ce563aa65d1bc200 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 06:41:37 -0600 Subject: [PATCH 05/10] remove auth ssl --- .evergreen/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index bf0d2bda3..5be7c5d19 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -34,8 +34,8 @@ functions: env: MONGODB_VERSION: "5.0" TOPOLOGY: server - AUTH: "auth" - SSL: "ssl" + AUTH: "noauth" + SSL: "nossl" args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh From e67cee0a83044cde9041bc858b3b3cbd28dcbae0 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 06:51:19 -0600 Subject: [PATCH 06/10] add sbom file --- sbom.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 sbom.json diff --git a/sbom.json b/sbom.json new file mode 100644 index 000000000..dc6714671 --- /dev/null +++ b/sbom.json @@ -0,0 +1,12 @@ +{ + "metadata": { + "timestamp": "2024-11-05T12:48:05.688090+00:00" + }, + "components": [], + "serialNumber": "urn:uuid:f3728d07-e448-4fae-8e28-c08f8c75f747", + "version": 1, + "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.5", + "vulnerabilities": [] +} From e1b37cabbfe7a02bda2003db1c2403f050e3eedf Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 06:55:41 -0600 Subject: [PATCH 07/10] no xml results --- .evergreen/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 5be7c5d19..6490b069f 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -62,9 +62,6 @@ pre: post: - func: teardown - - command: attach.xunit_results - params: - file: "mongo-python-driver/xunit-results/TEST-*.xml" tasks: - name: run-tests From c4f771d399378922d94f68b47325be8e89029489 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 07:25:13 -0600 Subject: [PATCH 08/10] try with ssl --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 6490b069f..aa10a265e 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -35,7 +35,7 @@ functions: MONGODB_VERSION: "5.0" TOPOLOGY: server AUTH: "noauth" - SSL: "nossl" + SSL: "ssl" args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh From 0320384048e28d49a2196cf407089c5c4cec8d19 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 07:35:49 -0600 Subject: [PATCH 09/10] Revert "try with ssl" This reverts commit c4f771d399378922d94f68b47325be8e89029489. --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index aa10a265e..6490b069f 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -35,7 +35,7 @@ functions: MONGODB_VERSION: "5.0" TOPOLOGY: server AUTH: "noauth" - SSL: "ssl" + SSL: "nossl" args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh From c30381ed337a8467abd735550a12bd42cd003e04 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 5 Nov 2024 09:05:31 -0600 Subject: [PATCH 10/10] address review --- .evergreen/run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 4a9896891..88ec602c5 100644 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -3,7 +3,7 @@ set -eux # Install the django-mongodb backend -/opt/mongodbtoolchain/v4/bin/python3 -m venv venv +/opt/python/3.10/bin/python3 -m venv venv . venv/bin/activate python -m pip install -U pip pip install -e .