Skip to content

Commit 1d218d2

Browse files
authored
Run CSFLE unified and legacy tests with mongocryptd (#1085)
JAVA-4763
1 parent a748926 commit 1d218d2

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

.evergreen/.evg.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,29 @@ functions:
755755
MONGODB_URI="${MONGODB_URI}" AWS_ACCESS_KEY_ID=${aws_access_key_id} AWS_SECRET_ACCESS_KEY=${aws_secret_access_key} \
756756
.evergreen/run-csfle-aws-from-environment.sh
757757
758+
"run csfle tests with mongocryptd":
759+
- command: shell.exec
760+
type: test
761+
params:
762+
working_dir: "src"
763+
script: |
764+
${PREPARE_SHELL}
765+
export AWS_ACCESS_KEY_ID=${aws_access_key_id}
766+
export AWS_SECRET_ACCESS_KEY=${aws_secret_access_key}
767+
export AWS_DEFAULT_REGION=us-east-1
768+
. ${DRIVERS_TOOLS}/.evergreen/csfle/set-temp-creds.sh
769+
MONGODB_URI="${MONGODB_URI}" \
770+
JAVA_VERSION="${JAVA_VERSION}" \
771+
AWS_ACCESS_KEY_ID=${aws_access_key_id} AWS_SECRET_ACCESS_KEY=${aws_secret_access_key} \
772+
AWS_TEMP_ACCESS_KEY_ID=$CSFLE_AWS_TEMP_ACCESS_KEY_ID \
773+
AWS_TEMP_SECRET_ACCESS_KEY=$CSFLE_AWS_TEMP_SECRET_ACCESS_KEY \
774+
AWS_TEMP_SESSION_TOKEN=$CSFLE_AWS_TEMP_SESSION_TOKEN \
775+
AZURE_TENANT_ID=${azure_tenant_id} AZURE_CLIENT_ID=${azure_client_id} AZURE_CLIENT_SECRET=${azure_client_secret} \
776+
GCP_EMAIL=${gcp_email} GCP_PRIVATE_KEY=${gcp_private_key} \
777+
AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} \
778+
AZUREKMS_KEY_NAME=${testazurekms_keyname} \
779+
.evergreen/run-csfle-tests-with-mongocryptd.sh
780+
758781
"publish snapshot":
759782
- command: shell.exec
760783
type: test
@@ -1482,6 +1505,12 @@ tasks:
14821505
SSL: "nossl"
14831506
- func: run-csfle-aws-from-environment-test
14841507

1508+
- name: "csfle-tests-with-mongocryptd"
1509+
commands:
1510+
- func: "start-kms-kmip-server"
1511+
- func: "bootstrap mongo-orchestration"
1512+
- func: "run csfle tests with mongocryptd"
1513+
14851514
- name: "testgcpkms-task"
14861515
commands:
14871516
- command: shell.exec
@@ -2053,6 +2082,12 @@ buildvariants:
20532082
tasks:
20542083
- name: ".csfle-aws-from-environment"
20552084

