Skip to content

Commit

Permalink
PYTHON-4496 Add integration test (#92)
Browse files Browse the repository at this point in the history
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
Co-authored-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
  • Loading branch information
blink1073 and mongodb-dbx-release-bot[bot] authored Jun 13, 2024
1 parent d1c2560 commit 7963281
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .evergreen/assign-pr-reviewer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -x
export CONFIG=$PROJECT_DIRECTORY/.github/reviewers.txt
export SCRIPT="$DRIVERS_TOOLS/.evergreen/github_app/assign-reviewer.sh"
# shellcheck disable=SC2154
bash $SCRIPT -p $CONFIG -h ${github_commit} -o "mongodb" -n "winkerberos"
echo '{"results": [{ "status": "PASS", "test_file": "Build", "log_raw": "Test completed" } ]}' > ${PROJECT_DIRECTORY}/test-results.json
93 changes: 93 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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: latest
TOPOLOGY: server
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

"assign pr reviewer":
- command: subprocess.exec
type: test
params:
binary: bash
add_expansions_to_env: true
working_dir: "src"
args:
- ./.evergreen/assign-pr-reviewer.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"

- name: assign-pr-reviewer
tags: ["pr"]
allowed_requesters: ["patch", "github_pr"]
commands:
- func: "assign pr reviewer"

buildvariants:
- name: tests
display_name: Run Tests
run_on: windows-64-vsMulti-small
tasks:
- name: run-tests

- name: rhel8-pr-assign-reviewer
display_name: Assign PR Reviewer
run_on: rhel87-small
tasks:
- name: "assign-pr-reviewer"
24 changes: 24 additions & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/bash
# Disable xtrace for security reasons (just in case it was accidentally set).
set +x
set -eu

# Fetch secrets
bash ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/enterprise_auth
source secrets-export.sh

# Set up env
pushd ..
git clone https://github.com/mongodb/mongo-python-driver

set -x
"C:/python/Python38/python.exe" -m venv .venv
dos2unix -q .venv/Scripts/activate
. .venv/Scripts/activate
pip install "./mongo-python-driver[test]"
pip install -e ./src

pushd ./mongo-python-driver
TEST_ENTERPRISE_AUTH=1 bash ./.evergreen/run-tests.sh
popd
popd
48 changes: 48 additions & 0 deletions .evergreen/setup.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOT > 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 <<EOT > ${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
5 changes: 5 additions & 0 deletions .github/reviewers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# List of reviewers for auto-assignment of reviews.
caseyclements
blink1073
Jibola
NoahStapp
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ winkerberos.egg-info/
envfile
.venv
signatures
secrets-export.sh
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ recursive-include src *.h
recursive-include test *.py
exclude .pre-commit-config.yaml
prune scripts
prune .evergreen

0 comments on commit 7963281

Please sign in to comment.