Skip to content

Commit 85124c2

Browse files
test(NODE-6836): make broken mongocryptd tests run in CI (#4497)
1 parent 6b05a77 commit 85124c2

File tree

7 files changed

+279
-378
lines changed

7 files changed

+279
-378
lines changed

.evergreen/config.yml

-8
Original file line numberDiff line numberDiff line change
@@ -2752,7 +2752,6 @@ tasks:
27522752
- {key: VERSION, value: latest}
27532753
- {key: TOPOLOGY, value: sharded_cluster}
27542754
- {key: AUTH, value: auth}
2755-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
27562755
- func: install dependencies
27572756
- func: bootstrap mongo-orchestration
27582757
- func: run tests
@@ -2768,7 +2767,6 @@ tasks:
27682767
- {key: VERSION, value: rapid}
27692768
- {key: TOPOLOGY, value: sharded_cluster}
27702769
- {key: AUTH, value: auth}
2771-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
27722770
- func: install dependencies
27732771
- func: bootstrap mongo-orchestration
27742772
- func: run tests
@@ -2784,7 +2782,6 @@ tasks:
27842782
- {key: VERSION, value: '8.0'}
27852783
- {key: TOPOLOGY, value: sharded_cluster}
27862784
- {key: AUTH, value: auth}
2787-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
27882785
- func: install dependencies
27892786
- func: bootstrap mongo-orchestration
27902787
- func: run tests
@@ -2800,7 +2797,6 @@ tasks:
28002797
- {key: VERSION, value: '7.0'}
28012798
- {key: TOPOLOGY, value: sharded_cluster}
28022799
- {key: AUTH, value: auth}
2803-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
28042800
- func: install dependencies
28052801
- func: bootstrap mongo-orchestration
28062802
- func: run tests
@@ -2816,7 +2812,6 @@ tasks:
28162812
- {key: VERSION, value: '6.0'}
28172813
- {key: TOPOLOGY, value: sharded_cluster}
28182814
- {key: AUTH, value: auth}
2819-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
28202815
- func: install dependencies
28212816
- func: bootstrap mongo-orchestration
28222817
- func: run tests
@@ -2832,7 +2827,6 @@ tasks:
28322827
- {key: VERSION, value: '5.0'}
28332828
- {key: TOPOLOGY, value: sharded_cluster}
28342829
- {key: AUTH, value: auth}
2835-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
28362830
- func: install dependencies
28372831
- func: bootstrap mongo-orchestration
28382832
- func: run tests
@@ -2848,7 +2842,6 @@ tasks:
28482842
- {key: VERSION, value: '4.4'}
28492843
- {key: TOPOLOGY, value: sharded_cluster}
28502844
- {key: AUTH, value: auth}
2851-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
28522845
- func: install dependencies
28532846
- func: bootstrap mongo-orchestration
28542847
- func: run tests
@@ -2864,7 +2857,6 @@ tasks:
28642857
- {key: VERSION, value: '4.2'}
28652858
- {key: TOPOLOGY, value: sharded_cluster}
28662859
- {key: AUTH, value: auth}
2867-
- {key: TEST_NPM_SCRIPT, value: check:csfle}
28682860
- func: install dependencies
28692861
- func: bootstrap mongo-orchestration
28702862
- func: run tests

.evergreen/generate_evergreen_tasks.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@ const MONGOCRYPTD_CSFLE_TASKS = MONGODB_VERSIONS.filter(
464464
updateExpansions({
465465
VERSION: mongoVersion,
466466
TOPOLOGY: 'sharded_cluster',
467-
AUTH: 'auth',
468-
TEST_NPM_SCRIPT: 'check:csfle'
467+
AUTH: 'auth'
469468
}),
470469
{ func: 'install dependencies' },
471470
{ func: 'bootstrap mongo-orchestration' },

.evergreen/run-tests.sh

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
#!/bin/bash
22
# set -o xtrace # Write all commands first to stderr
3-
set -o errexit # Exit the script with error if any of the commands fail
3+
set -o errexit # Exit the script with error if any of the commands fail
44

55
# Supported/used environment variables:
66
# AUTH Set to enable authentication. Defaults to "noauth"
77
# SSL Set to enable SSL. Defaults to "nossl"
88
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
99
# MARCH Machine Architecture. Defaults to lowercase uname -m
10-
# TEST_NPM_SCRIPT Script to npm run. Defaults to "integration-coverage"
1110
# SKIP_DEPS Skip installing dependencies
1211
# TEST_CSFLE Set to enforce running csfle tests
1312

1413
AUTH=${AUTH:-noauth}
1514
MONGODB_URI=${MONGODB_URI:-}
16-
TEST_NPM_SCRIPT=${TEST_NPM_SCRIPT:-check:integration-coverage}
1715
COMPRESSOR=${COMPRESSOR:-}
1816
SKIP_DEPS=${SKIP_DEPS:-true}
1917

@@ -28,8 +26,8 @@ fi
2826
# ssl setup
2927
SSL=${SSL:-nossl}
3028
if [ "$SSL" != "nossl" ]; then
31-
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
32-
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
29+
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
30+
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
3331
fi
3432

3533
# run tests
@@ -60,4 +58,4 @@ export MONGODB_URI=${MONGODB_URI}
6058
export LOAD_BALANCER=${LOAD_BALANCER}
6159
export TEST_CSFLE=${TEST_CSFLE}
6260
export COMPRESSOR=${COMPRESSOR}
63-
npm run "${TEST_NPM_SCRIPT}"
61+
npm run check:integration-coverage

src/client-side-encryption/auto_encrypter.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,10 @@ export class AutoEncrypter {
365365
const client = await this._mongocryptdClient.connect();
366366
return client;
367367
} catch (error) {
368-
const { message } = error;
369-
if (message && (message.match(/timed out after/) || message.match(/ENOTFOUND/))) {
370-
throw new MongoRuntimeError(
371-
'Unable to connect to `mongocryptd`, please make sure it is running or in your PATH for auto-spawn',
372-
{ cause: error }
373-
);
374-
}
375-
throw error;
368+
throw new MongoRuntimeError(
369+
'Unable to connect to `mongocryptd`, please make sure it is running or in your PATH for auto-spawn',
370+
{ cause: error }
371+
);
376372
}
377373
}
378374

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const path = require('path');
77
const { dropCollection, APMEventCollector } = require('../shared');
88

99
const { EJSON } = BSON;
10-
const { LEGACY_HELLO_COMMAND, MongoCryptError } = require('../../mongodb');
10+
const { LEGACY_HELLO_COMMAND, MongoCryptError, MongoRuntimeError } = require('../../mongodb');
1111
const { MongoServerError, MongoServerSelectionError, MongoClient } = require('../../mongodb');
1212
const { getEncryptExtraOptions } = require('../../tools/utils');
1313

@@ -1177,9 +1177,16 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
11771177
.insertOne({ encrypted: 'test' })
11781178
.catch(e => e);
11791179

1180-
expect(insertError).to.be.instanceOf(MongoServerSelectionError);
1180+
expect(insertError)
1181+
.to.be.instanceOf(MongoRuntimeError)
1182+
.to.match(
1183+
/Unable to connect to `mongocryptd`, please make sure it is running or in your PATH for auto-spawn/
1184+
);
1185+
1186+
const { cause } = insertError;
11811187

1182-
expect(insertError, 'Error must contain ECONNREFUSED').to.satisfy(
1188+
expect(cause).to.be.instanceOf(MongoServerSelectionError);
1189+
expect(cause, 'Error must contain ECONNREFUSED').to.satisfy(
11831190
error =>
11841191
/ECONNREFUSED/.test(error.message) ||
11851192
!!error.cause?.cause?.errors?.every(e => e.code === 'ECONNREFUSED')

0 commit comments

Comments
 (0)