2085+
- matrix_name: "csfle-tests-with-mongocryptd"
2086+
matrix_spec: { os: "linux", version: [ "4.2", "4.4", "5.0", "6.0", "latest" ], topology: ["replicaset"] }
2087+
display_name: "CSFLE with mongocryptd: ${version}"
2088+
tasks:
2089+
- name: "csfle-tests-with-mongocryptd"
2090+
20562091
- name: testgcpkms-variant
20572092
display_name: "GCP KMS"
20582093
run_on:
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
set -o xtrace # Write all commands first to stderr
4+
set -o errexit # Exit the script with error if any of the commands fail
5+
6+
# Supported/used environment variables:
7+
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
8+
# JAVA_VERSION Set the version of java to be used. Java versions can be set from the java toolchain /opt/java
9+
# AWS_ACCESS_KEY_ID The AWS access key identifier for client-side encryption
10+
# AWS_SECRET_ACCESS_KEY The AWS secret access key for client-side encryption
11+
# AWS_TEMP_ACCESS_KEY_ID The temporary AWS access key identifier for client-side encryption
12+
# AWS_TEMP_SECRET_ACCESS_KEY The temporary AWS secret access key for client-side encryption
13+
# AWS_TEMP_SESSION_TOKEN The temporary AWS session token for client-side encryption
14+
# AZURE_TENANT_ID The Azure tenant identifier for client-side encryption
15+
# AZURE_CLIENT_ID The Azure client identifier for client-side encryption
16+
# AZURE_CLIENT_SECRET The Azure client secret for client-side encryption
17+
# GCP_EMAIL The GCP email for client-side encryption
18+
# GCP_PRIVATE_KEY The GCP private key for client-side encryption
19+
# AZUREKMS_KEY_VAULT_ENDPOINT The Azure key vault endpoint for integration tests
20+
# AZUREKMS_KEY_NAME The Azure key name endpoint for integration tests
21+
22+
MONGODB_URI=${MONGODB_URI:-}
23+
24+
RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")"
25+
. "${RELATIVE_DIR_PATH}/javaConfig.bash"
26+
27+
############################################
28+
# Functions #
29+
############################################
30+
31+
provision_ssl () {
32+
# We generate the keystore and truststore on every run with the certs in the drivers-tools repo
33+
if [ ! -f client.pkc ]; then
34+
openssl pkcs12 -CAfile ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -export -in ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem -out client.pkc -password pass:bithere
35+
fi
36+
37+
cp ${JAVA_HOME}/lib/security/cacerts mongo-truststore
38+
${JAVA_HOME}/bin/keytool -importcert -trustcacerts -file ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -keystore mongo-truststore -storepass changeit -storetype JKS -noprompt
39+
40+
# We add extra gradle arguments for SSL
41+
export GRADLE_EXTRA_VARS="-Pssl.enabled=true -Pssl.keyStoreType=pkcs12 -Pssl.keyStore=`pwd`/client.pkc -Pssl.keyStorePassword=bithere -Pssl.trustStoreType=jks -Pssl.trustStore=`pwd`/mongo-truststore -Pssl.trustStorePassword=changeit"
42+
}
43+
44+
############################################
45+
# Main Program #
46+
############################################
47+
48+
# Set up keystore/truststore regardless, as they are required for testing KMIP
49+
provision_ssl
50+
51+
echo "Running tests with Java ${JAVA_VERSION}"
52+
./gradlew -version
53+
54+
# By not specifying the path to the `crypt_shared` via the `org.mongodb.test.crypt.shared.lib.path` Java system property,
55+
# we force the driver to start `mongocryptd` instead of loading and using `crypt_shared`.
56+
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
57+
-Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled="true" \
58+
-Dorg.mongodb.test.fle.on.demand.credential.test.azure.keyVaultEndpoint="${AZUREKMS_KEY_VAULT_ENDPOINT}" \
59+
-Dorg.mongodb.test.fle.on.demand.credential.test.azure.keyName="${AZUREKMS_KEY_NAME}" \
60+
-Dorg.mongodb.test.awsAccessKeyId=${AWS_ACCESS_KEY_ID} -Dorg.mongodb.test.awsSecretAccessKey=${AWS_SECRET_ACCESS_KEY} \
61+
-Dorg.mongodb.test.tmpAwsAccessKeyId=${AWS_TEMP_ACCESS_KEY_ID} -Dorg.mongodb.test.tmpAwsSecretAccessKey=${AWS_TEMP_SECRET_ACCESS_KEY} -Dorg.mongodb.test.tmpAwsSessionToken=${AWS_TEMP_SESSION_TOKEN} \
62+
-Dorg.mongodb.test.azureTenantId=${AZURE_TENANT_ID} -Dorg.mongodb.test.azureClientId=${AZURE_CLIENT_ID} -Dorg.mongodb.test.azureClientSecret=${AZURE_CLIENT_SECRET} \
63+
-Dorg.mongodb.test.gcpEmail=${GCP_EMAIL} -Dorg.mongodb.test.gcpPrivateKey=${GCP_PRIVATE_KEY} \
64+
${GRADLE_EXTRA_VARS} \
65+
--stacktrace --info --continue \
66+
driver-legacy:test \
67+
--tests com.mongodb.ClientSideEncryptionLegacyTest \
68+
driver-sync:test \
69+
--tests com.mongodb.client.ClientSideEncryptionTest \
70+
--tests com.mongodb.client.unified.ClientSideEncryptionTest \
71+
driver-reactive-streams:test \
72+
--tests com.mongodb.reactivestreams.client.ClientSideEncryptionTest \
73+
--tests com.mongodb.reactivestreams.client.unified.ClientSideEncryptionTest \
74+
driver-scala:integrationTest \
75+
--tests org.mongodb.scala.ClientSideEncryptionTest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ local.properties
4747

4848
# shell scripts
4949
*.sh
50+
!.evergreen/*.sh
5051

5152
# security-sensitive files
5253
*.gpg

0 commit comments

Comments
 (0)