Skip to content

Commit 2484ea4

Browse files
authored
test(NODE-5070): reduce fle prose 14 flakiness on sharded clusters (mongodb#3579)
1 parent 35879f6 commit 2484ea4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ describe('14. Decryption Events', metadata, function () {
4242
setupClient = this.configuration.newClient();
4343
// Drop and create the collection ``db.decryption_events``.
4444
const db = setupClient.db('db');
45+
await setupClient
46+
.db('db')
47+
.collection('decryption_events')
48+
.deleteMany({})
49+
.catch(() => null);
4550
await db.dropCollection('decryption_events').catch(() => null);
4651
await db.createCollection('decryption_events');
4752
// Create a ClientEncryption object named ``clientEncryption`` with these options:
@@ -110,6 +115,11 @@ describe('14. Decryption Events', metadata, function () {
110115
afterEach(async function () {
111116
aggregateSucceeded = undefined;
112117
aggregateFailed = undefined;
118+
await setupClient
119+
.db('db')
120+
.collection('decryption_events')
121+
.deleteMany({})
122+
.catch(() => null);
113123
await setupClient.close();
114124
await encryptedClient.close();
115125
});
@@ -216,7 +226,15 @@ describe('14. Decryption Events', metadata, function () {
216226
// to contain BSON binary for the field
217227
// ``cursor.firstBatch.encrypted``.
218228
const collection = encryptedClient.db('db').collection('decryption_events');
219-
await collection.insertOne({ encrypted: malformedCiphertext });
229+
await collection.insertOne(
230+
{ encrypted: malformedCiphertext },
231+
{ writeConcern: { w: 'majority' } }
232+
);
233+
234+
/// Verify the malformedCiphertext was inserted with a plain client
235+
const docs = await setupClient.db('db').collection('decryption_events').find({}).toArray();
236+
expect(docs).to.have.lengthOf(1);
237+
expect(docs).to.have.deep.nested.property('[0].encrypted', malformedCiphertext);
220238

221239
const error = await collection
222240
.aggregate([])

0 commit comments

Comments
 (0)