Skip to content

Commit 6c768e8

Browse files
aclark4lifetimgraham
authored andcommitted
Add Queryable Encryption builds on evergreen
1 parent 8307e4a commit 6c768e8

File tree

5 files changed

+93
-3
lines changed

5 files changed

+93
-3
lines changed

.evergreen/config.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ post_error_fails_task: true
1212
post_timeout_secs: 1800 # 5 minutes
1313

1414
functions:
15+
"start csfle servers":
16+
- command: ec2.assume_role
17+
params:
18+
role_arn: ${aws_test_secrets_role}
19+
- command: subprocess.exec
20+
params:
21+
binary: bash
22+
include_expansions_in_env: ["AWS_SECRET_ACCESS_KEY", "AWS_ACCESS_KEY_ID", "AWS_SESSION_TOKEN"]
23+
args:
24+
- ${DRIVERS_TOOLS}/.evergreen/csfle/setup.sh
25+
1526
"setup":
1627
- command: git.get_project
1728
params:
@@ -48,15 +59,28 @@ functions:
4859
args:
4960
- ./.evergreen/run-tests.sh
5061

62+
"run encryption tests":
63+
- command: subprocess.exec
64+
type: test
65+
params:
66+
binary: bash
67+
working_dir: "src"
68+
include_expansions_in_env: ["DRIVERS_TOOLS", "MONGODB_URI", "DJANGO_SETTINGS_MODULE", "CRYPT_SHARED_LIB_PATH"]
69+
args:
70+
- ./.evergreen/run-tests.sh
71+
- encryption
72+
5173
"teardown":
5274
- command: subprocess.exec
5375
params:
5476
binary: bash
5577
args:
5678
- ${DRIVERS_TOOLS}/.evergreen/teardown.sh
79+
- ${DRIVERS_TOOLS}/.evergreen/csfle/teardown.sh
5780

5881
pre:
5982
- func: setup
83+
- func: start csfle servers
6084
- func: bootstrap mongo-orchestration
6185

6286
post:
@@ -67,6 +91,10 @@ tasks:
6791
commands:
6892
- func: "run unit tests"
6993

94+
- name: run-encryption-tests
95+
commands:
96+
- func: "run encryption tests"
97+
7098
buildvariants:
7199
- name: tests-7-noauth-nossl
72100
display_name: Run Tests 7.0 NoAuth NoSSL
@@ -111,3 +139,23 @@ buildvariants:
111139
SSL: "ssl"
112140
tasks:
113141
- name: run-tests
142+
143+
- name: tests-8-qe-local
144+
display_name: Run Tests 8.2 QE local KMS
145+
run_on: rhel87-small
146+
expansions:
147+
MONGODB_VERSION: "8.2"
148+
TOPOLOGY: replica_set
149+
DJANGO_SETTINGS_MODULE: "encrypted_settings"
150+
tasks:
151+
- name: run-encryption-tests
152+
153+
- name: tests-8-qe-aws
154+
display_name: Run Tests 8.2 QE AWS KMS
155+
run_on: rhel87-small
156+
expansions:
157+
MONGODB_VERSION: "8.2"
158+
TOPOLOGY: replica_set
159+
DJANGO_SETTINGS_MODULE: "encrypted_aws_settings"
160+
tasks:
161+
- 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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
from encrypted_settings import * # noqa: F403
4+
from pymongo.encryption import AutoEncryptionOpts
5+
6+
DATABASES["encrypted"] = { # noqa: F405
7+
"ENGINE": "django_mongodb_backend",
8+
"NAME": "djangotests_encrypted",
9+
"OPTIONS": {
10+
"auto_encryption_opts": AutoEncryptionOpts(
11+
key_vault_namespace="djangotests_encrypted.__keyVault",
12+
kms_providers={
13+
"aws": {
14+
"accessKeyId": os.environ["AWS_ACCESS_KEY_ID"],
15+
"secretAccessKey": os.environ["AWS_SECRET_ACCESS_KEY"],
16+
}
17+
},
18+
crypt_shared_lib_path=os.environ["CRYPT_SHARED_LIB_PATH"],
19+
crypt_shared_lib_required=True,
20+
),
21+
},
22+
"KMS_CREDENTIALS": {
23+
"aws": {
24+
"key": "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0",
25+
"region": os.environ["AWS_DEFAULT_REGION"],
26+
}
27+
},
28+
}

.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
),
1616
"directConnection": True,
1717
},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ jobs:
6262
contents: read
6363
env:
6464
DJANGO_SETTINGS_MODULE: "encrypted_settings"
65+
CRYPT_SHARED_LIB_PATH: "${{ github.workspace }}/lib/mongo_crypt_v1.so"

0 commit comments

Comments
 (0)