Skip to content

Commit 98f0918

Browse files
aclark4lifetimgraham
authored andcommitted
INTPYTHON-677 Add Queryable Encryption evergreen builds
1 parent 73e506d commit 98f0918

File tree

5 files changed

+112
-3
lines changed

5 files changed

+112
-3
lines changed

.evergreen/config.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,46 @@ functions:
5555
args:
5656
- ${DRIVERS_TOOLS}/.evergreen/teardown.sh
5757

58+
# Encryption-specific functions
59+
"start csfle servers":
60+
- command: ec2.assume_role
61+
params:
62+
role_arn: ${aws_test_secrets_role}
63+
- command: subprocess.exec
64+
params:
65+
binary: bash
66+
include_expansions_in_env: [
67+
"AWS_SECRET_ACCESS_KEY",
68+
"AWS_ACCESS_KEY_ID",
69+
"AWS_SESSION_TOKEN",
70+
]
71+
args:
72+
- ${DRIVERS_TOOLS}/.evergreen/csfle/setup.sh
73+
74+
"teardown csfle":
75+
- command: subprocess.exec
76+
params:
77+
binary: bash
78+
args:
79+
- ${DRIVERS_TOOLS}/.evergreen/csfle/teardown.sh
80+
81+
"run encryption tests":
82+
- command: subprocess.exec
83+
type: test
84+
params:
85+
binary: bash
86+
working_dir: "src"
87+
include_expansions_in_env: [
88+
"AWS_KMS_ARN",
89+
"DRIVERS_TOOLS",
90+
"MONGODB_URI",
91+
"DJANGO_SETTINGS_MODULE",
92+
"CRYPT_SHARED_LIB_PATH",
93+
]
94+
args:
95+
- ./.evergreen/run-tests.sh
96+
- encryption
97+
5898
pre:
5999
- func: setup
60100
- func: bootstrap mongo-orchestration
@@ -67,6 +107,12 @@ tasks:
67107
commands:
68108
- func: "run unit tests"
69109

110+
- name: run-encryption-tests
111+
commands:
112+
- func: "start csfle servers"
113+
- func: "run encryption tests"
114+
- func: "teardown csfle"
115+
70116
buildvariants:
71117
- name: tests-7-noauth-nossl
72118
display_name: Run Tests 7.0 NoAuth NoSSL
@@ -111,3 +157,23 @@ buildvariants:
111157
SSL: "ssl"
112158
tasks:
113159
- name: run-tests
160+
161+
- name: tests-8-qe-local
162+
display_name: Run Tests 8.2 QE local KMS
163+
run_on: rhel87-small
164+
expansions:
165+
MONGODB_VERSION: "8.2"
166+
TOPOLOGY: replica_set
167+
DJANGO_SETTINGS_MODULE: "encrypted_settings"
168+
tasks:
169+
- name: run-encryption-tests
170+
171+
- name: tests-8-qe-aws
172+
display_name: Run Tests 8.2 QE AWS KMS
173+
run_on: rhel87-small
174+
expansions:
175+
MONGODB_VERSION: "8.2"
176+
TOPOLOGY: replica_set
177+
DJANGO_SETTINGS_MODULE: "encrypted_aws_settings"
178+
tasks:
179+
- name: run-encryption-tests

.evergreen/run-tests.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,24 @@
22

33
set -eux
44

5-
# Install django-mongodb-backend
5+
# Export secrets as environment variables
6+
# https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/csfle/README.md#usage
7+
if [[ "${1:-}" == "encryption" ]]; then
8+
. ../secrets-export.sh
9+
fi
10+
11+
# Set up virtual environment
612
/opt/python/3.12/bin/python3 -m venv venv
713
. venv/bin/activate
814
python -m pip install -U pip
9-
pip install -e .
15+
16+
# Install django-mongodb-backend
17+
if [[ "${1:-}" == "encryption" ]]; then
18+
# Install encryption dependencies for the Queryable Encryption build
19+
pip install -e '.[encryption]'
20+
else
21+
pip install -e .
22+
fi
1023

1124
# Install django and test dependencies
1225
git clone --branch mongodb-6.0.x https://github.com/mongodb-forks/django django_repo
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Settings for django_mongodb_backend/tests with AWS Key Management System.
2+
import os
3+
4+
from encrypted_settings import * # noqa: F403
5+
from pymongo.encryption import AutoEncryptionOpts
6+
7+
DATABASES["encrypted"] = { # noqa: F405
8+
"ENGINE": "django_mongodb_backend",
9+
"NAME": "djangotests_encrypted",
10+
"OPTIONS": {
11+
"auto_encryption_opts": AutoEncryptionOpts(
12+
key_vault_namespace="djangotests_encrypted.__keyVault",
13+
kms_providers={
14+
"aws": {
15+
"accessKeyId": os.environ["AWS_ACCESS_KEY_ID"],
16+
"secretAccessKey": os.environ["AWS_SECRET_ACCESS_KEY"],
17+
}
18+
},
19+
crypt_shared_lib_path=os.environ["CRYPT_SHARED_LIB_PATH"],
20+
crypt_shared_lib_required=True,
21+
),
22+
},
23+
"KMS_CREDENTIALS": {
24+
"aws": {
25+
"key": os.environ["AWS_KMS_ARN"],
26+
"region": os.environ["AWS_DEFAULT_REGION"],
27+
}
28+
},
29+
}

.github/workflows/encrypted_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"auto_encryption_opts": AutoEncryptionOpts(
1212
key_vault_namespace="djangotests_encrypted.__keyVault",
1313
kms_providers={"local": {"key": os.urandom(96)}},
14-
crypt_shared_lib_path=os.environ["GITHUB_WORKSPACE"] + "/lib/mongo_crypt_v1.so",
14+
crypt_shared_lib_path=os.environ["CRYPT_SHARED_LIB_PATH"],
1515
crypt_shared_lib_required=True,
1616
),
1717
"directConnection": True,

.github/workflows/test-python-encryption.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ jobs:
6161
permissions:
6262
contents: read
6363
env:
64+
CRYPT_SHARED_LIB_PATH: "${{ github.workspace }}/lib/mongo_crypt_v1.so"
6465
DJANGO_SETTINGS_MODULE: "encrypted_settings"

0 commit comments

Comments
 (0)