Skip to content

Commit

Permalink
test(NODE-6101): cherry-pick test fixes from main (#4087)
Browse files Browse the repository at this point in the history
Co-authored-by: Durran Jordan <durran@gmail.com>
Co-authored-by: Neal Beeken <neal.beeken@mongodb.com>
  • Loading branch information
3 people committed Apr 22, 2024
1 parent 55c290a commit 63ba4ac
Show file tree
Hide file tree
Showing 98 changed files with 236 additions and 146 deletions.
29 changes: 7 additions & 22 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1169,17 +1169,7 @@ tasks:
binary: bash
add_expansions_to_env: true
args:
- src/.evergreen/copy-driver-to-azure.sh
- command: subprocess.exec
type: test
params:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
AZUREKMS_CMD: "env EXPECTED_AZUREKMS_OUTCOME=success bash src/.evergreen/run-azure-kms-tests.sh"
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/run-command.sh
- src/.evergreen/copy-driver-to-azure-and-run.sh

- name: "test-azurekms-fail-task"
commands:
Expand Down Expand Up @@ -1269,14 +1259,8 @@ task_groups:
params:
working_dir: "src"
binary: bash
add_expansions_to_env: true
env:
testgcpkms_key_file: ${gcpkms_key_file}
GCPKMS_SERVICEACCOUNT: ${gcpkms_service_account}
GCPKMS_DRIVERS_TOOLS: ${DRIVERS_TOOLS}
GCPKMS_MACHINETYPE: "e2-standard-4"
args:
- .evergreen/setup-gcp-instance.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/setup.sh
- command: expansions.update
# Load the GCPKMS_GCLOUD, GCPKMS_INSTANCE, GCPKMS_REGION, and GCPKMS_ZONE expansions.
params:
Expand All @@ -1293,7 +1277,7 @@ task_groups:
GCPKMS_ZONE: ${GCPKMS_ZONE}
GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/delete-instance.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/teardown.sh
tasks:
- test-gcpkms-task

Expand All @@ -1306,9 +1290,10 @@ task_groups:
params:
working_dir: "src"
binary: bash
add_expansions_to_env: true
env:
AZUREKMS_VMNAME_PREFIX: "NODE_DRIVER"
args:
- .evergreen/setup-azure-vm.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup.sh
- command: expansions.update
# Load AZUREKMS_VMNAME into the expansions.
params:
Expand All @@ -1324,7 +1309,7 @@ task_groups:
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/delete-vm.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/teardown.sh
tasks:
- test-azurekms-task

Expand Down
29 changes: 7 additions & 22 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1125,17 +1125,7 @@ tasks:
binary: bash
add_expansions_to_env: true
args:
- src/.evergreen/copy-driver-to-azure.sh
- command: subprocess.exec
type: test
params:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
AZUREKMS_CMD: env EXPECTED_AZUREKMS_OUTCOME=success bash src/.evergreen/run-azure-kms-tests.sh
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/run-command.sh
- src/.evergreen/copy-driver-to-azure-and-run.sh
- name: test-azurekms-fail-task
commands:
- command: expansions.update
Expand Down Expand Up @@ -3596,14 +3586,8 @@ task_groups:
params:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
testgcpkms_key_file: ${gcpkms_key_file}
GCPKMS_SERVICEACCOUNT: ${gcpkms_service_account}
GCPKMS_DRIVERS_TOOLS: ${DRIVERS_TOOLS}
GCPKMS_MACHINETYPE: e2-standard-4
args:
- .evergreen/setup-gcp-instance.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/setup.sh
- command: expansions.update
params:
file: src/testgcpkms-expansions.yml
Expand All @@ -3618,7 +3602,7 @@ task_groups:
GCPKMS_ZONE: ${GCPKMS_ZONE}
GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/delete-instance.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/teardown.sh
tasks:
- test-gcpkms-task
- name: test_azurekms_task_group
Expand All @@ -3630,9 +3614,10 @@ task_groups:
params:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
AZUREKMS_VMNAME_PREFIX: NODE_DRIVER
args:
- .evergreen/setup-azure-vm.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup.sh
- command: expansions.update
params:
file: src/testazurekms-expansions.yml
Expand All @@ -3645,7 +3630,7 @@ task_groups:
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/delete-vm.sh
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/teardown.sh
tasks:
- test-azurekms-task
- name: test_atlas_task_group
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#! /usr/bin/env bash

set -o errexit
source "${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/secrets-export.sh"

if [ -z ${AZUREKMS_RESOURCEGROUP+omitted} ]; then echo "AZUREKMS_RESOURCEGROUP is unset" && exit 1; fi
if [ -z ${AZUREKMS_VMNAME+omitted} ]; then echo "AZUREKMS_VMNAME is unset" && exit 1; fi
if [ -z ${AZUREKMS_PRIVATEKEYPATH+omitted} ]; then echo "AZUREKMS_PRIVATEKEYPATH is unset" && exit 1; fi

source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"

export AZUREKMS_PUBLICKEYPATH=/tmp/testazurekms_publickey
export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey

echo "compressing node driver source ... begin"
tar -czf node-driver-source.tgz src
echo "compressing node driver source ... end"
Expand All @@ -22,3 +25,8 @@ echo "decompressing node driver tar on azure ... begin"
export AZUREKMS_CMD="tar xf node-driver-source.tgz"
"${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/run-command.sh"
echo "decompressing node driver tar on azure ... end"

echo "Running test ... begin"
export AZUREKMS_CMD="env EXPECTED_AZUREKMS_OUTCOME=success bash src/.evergreen/run-azure-kms-tests.sh"
${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/run-command.sh
echo "Running test ... end"
20 changes: 0 additions & 20 deletions .evergreen/setup-azure-vm.sh

This file was deleted.

9 changes: 0 additions & 9 deletions .evergreen/setup-gcp-instance.sh

This file was deleted.

2 changes: 2 additions & 0 deletions .evergreen/setup-gcp-testing.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/env bash

source "${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/secrets-export.sh"

# Assert required environment variables are present without printing them
if [ -z ${GCPKMS_GCLOUD+omitted} ]; then echo "GCPKMS_GCLOUD is unset" && exit 1; fi
if [ -z ${GCPKMS_PROJECT+omitted} ]; then echo "GCPKMS_PROJECT is unset" && exit 1; fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const metaData: MongoDBMetadataUI = {

// The Range Explicit Encryption tests require MongoDB server 7.0+ for QE v2.
// The tests must not run against a standalone.
mongodb: '>=7.0.0',
//
// `rangePreview` is not supported on 8.0+ servers.
mongodb: '>=7.0.0 <8.0.0',
topology: '!single'
}
};
Expand Down Expand Up @@ -132,7 +134,7 @@ describe('Range Explicit Encryption', function () {
let encryptedTwoHundred;
let compareNumericValues;
for (const { type: dataType, rangeOptions, factory } of dataTypes) {
context(`datatype ${dataType}`, async function () {
context(`datatype ${dataType}`, function () {
beforeEach(async function () {
compareNumericValues = function (value: unknown, expected: number): void {
if (dataType === 'DoubleNoPrecision' || dataType === 'DoublePrecision') {
Expand Down
47 changes: 26 additions & 21 deletions test/integration/crud/bulk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,32 +652,37 @@ describe('Bulk', function () {
}
});

it('should correctly execute ordered batch using w:0', function (done) {
client.connect((err, client) => {
const db = client.db();
const col = db.collection('batch_write_ordered_ops_9');
it(
'should correctly execute ordered batch using w:0',
// TODO(NODE-6060): set `moreToCome` op_msg bit when `w: 0` is specified
{ requires: { mongodb: '<8.0.0' } },
function (done) {
client.connect((err, client) => {
const db = client.db();
const col = db.collection('batch_write_ordered_ops_9');

const bulk = col.initializeOrderedBulkOp();
for (let i = 0; i < 100; i++) {
bulk.insert({ a: 1 });
}
const bulk = col.initializeOrderedBulkOp();
for (let i = 0; i < 100; i++) {
bulk.insert({ a: 1 });
}

bulk.find({ b: 1 }).upsert().update({ b: 1 });
bulk.find({ c: 1 }).delete();
bulk.find({ b: 1 }).upsert().update({ b: 1 });
bulk.find({ c: 1 }).delete();

bulk.execute({ writeConcern: { w: 0 } }, function (err, result) {
expect(err).to.not.exist;
test.equal(0, result.upsertedCount);
test.equal(0, result.insertedCount);
test.equal(0, result.matchedCount);
test.ok(0 === result.modifiedCount || result.modifiedCount == null);
test.equal(0, result.deletedCount);
test.equal(false, result.hasWriteErrors());
bulk.execute({ writeConcern: { w: 0 } }, function (err, result) {
expect(err).to.not.exist;
test.equal(0, result.upsertedCount);
test.equal(0, result.insertedCount);
test.equal(0, result.matchedCount);
test.ok(0 === result.modifiedCount || result.modifiedCount == null);
test.equal(0, result.deletedCount);
test.equal(false, result.hasWriteErrors());

client.close(done);
client.close(done);
});
});
});
});
}
);

it('should correctly handle single unordered batch API', function (done) {
client.connect((err, client) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"key_vault_data": [],
"tests": [
{
"description": "FLE2 encrypt fails with mising key",
"description": "FLE2 encrypt fails with missing key",
"clientOptions": {
"autoEncryptOpts": {
"kmsProviders": {
Expand Down Expand Up @@ -85,7 +85,7 @@
]
},
{
"description": "FLE2 decrypt fails with mising key",
"description": "FLE2 decrypt fails with missing key",
"clientOptions": {
"autoEncryptOpts": {
"kmsProviders": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data: [
encrypted_fields: {'fields': [{'keyId': {'$binary': {'base64': 'EjRWeBI0mHYSNBI0VniQEg==', 'subType': '04'}}, 'path': 'encryptedIndexed', 'bsonType': 'string', 'queries': {'queryType': 'equality', 'contention': {'$numberLong': '0'}}}, {'keyId': {'$binary': {'base64': 'q83vqxI0mHYSNBI0VniQEg==', 'subType': '04'}}, 'path': 'encryptedUnindexed', 'bsonType': 'string'}]}
key_vault_data: []
tests:
- description: "FLE2 encrypt fails with mising key"
- description: "FLE2 encrypt fails with missing key"
clientOptions:
autoEncryptOpts:
kmsProviders:
Expand All @@ -30,7 +30,7 @@ tests:
document: { _id: 1, encryptedIndexed: "123" }
result:
errorContains: "not all keys requested were satisfied"
- description: "FLE2 decrypt fails with mising key"
- description: "FLE2 decrypt fails with missing key"
clientOptions:
autoEncryptOpts:
kmsProviders:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"replicaset",
"sharded",
"load-balanced"
]
],
"maxServerVersion": "7.99.99"
}
],
"database_name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ runOn:
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
# FLE 2 Encrypted collections are not supported on standalone.
topology: [ "replicaset", "sharded", "load-balanced" ]
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
maxServerVersion: "7.99.99"
database_name: &database_name "default"
collection_name: &collection_name "default"
data: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"replicaset",
"sharded",
"load-balanced"
]
],
"maxServerVersion": "7.99.99"
}
],
"database_name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ runOn:
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
# FLE 2 Encrypted collections are not supported on standalone.
topology: [ "replicaset", "sharded", "load-balanced" ]
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
maxServerVersion: "7.99.99"
database_name: &database_name "default"
collection_name: &collection_name "default"
data: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"replicaset",
"sharded",
"load-balanced"
]
],
"maxServerVersion": "7.99.99"
}
],
"database_name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ runOn:
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
# FLE 2 Encrypted collections are not supported on standalone.
topology: [ "replicaset", "sharded", "load-balanced" ]
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
maxServerVersion: "7.99.99"
database_name: &database_name "default"
collection_name: &collection_name "default"
data: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"replicaset",
"sharded",
"load-balanced"
]
],
"maxServerVersion": "7.99.99"
}
],
"database_name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ runOn:
# Skip QEv2 (also referred to as FLE2v2) tests on Serverless. Unskip once Serverless enables the QEv2 protocol.
# FLE 2 Encrypted collections are not supported on standalone.
topology: [ "replicaset", "sharded", "load-balanced" ]
# Skip tests for "rangePreview" algorithm on Server 8.0+. Server 8.0 drops "rangePreview" and adds "range".
maxServerVersion: "7.99.99"
database_name: &database_name "default"
collection_name: &collection_name "default"
data: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"replicaset",
"sharded",
"load-balanced"
]
],
"maxServerVersion": "7.99.99"
}
],
"database_name": "default",
Expand Down

0 comments on commit 63ba4ac

Please sign in to comment.