Skip to content

Commit 289300d

Browse files
ci(NODE-4629): run csfle tests on serverless (#3442)
1 parent 78b2dd5 commit 289300d

34 files changed

+150
-40
lines changed

.evergreen/config.in.yml

+39-1
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,47 @@ functions:
148148
- command: shell.exec
149149
type: test
150150
params:
151-
working_dir: "src"
151+
silent: true
152+
working_dir: src
153+
script: |
154+
cat <<EOT > prepare_client_encryption.sh
155+
export CLIENT_ENCRYPTION=${CLIENT_ENCRYPTION}
156+
export CSFLE_KMS_PROVIDERS='${CSFLE_KMS_PROVIDERS}'
157+
export AWS_ACCESS_KEY_ID='${AWS_ACCESS_KEY_ID}'
158+
export AWS_SECRET_ACCESS_KEY='${AWS_SECRET_ACCESS_KEY}'
159+
export AWS_DEFAULT_REGION='us-east-1'
160+
export KMIP_TLS_CA_FILE="${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem"
161+
export KMIP_TLS_CERT_FILE="${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem"
162+
EOT
163+
- command: shell.exec
164+
type: test
165+
params:
166+
working_dir: src
167+
timeout_secs: 300
168+
shell: bash
152169
script: |
153170
${PREPARE_SHELL}
171+
154172
# Disable xtrace (just in case it was accidentally set).
155173
set +x
174+
source ./prepare_client_encryption.sh
175+
rm -f ./prepare_client_encryption.sh
176+
177+
export VERSION=${VERSION}
178+
export DRIVERS_TOOLS=${DRIVERS_TOOLS}
179+
180+
source ${PROJECT_DIRECTORY}/.evergreen/prepare-crypt-shared-lib.sh
181+
182+
echo "CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH"
183+
184+
# Get access to the AWS temporary credentials:
185+
echo "adding temporary AWS credentials to environment"
186+
# CSFLE_AWS_TEMP_ACCESS_KEY_ID, CSFLE_AWS_TEMP_SECRET_ACCESS_KEY, CSFLE_AWS_TEMP_SESSION_TOKEN
187+
. "$DRIVERS_TOOLS"/.evergreen/csfle/set-temp-creds.sh
188+
189+
MONGODB_URI="${MONGODB_URI}" \
190+
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
191+
MONGODB_API_VERSION="${MONGODB_API_VERSION}"
156192
157193
export MONGODB_API_VERSION="${MONGODB_API_VERSION}"
158194
export AUTH="auth"
@@ -917,6 +953,8 @@ tasks:
917953
- name: "test-serverless"
918954
tags: ["serverless"]
919955
commands:
956+
- func: install dependencies
957+
- func: bootstrap kms servers
920958
- func: "run serverless tests"
921959

922960
- name: run-spec-benchmark-tests

.evergreen/config.yml

+38
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,47 @@ functions:
121121
- command: shell.exec
122122
type: test
123123
params:
124+
silent: true
124125
working_dir: src
126+
script: |
127+
cat <<EOT > prepare_client_encryption.sh
128+
export CLIENT_ENCRYPTION=${CLIENT_ENCRYPTION}
129+
export CSFLE_KMS_PROVIDERS='${CSFLE_KMS_PROVIDERS}'
130+
export AWS_ACCESS_KEY_ID='${AWS_ACCESS_KEY_ID}'
131+
export AWS_SECRET_ACCESS_KEY='${AWS_SECRET_ACCESS_KEY}'
132+
export AWS_DEFAULT_REGION='us-east-1'
133+
export KMIP_TLS_CA_FILE="${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem"
134+
export KMIP_TLS_CERT_FILE="${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem"
135+
EOT
136+
- command: shell.exec
137+
type: test
138+
params:
139+
working_dir: src
140+
timeout_secs: 300
141+
shell: bash
125142
script: |
126143
${PREPARE_SHELL}
144+
127145
# Disable xtrace (just in case it was accidentally set).
128146
set +x
147+
source ./prepare_client_encryption.sh
148+
rm -f ./prepare_client_encryption.sh
149+
150+
export VERSION=${VERSION}
151+
export DRIVERS_TOOLS=${DRIVERS_TOOLS}
152+
153+
source ${PROJECT_DIRECTORY}/.evergreen/prepare-crypt-shared-lib.sh
154+
155+
echo "CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH"
156+
157+
# Get access to the AWS temporary credentials:
158+
echo "adding temporary AWS credentials to environment"
159+
# CSFLE_AWS_TEMP_ACCESS_KEY_ID, CSFLE_AWS_TEMP_SECRET_ACCESS_KEY, CSFLE_AWS_TEMP_SESSION_TOKEN
160+
. "$DRIVERS_TOOLS"/.evergreen/csfle/set-temp-creds.sh
161+
162+
MONGODB_URI="${MONGODB_URI}" \
163+
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
164+
MONGODB_API_VERSION="${MONGODB_API_VERSION}"
129165
130166
export MONGODB_API_VERSION="${MONGODB_API_VERSION}"
131167
export AUTH="auth"
@@ -864,6 +900,8 @@ tasks:
864900
tags:
865901
- serverless
866902
commands:
903+
- func: install dependencies
904+
- func: bootstrap kms servers
867905
- func: run serverless tests
868906
- name: run-spec-benchmark-tests
869907
tags:

.evergreen/run-serverless-tests.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if [ -z ${MONGODB_URI+omitted} ]; then echo "MONGODB_URI is unset" && exit 1; fi
1010
if [ -z ${SERVERLESS_ATLAS_USER+omitted} ]; then echo "SERVERLESS_ATLAS_USER is unset" && exit 1; fi
1111
if [ -z ${SERVERLESS_ATLAS_PASSWORD+omitted} ]; then echo "SERVERLESS_ATLAS_PASSWORD is unset" && exit 1; fi
1212

13+
npm install mongodb-client-encryption@">=2.3.0"
14+
1315
npx mocha \
1416
--config test/mocha_mongodb.json \
1517
test/integration/crud/crud.spec.test.js \
@@ -21,4 +23,5 @@ npx mocha \
2123
test/integration/transactions/transactions.spec.test.js \
2224
test/integration/transactions/transactions.test.ts \
2325
test/integration/versioned-api/versioned_api.spec.test.js \
24-
test/integration/load-balancers/load_balancers.spec.test.js
26+
test/integration/load-balancers/load_balancers.spec.test.js \
27+
test/integration/client-side-encryption/client_side_encryption.spec.test.ts

test/integration/client-side-encryption/client_side_encryption.spec.test.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ const SKIPPED_TESTS = new Set([
6464
...(isAuthEnabled ? skippedAuthTests.concat(skippedNoAuthTests) : skippedNoAuthTests)
6565
]);
6666

67+
const isServerless = !!process.env.SERVERLESS;
68+
6769
describe('Client Side Encryption (Legacy)', function () {
6870
const testContext = new TestRunnerContext({ requiresCSFLE: true });
6971
const testSuites = gatherTestSuites(
@@ -78,12 +80,26 @@ describe('Client Side Encryption (Legacy)', function () {
7880
return testContext.setup(this.configuration);
7981
});
8082

81-
generateTopologyTests(testSuites, testContext, spec => {
82-
return !SKIPPED_TESTS.has(spec.description);
83+
generateTopologyTests(testSuites, testContext, ({ description }) => {
84+
if (SKIPPED_TESTS.has(description)) {
85+
return false;
86+
}
87+
if (isServerless) {
88+
// TODO(NODE-4730): Fix failing csfle tests against serverless
89+
const isSkippedTest = [
90+
'BypassQueryAnalysis decrypts',
91+
'encryptedFieldsMap is preferred over remote encryptedFields'
92+
].includes(description);
93+
94+
return !isSkippedTest;
95+
}
96+
return true;
8397
});
8498
});
8599

86100
describe('Client Side Encryption (Unified)', function () {
87101
installNode18DNSHooks();
88-
runUnifiedSuite(loadSpecTests(path.join('client-side-encryption', 'tests', 'unified')));
102+
runUnifiedSuite(loadSpecTests(path.join('client-side-encryption', 'tests', 'unified')), () =>
103+
isServerless ? 'Unified CSFLE tests to not run on serverless' : false
104+
);
89105
});

test/spec/client-side-encryption/tests/legacy/fle2-BypassQueryAnalysis.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-BypassQueryAnalysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []

test/spec/client-side-encryption/tests/legacy/fle2-Compact.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-Compact.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []

test/spec/client-side-encryption/tests/legacy/fle2-CreateCollection.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-CreateCollection.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
runOn:
33
- minServerVersion: "6.0.0"
44
# FLE 2 Encrypted collections are not supported on standalone.
5-
topology: [ "replicaset", "sharded" ]
5+
topology: [ "replicaset", "sharded", "load-balanced" ]
66

77
database_name: &database_name "default"
88
collection_name: &collection_name "default"

test/spec/client-side-encryption/tests/legacy/fle2-DecryptExistingData.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-DecryptExistingData.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: [

test/spec/client-side-encryption/tests/legacy/fle2-Delete.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-Delete.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []

test/spec/client-side-encryption/tests/legacy/fle2-EncryptedFields-vs-EncryptedFieldsMap.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-EncryptedFields-vs-EncryptedFieldsMap.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []
@@ -77,4 +77,4 @@ tests:
7777
outcome:
7878
collection:
7979
data:
80-
- *doc0
80+
- *doc0

test/spec/client-side-encryption/tests/legacy/fle2-EncryptedFields-vs-jsonSchema.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-EncryptedFields-vs-jsonSchema.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []

test/spec/client-side-encryption/tests/legacy/fle2-EncryptedFieldsMap-defaults.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-EncryptedFieldsMap-defaults.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []
@@ -54,4 +54,4 @@ tests:
5454
outcome:
5555
collection:
5656
data:
57-
- *doc0
57+
- *doc0

test/spec/client-side-encryption/tests/legacy/fle2-FindOneAndUpdate.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-FindOneAndUpdate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []

test/spec/client-side-encryption/tests/legacy/fle2-InsertFind-Indexed.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-InsertFind-Indexed.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []

test/spec/client-side-encryption/tests/legacy/fle2-InsertFind-Unindexed.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "6.0.0",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

test/spec/client-side-encryption/tests/legacy/fle2-InsertFind-Unindexed.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
runOn:
22
- minServerVersion: "6.0.0"
33
# FLE 2 Encrypted collections are not supported on standalone.
4-
topology: [ "replicaset", "sharded" ]
4+
topology: [ "replicaset", "sharded", "load-balanced" ]
55
database_name: &database_name "default"
66
collection_name: &collection_name "default"
77
data: []
@@ -84,4 +84,4 @@ tests:
8484
# Before the message was "cannot query non-indexed fields with the randomized encryption algorithm"
8585
# After: "can only execute encrypted equality queries with an encrypted equality index"
8686
# Use a small common substring.
87-
errorContains: "encrypt"
87+
errorContains: "encrypt"

0 commit comments

Comments
 (0)