Skip to content

Commit 718e7f0

Browse files
Merge branch 'main' into NODE-6052
2 parents c331eed + 4a62ec6 commit 718e7f0

File tree

3 files changed

+67
-8
lines changed

3 files changed

+67
-8
lines changed

Diff for: .evergreen/config.in.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ tasks:
13101310
- { key: NODE_LTS_VERSION, value: "20" }
13111311
- func: install dependencies
13121312
- command: subprocess.exec
1313+
type: test
13131314
params:
13141315
working_dir: src
13151316
binary: bash

Diff for: .evergreen/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@ tasks:
12591259
- {key: NODE_LTS_VERSION, value: '20'}
12601260
- func: install dependencies
12611261
- command: subprocess.exec
1262+
type: test
12621263
params:
12631264
working_dir: src
12641265
binary: bash

Diff for: test/manual/search-index-management.prose.test.ts

+65-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { Readable } from 'stream';
44
import { clearTimeout, setTimeout as setTimeoutCb } from 'timers';
55
import { setInterval } from 'timers/promises';
66

7-
import { type Collection, type Document, type MongoClient, ObjectId } from '../mongodb';
7+
import {
8+
type Collection,
9+
type Document,
10+
type MongoClient,
11+
ObjectId,
12+
ReadConcern
13+
} from '../mongodb';
814

915
class TimeoutController extends AbortController {
1016
timeoutId: NodeJS.Timeout;
@@ -46,10 +52,12 @@ describe('Index Management Prose Tests', function () {
4652
*/
4753
function waitForIndexes({
4854
predicate,
49-
indexNames
55+
indexNames,
56+
collection
5057
}: {
5158
predicate: (arg0: Array<Document>) => boolean;
5259
indexNames: string | string[];
60+
collection: Collection;
5361
}): Promise<Array<Document>> {
5462
const names = new Set([indexNames].flat());
5563
return Readable.from(
@@ -112,7 +120,8 @@ describe('Index Management Prose Tests', function () {
112120
// 1. An index with the name of test-search-index is present and the index has a field queryable with a value of true.
113121
const [index] = await waitForIndexes({
114122
predicate: indexes => indexes.every(index => index.queryable),
115-
indexNames: 'test-search-index'
123+
indexNames: 'test-search-index',
124+
collection
116125
});
117126

118127
// Assert that index has a property latestDefinition whose value is { 'mappings': { 'dynamic': false } }
@@ -165,7 +174,8 @@ describe('Index Management Prose Tests', function () {
165174
// 2. An index with the name of test-search-index-2 is present and index has a field queryable with the value of true. Store result in index2.
166175
const indexes = await waitForIndexes({
167176
predicate: indexes => indexes.every(index => index.queryable),
168-
indexNames: ['test-search-index-1', 'test-search-index-2']
177+
indexNames: ['test-search-index-1', 'test-search-index-2'],
178+
collection
169179
});
170180

171181
const index1 = indexes.find(({ name }) => name === 'test-search-index-1');
@@ -203,7 +213,8 @@ describe('Index Management Prose Tests', function () {
203213
// 1. An index with the name of test-search-index is present and index has a field queryable with the value of true.
204214
await waitForIndexes({
205215
predicate: indexes => indexes.every(index => index.queryable),
206-
indexNames: 'test-search-index'
216+
indexNames: 'test-search-index',
217+
collection
207218
});
208219

209220
// Run a dropSearchIndex on coll0, using test-search-index for the name.
@@ -213,7 +224,8 @@ describe('Index Management Prose Tests', function () {
213224
// This test fails if it times out waiting for the deletion to succeed.
214225
const indexes = await waitForIndexes({
215226
predicate: indexes => indexes.length === 0,
216-
indexNames: 'test-search-index'
227+
indexNames: 'test-search-index',
228+
collection
217229
});
218230

219231
expect(indexes).to.deep.equal([]);
@@ -241,7 +253,8 @@ describe('Index Management Prose Tests', function () {
241253
// 1. An index with the name of test-search-index is present and index has a field queryable with the value of true.
242254
await waitForIndexes({
243255
predicate: indexes => indexes.every(index => index.queryable),
244-
indexNames: 'test-search-index'
256+
indexNames: 'test-search-index',
257+
collection
245258
});
246259

247260
// Run a updateSearchIndex on coll0, using the following definition.
@@ -261,7 +274,8 @@ describe('Index Management Prose Tests', function () {
261274
// 2. The index has a field queryable with a value of true and has a field status with the value of READY.
262275
const [index2] = await waitForIndexes({
263276
predicate: indexes => indexes.every(index => index.queryable && index.status === 'READY'),
264-
indexNames: 'test-search-index'
277+
indexNames: 'test-search-index',
278+
collection
265279
});
266280

267281
// Assert that an index is present with the name test-search-index and the definition has a
@@ -283,5 +297,48 @@ describe('Index Management Prose Tests', function () {
283297
await collection.dropSearchIndex('test-search-index');
284298
}
285299
);
300+
301+
it(
302+
'Case 6: Driver can successfully create and list search indexes with non-default readConcern and writeConcern',
303+
metadata,
304+
async function () {
305+
// 1. Create a collection with the "create" command using a randomly generated name (referred to as coll0).
306+
// 2. Apply a write concern WriteConcern(w=1) and a read concern with ReadConcern(level="majority") to coll0.
307+
const coll0 = await client.db('node-test').createCollection(new ObjectId().toHexString(), {
308+
readConcern: ReadConcern.MAJORITY,
309+
writeConcern: { w: 1 }
310+
});
311+
312+
// 3. Create a new search index on coll0 with the createSearchIndex helper. Use the following definition:
313+
// {
314+
// name: 'test-search-index-case6',
315+
// definition: {
316+
// mappings: { dynamic: false }
317+
// }
318+
// }
319+
const name = await coll0.createSearchIndex({
320+
name: 'test-search-index-case6',
321+
definition: {
322+
mappings: { dynamic: false }
323+
}
324+
});
325+
326+
// 4. Assert that the command returns the name of the index: "test-search-index-case6".
327+
expect(name).to.equal('test-search-index-case6');
328+
329+
// 5. Run coll0.listSearchIndexes() repeatedly every 5 seconds until the following condition is satisfied and store the value in a variable index:
330+
// - An index with the name of test-search-index-case6 is present and the index has a field queryable with a value of true.
331+
const [index] = await waitForIndexes({
332+
predicate: indexes => indexes.every(index => index.queryable),
333+
indexNames: 'test-search-index-case6',
334+
collection: coll0
335+
});
336+
337+
// 6. Assert that index has a property latestDefinition whose value is { 'mappings': { 'dynamic': false } }
338+
expect(index)
339+
.to.have.nested.property('latestDefinition.mappings')
340+
.to.deep.equal({ dynamic: false });
341+
}
342+
);
286343
});
287344
});

0 commit comments

Comments
 (0)