Skip to content

Commit 4bd24ec

Browse files
committed
chore: logs and check list
1 parent 68707d2 commit 4bd24ec

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

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

+26-1
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,10 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
23102310
kmip: {},
23112311
local: undefined
23122312
};
2313-
let client1, client2;
2313+
/** @type {import('../../mongodb').MongoClient} */
2314+
let client1;
2315+
/** @type {import('../../mongodb').MongoClient} */
2316+
let client2;
23142317

23152318
describe('Case 1: Rewrap with separate ClientEncryption', function () {
23162319
/**
@@ -2341,12 +2344,16 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
23412344
`should rewrap data key from ${srcProvider} to ${dstProvider}`,
23422345
metadata,
23432346
async function () {
2347+
client1.mongoLogger?.trace('client', 'dropping datakeys collection');
2348+
23442349
// Step 1. Drop the collection ``keyvault.datakeys``
23452350
await client1
23462351
.db('keyvault')
23472352
.dropCollection('datakeys')
23482353
.catch(() => null);
23492354

2355+
client1.mongoLogger?.trace('client', 'dropped datakeys collection');
2356+
23502357
// Step 2. Create a ``ClientEncryption`` object named ``clientEncryption1``
23512358
const clientEncryption1 = new ClientEncryption(client1, {
23522359
keyVaultNamespace: 'keyvault.datakeys',
@@ -2361,17 +2368,24 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
23612368
bson: BSON
23622369
});
23632370

2371+
client1.mongoLogger?.trace('client', 'clientEncryption1.createDataKey started');
2372+
23642373
// Step 3. Call ``clientEncryption1.createDataKey`` with ``srcProvider``
23652374
const keyId = await clientEncryption1.createDataKey(srcProvider, {
23662375
masterKey: masterKeys[srcProvider]
23672376
});
23682377

2378+
client1.mongoLogger?.trace('client', 'clientEncryption1.createDataKey finished');
2379+
client1.mongoLogger?.trace('client', 'clientEncryption1.encrypt started');
2380+
23692381
// Step 4. Call ``clientEncryption1.encrypt`` with the value "test"
23702382
const cipherText = await clientEncryption1.encrypt('test', {
23712383
keyId,
23722384
algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
23732385
});
23742386

2387+
client1.mongoLogger?.trace('client', 'clientEncryption1.encrypt finished');
2388+
23752389
// Step 5. Create a ``ClientEncryption`` object named ``clientEncryption2``
23762390
const clientEncryption2 = new ClientEncryption(client2, {
23772391
keyVaultNamespace: 'keyvault.datakeys',
@@ -2386,6 +2400,8 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
23862400
bson: BSON
23872401
});
23882402

2403+
client2.mongoLogger?.trace('client', 'clientEncryption2.rewrapManyDataKey started');
2404+
23892405
// Step 6. Call ``clientEncryption2.rewrapManyDataKey`` with an empty ``filter``
23902406
const rewrapManyDataKeyResult = await clientEncryption2.rewrapManyDataKey(
23912407
{},
@@ -2395,16 +2411,25 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
23952411
}
23962412
);
23972413

2414+
client2.mongoLogger?.trace('client', 'clientEncryption2.rewrapManyDataKey finished');
2415+
23982416
expect(rewrapManyDataKeyResult).to.have.property('bulkWriteResult');
23992417
expect(rewrapManyDataKeyResult.bulkWriteResult).to.have.property('modifiedCount', 1);
24002418

2419+
client1.mongoLogger?.trace('client', 'clientEncryption1.decrypt started');
2420+
24012421
// 7. Call ``clientEncryption1.decrypt`` with the ``ciphertext``. Assert the return value is "test".
24022422
const decryptResult1 = await clientEncryption1.decrypt(cipherText);
24032423
expect(decryptResult1).to.equal('test');
24042424

2425+
client1.mongoLogger?.trace('client', 'clientEncryption1.decrypt finished');
2426+
client2.mongoLogger?.trace('client', 'clientEncryption2.decrypt started');
2427+
24052428
// 8. Call ``clientEncryption2.decrypt`` with the ``ciphertext``. Assert the return value is "test".
24062429
const decryptResult2 = await clientEncryption2.decrypt(cipherText);
24072430
expect(decryptResult2).to.equal('test');
2431+
2432+
client2.mongoLogger?.trace('client', 'clientEncryption2.decrypt finished');
24082433
}
24092434
);
24102435
}

test/tools/runner/hooks/configuration.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { OSFilter } from '../filters/os_filter';
2323
import { ServerlessFilter } from '../filters/serverless_filter';
2424
import { type Filter } from '../filters/filter';
2525
import { type Context } from 'mocha';
26+
import { flakyTests } from '../flaky';
2627

2728
// Default our tests to have auth enabled
2829
// A better solution will be tackled in NODE-3714
@@ -222,8 +223,26 @@ async function afterEachLogging(this: Context) {
222223
this.configuration.afterEachLogging(this);
223224
}
224225

226+
function checkFlakyTestList(this: Context) {
227+
const allTests: string[] = [];
228+
229+
const stack = [this.test.parent];
230+
while (stack.length) {
231+
const suite = stack.pop();
232+
allTests.push(...suite.tests.map(test => test.fullTitle()));
233+
stack.push(...suite.suites);
234+
}
235+
allTests.reverse(); // Doesn't matter but when debugging easier to see this in the expected order.
236+
237+
const flakyTestDoesNotExist = flakyTests.find(testName => !allTests.includes(testName));
238+
if (flakyTestDoesNotExist != null) {
239+
console.error('Flaky test:', flakyTestDoesNotExist, 'is not run at all');
240+
process.exitCode = 1;
241+
}
242+
}
243+
225244
export const mochaHooks = {
226-
beforeAll: [beforeAllPluginImports, testConfigBeforeHook],
245+
beforeAll: [beforeAllPluginImports, testConfigBeforeHook, checkFlakyTestList],
227246
beforeEach: [testSkipBeforeEachHook, beforeEachLogging],
228247
afterEach: [afterEachLogging],
229248
afterAll: [cleanUpMocksAfterHook]

0 commit comments

Comments
 (0)