Skip to content

Commit 1a6dc9b

Browse files
kevinAlbsbaileympearsondurran
authored
test(NODE-6771): sync non-lb-connection-establishment test (#4426)
Co-authored-by: bailey <bailey.pearson@mongodb.com> Co-authored-by: Durran Jordan <durran@gmail.com>
1 parent cb6a7ba commit 1a6dc9b

File tree

10 files changed

+75
-49
lines changed

10 files changed

+75
-49
lines changed

.evergreen/prepare-crypt-shared-lib.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

.evergreen/setup-fle.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ bash ${DRIVERS_TOOLS}/.evergreen/csfle/setup-secrets.sh
44
source secrets-export.sh
55

66
if [ -z "${RUN_WITH_MONGOCRYPTD}" ]; then
7-
# Set up crypt shared lib if we don't want to use mongocryptd
8-
bash .evergreen/prepare-crypt-shared-lib.sh
9-
source crypt_shared.sh
10-
echo "CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH"
7+
echo "crypt shared: $CRYPT_SHARED_LIB_PATH"
118
else
9+
rm $CRYPT_SHARED_LIB_PATH
10+
unset CRYPT_SHARED_LIB_PATH
1211
echo "CRYPT_SHARED_LIB_PATH not set; using mongocryptd"
1312
fi

test/integration/client-side-encryption/client_side_encryption.prose.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,8 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
11461146
mongocryptdSpawnArgs: [
11471147
'--pidfilepath=bypass-spawning-mongocryptd.pid',
11481148
'--port=27021'
1149-
]
1149+
],
1150+
cryptSharedLibSearchPaths: []
11501151
}
11511152
}
11521153
}

test/integration/client-side-encryption/driver.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ describe('CSOT', function () {
718718
keyVaultClient,
719719
keyVaultNamespace: 'keyvault.datakeys',
720720
kmsProviders: getLocalKmsProvider(),
721+
extraOptions: getEncryptExtraOptions(),
721722
schemaMap: {
722723
'test.test': {
723724
bsonType: 'object',
@@ -771,14 +772,15 @@ describe('CSOT', function () {
771772
autoEncryption: {
772773
keyVaultClient,
773774
keyVaultNamespace: 'admin.datakeys',
774-
kmsProviders: getLocalKmsProvider()
775+
kmsProviders: getLocalKmsProvider(),
776+
extraOptions: getEncryptExtraOptions()
775777
}
776778
}
777779
);
778780
});
779781

780782
afterEach(async function () {
781-
await encryptedClient.close();
783+
await encryptedClient?.close();
782784
});
783785

784786
it('the command succeeds', metadata, async function () {

test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ describe('CSOT spec unit tests', function () {
200200
mongocryptdSpawnArgs: [
201201
`--pidfilepath=${new ObjectId().toHexString()}.pid`,
202202
'--port=27020'
203-
]
203+
],
204+
cryptSharedLibSearchPaths: []
204205
},
205206
keyVaultNamespace: 'admin.datakeys',
206207
kmsProviders: {

test/integration/crud/crud.prose.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
MongoInvalidArgumentError,
1414
MongoServerError
1515
} from '../../mongodb';
16+
import { getEncryptExtraOptions } from '../../tools/utils';
1617
import { filterForCommands } from '../shared';
1718

1819
describe('CRUD Prose Spec Tests', () => {
@@ -1023,7 +1024,8 @@ describe('CRUD Prose Spec Tests', () => {
10231024
accessKeyId: 'foo',
10241025
secretAccessKey: 'bar'
10251026
}
1026-
}
1027+
},
1028+
extraOptions: getEncryptExtraOptions()
10271029
}
10281030
}
10291031
);

test/spec/load-balancers/non-lb-connection-establishment.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@
5757
"tests": [
5858
{
5959
"description": "operations against non-load balanced clusters fail if URI contains loadBalanced=true",
60+
"runOnRequirements": [
61+
{
62+
"maxServerVersion": "8.0.99",
63+
"topologies": [
64+
"single"
65+
]
66+
},
67+
{
68+
"topologies": [
69+
"sharded"
70+
]
71+
}
72+
],
6073
"operations": [
6174
{
6275
"name": "runCommand",

test/spec/load-balancers/non-lb-connection-establishment.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ tests:
4242
# If the server is not configured to be behind a load balancer and the URI contains loadBalanced=true, the driver
4343
# should error during the connection handshake because the server's hello response does not contain a serviceId field.
4444
- description: operations against non-load balanced clusters fail if URI contains loadBalanced=true
45+
runOnRequirements:
46+
- maxServerVersion: 8.0.99 # DRIVERS-3108: Skip test on >=8.1 mongod. SERVER-85804 changes a non-LB mongod to close connection.
47+
topologies: [ single ]
48+
- topologies: [ sharded ]
49+
4550
operations:
4651
- name: runCommand
4752
object: *lbTrueDatabase

test/tools/runner/filters/client_encryption_filter.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,44 @@ import * as process from 'process';
44
import { satisfies } from 'semver';
55

66
import { kmsCredentialsPresent } from '../../../csfle-kms-providers';
7-
import { type MongoClient } from '../../../mongodb';
7+
import { type AutoEncrypter, MongoClient } from '../../../mongodb';
88
import { Filter } from './filter';
99

10+
function getCryptSharedVersion(): AutoEncrypter['cryptSharedLibVersionInfo'] | null {
11+
try {
12+
const mc = new MongoClient('mongodb://localhost:27017', {
13+
autoEncryption: {
14+
kmsProviders: {
15+
local: {
16+
key: Buffer.alloc(96)
17+
}
18+
},
19+
extraOptions: {
20+
cryptSharedLibPath: process.env.CRYPT_SHARED_LIB_PATH
21+
}
22+
}
23+
});
24+
return mc.autoEncrypter.cryptSharedLibVersionInfo;
25+
} catch {
26+
try {
27+
const mc = new MongoClient('mongodb://localhost:27017', {
28+
autoEncryption: {
29+
kmsProviders: {
30+
local: {
31+
key: Buffer.alloc(96)
32+
}
33+
}
34+
}
35+
});
36+
return mc.autoEncrypter.cryptSharedLibVersionInfo;
37+
} catch {
38+
// squash errors
39+
}
40+
}
41+
42+
return null;
43+
}
44+
1045
/**
1146
* Filter for whether or not a test needs / doesn't need Client Side Encryption
1247
*
@@ -24,15 +59,18 @@ export class ClientSideEncryptionFilter extends Filter {
2459
enabled: boolean;
2560
static version = null;
2661
static libmongocrypt: string | null = null;
62+
static cryptShared: AutoEncrypter['cryptSharedLibVersionInfo'] | null = null;
2763

2864
override async initializeFilter(client: MongoClient, context: Record<string, any>) {
29-
let mongodbClientEncryption;
65+
let mongodbClientEncryption: typeof import('mongodb-client-encryption');
3066
try {
3167
// eslint-disable-next-line @typescript-eslint/no-require-imports
3268
mongodbClientEncryption = require('mongodb-client-encryption');
3369
ClientSideEncryptionFilter.libmongocrypt = (
3470
mongodbClientEncryption as typeof import('mongodb-client-encryption')
3571
).MongoCrypt.libmongocryptVersion;
72+
73+
ClientSideEncryptionFilter.cryptShared = getCryptSharedVersion();
3674
} catch (failedToGetFLELib) {
3775
if (process.env.TEST_CSFLE) {
3876
console.error({ failedToGetFLELib });
@@ -53,7 +91,8 @@ export class ClientSideEncryptionFilter extends Filter {
5391
enabled: this.enabled,
5492
mongodbClientEncryption,
5593
version: ClientSideEncryptionFilter.version,
56-
libmongocrypt: ClientSideEncryptionFilter.libmongocrypt
94+
libmongocrypt: ClientSideEncryptionFilter.libmongocrypt,
95+
cryptShared: ClientSideEncryptionFilter.cryptShared
5796
};
5897
}
5998

test/tools/runner/hooks/configuration.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ const testConfigBeforeHook = async function () {
176176
auth: process.env.AUTH === 'auth',
177177
tls: process.env.SSL === 'ssl',
178178
csfle: {
179-
enabled: this.configuration.clientSideEncryption.enabled,
180-
version: this.configuration.clientSideEncryption.version,
181-
libmongocrypt: this.configuration.clientSideEncryption.libmongocrypt
179+
...this.configuration.clientSideEncryption
182180
},
183181
serverApi: MONGODB_API_VERSION,
184182
atlas: process.env.ATLAS_CONNECTIVITY != null,

0 commit comments

Comments
 (0)