Skip to content

Commit 6053e83

Browse files
Misc cleanups for search indexes testing
1 parent b038fcf commit 6053e83

File tree

4 files changed

+71
-34
lines changed

4 files changed

+71
-34
lines changed

.evergreen/config.in.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,9 @@ task_groups:
14201420
MONGODB_VERSION: "7.0"
14211421
args:
14221422
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
1423+
- command: expansions.update
1424+
params:
1425+
file: src/atlas-expansion.yml
14231426
teardown_group:
14241427
- command: subprocess.exec
14251428
params:
@@ -1428,22 +1431,37 @@ task_groups:
14281431
add_expansions_to_env: true
14291432
args:
14301433
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
1431-
# `setup_group`s get run once-per-task-group, but only changes that get written to disk
1432-
# are preserved across tasks inside the task group. Specifically, any expansions loaded
1433-
# into memory will not be present for any tasks except the first task that gets run.
1434-
# We load the expansions file again to ensure that necessary enviroment variables are present.
1435-
setup_task:
1436-
# Load the expansion file to make an evergreen variable with the current unique version
1437-
- command: expansions.update
1434+
setup_group_can_fail_task: true
1435+
setup_group_timeout_secs: 1800
1436+
tasks:
1437+
- test-aws-lambda-deployed
1438+
1439+
- name: test_atlas_task_group_search_indexes
1440+
setup_group:
1441+
- func: fetch source
1442+
- command: subprocess.exec
14381443
params:
1439-
file: src/expansion.yml
1444+
working_dir: src
1445+
binary: bash
1446+
add_expansions_to_env: true
1447+
env:
1448+
MONGODB_VERSION: "7.0"
1449+
args:
1450+
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
14401451
- command: expansions.update
14411452
params:
14421453
file: src/atlas-expansion.yml
1454+
teardown_group:
1455+
- command: subprocess.exec
1456+
params:
1457+
working_dir: src
1458+
binary: bash
1459+
add_expansions_to_env: true
1460+
args:
1461+
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
14431462
setup_group_can_fail_task: true
14441463
setup_group_timeout_secs: 1800
14451464
tasks:
1446-
- test-aws-lambda-deployed
14471465
- test-search-index-helpers
14481466

14491467
pre:

.evergreen/config.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,6 +3462,9 @@ task_groups:
34623462
MONGODB_VERSION: '7.0'
34633463
args:
34643464
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
3465+
- command: expansions.update
3466+
params:
3467+
file: src/atlas-expansion.yml
34653468
teardown_group:
34663469
- command: subprocess.exec
34673470
params:
@@ -3470,17 +3473,36 @@ task_groups:
34703473
add_expansions_to_env: true
34713474
args:
34723475
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
3473-
setup_task:
3474-
- command: expansions.update
3476+
setup_group_can_fail_task: true
3477+
setup_group_timeout_secs: 1800
3478+
tasks:
3479+
- test-aws-lambda-deployed
3480+
- name: test_atlas_task_group_search_indexes
3481+
setup_group:
3482+
- func: fetch source
3483+
- command: subprocess.exec
34753484
params:
3476-
file: src/expansion.yml
3485+
working_dir: src
3486+
binary: bash
3487+
add_expansions_to_env: true
3488+
env:
3489+
MONGODB_VERSION: '7.0'
3490+
args:
3491+
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
34773492
- command: expansions.update
34783493
params:
34793494
file: src/atlas-expansion.yml
3495+
teardown_group:
3496+
- command: subprocess.exec
3497+
params:
3498+
working_dir: src
3499+
binary: bash
3500+
add_expansions_to_env: true
3501+
args:
3502+
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
34803503
setup_group_can_fail_task: true
34813504
setup_group_timeout_secs: 1800
34823505
tasks:
3483-
- test-aws-lambda-deployed
34843506
- test-search-index-helpers
34853507
pre:
34863508
- func: fetch source
@@ -4057,3 +4079,8 @@ buildvariants:
40574079
tasks:
40584080
- test-lambda-example
40594081
- test-lambda-aws-auth-example
4082+
- name: rhel8-test-search-indexes
4083+
display_name: Search Index Tests
4084+
run_on: rhel80-large
4085+
tasks:
4086+
- test_atlas_task_group_search_indexes

.evergreen/generate_evergreen_tasks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ SINGLETON_TASKS.push(
547547
]
548548
);
549549

550+
550551
function* makeTypescriptTasks() {
551552
for (const TS_VERSION of ['next', 'current', '4.1.6']) {
552553
// 4.1.6 can consume the public API but not compile the driver
@@ -755,6 +756,13 @@ BUILD_VARIANTS.push({
755756
tasks: ['test-lambda-example', 'test-lambda-aws-auth-example']
756757
});
757758

759+
BUILD_VARIANTS.push({
760+
name: 'rhel8-test-search-indexes',
761+
display_name: 'Search Index Tests',
762+
run_on: DEFAULT_OS,
763+
tasks: ['test_atlas_task_group_search_indexes']
764+
});
765+
758766
// TODO(NODE-4575): unskip zstd and snappy on node 16
759767
for (const variant of BUILD_VARIANTS.filter(
760768
variant =>

test/manual/search-index-management.prose.test.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('Index Management Prose Tests', function () {
3636

3737
let client: MongoClient;
3838
let timeoutController: TimeoutController;
39+
let collection: Collection;
3940

4041
/** creates a readable stream that emits every \<interval\> ms */
4142
const interval = (interval: number, signal: AbortSignal) =>
@@ -46,11 +47,9 @@ describe('Index Management Prose Tests', function () {
4647
* for indexes with name = `indexName`
4748
*/
4849
const waitForIndexes = ({
49-
collection,
5050
predicate,
5151
indexName
5252
}: {
53-
collection: Collection;
5453
predicate: (arg0: Array<Document>) => boolean;
5554
indexName?: string;
5655
}): Promise<Array<Document>> =>
@@ -73,10 +72,13 @@ describe('Index Management Prose Tests', function () {
7372
client = this.configuration.newClient();
7473
await client.connect();
7574

75+
collection = await client.db('node-test').createCollection(new ObjectId().toHexString());
76+
7677
timeoutController = new TimeoutController(60 * 1000 * 4);
7778
});
7879

7980
afterEach(async () => {
81+
await collection.drop();
8082
await client?.close();
8183
timeoutController?.clear(false);
8284
});
@@ -85,10 +87,6 @@ describe('Index Management Prose Tests', function () {
8587
'Case 1: Driver can successfully create and list search indexes',
8688
metadata,
8789
async function () {
88-
const collection = await client
89-
.db('test-db')
90-
.createCollection(new ObjectId().toHexString());
91-
9290
await collection.createSearchIndex({
9391
name: 'test-search-index',
9492
definition: {
@@ -97,7 +95,6 @@ describe('Index Management Prose Tests', function () {
9795
});
9896

9997
const [index] = await waitForIndexes({
100-
collection,
10198
predicate: indexes => indexes.every(index => index.queryable),
10299
indexName: 'test-search-index'
103100
});
@@ -113,10 +110,6 @@ describe('Index Management Prose Tests', function () {
113110
'Case 2: Driver can successfully create multiple indexes in batch',
114111
metadata,
115112
async function () {
116-
const collection = await client
117-
.db('test-db')
118-
.createCollection(new ObjectId().toHexString());
119-
120113
const indexDefinitions = [
121114
{
122115
name: 'test-search-index-1',
@@ -135,7 +128,6 @@ describe('Index Management Prose Tests', function () {
135128
await collection.createSearchIndexes(indexDefinitions);
136129

137130
const indexes = await waitForIndexes({
138-
collection,
139131
predicate: indexes => indexes.every(index => index.queryable)
140132
});
141133

@@ -151,8 +143,6 @@ describe('Index Management Prose Tests', function () {
151143
);
152144

153145
it('Case 3: Driver can successfully drop search indexes', metadata, async function () {
154-
const collection = await client.db('test-db').createCollection(new ObjectId().toHexString());
155-
156146
await collection.createSearchIndex({
157147
name: 'test-search-index',
158148
definition: {
@@ -161,15 +151,13 @@ describe('Index Management Prose Tests', function () {
161151
});
162152

163153
await waitForIndexes({
164-
collection,
165154
predicate: indexes => indexes.every(index => index.queryable),
166155
indexName: 'test-search-index'
167156
});
168157

169158
await collection.dropSearchIndex('test-search-index');
170159

171160
const indexes = await waitForIndexes({
172-
collection,
173161
predicate: indexes => indexes.length === 0,
174162
indexName: 'test-search-index'
175163
});
@@ -178,8 +166,6 @@ describe('Index Management Prose Tests', function () {
178166
});
179167

180168
it('Case 4: Driver can update a search index', metadata, async function () {
181-
const collection = await client.db('test-db').createCollection(new ObjectId().toHexString());
182-
183169
await collection.createSearchIndex({
184170
name: 'test-search-index',
185171
definition: {
@@ -188,15 +174,13 @@ describe('Index Management Prose Tests', function () {
188174
});
189175

190176
await waitForIndexes({
191-
collection,
192177
predicate: indexes => indexes.every(index => index.queryable),
193178
indexName: 'test-search-index'
194179
});
195180

196181
await collection.updateSearchIndex('test-search-index', { mappings: { dynamic: true } });
197182

198183
const [updatedIndex] = await waitForIndexes({
199-
collection,
200184
predicate: indexes => indexes.every(index => index.queryable && index.status === 'READY'),
201185
indexName: 'test-search-index'
202186
});
@@ -211,7 +195,7 @@ describe('Index Management Prose Tests', function () {
211195
'Case 5: `dropSearchIndex` suppresses namespace not found errors',
212196
metadata,
213197
async function () {
214-
const collection = await client.db('test-db').collection(new ObjectId().toHexString());
198+
const collection = await client.db('node-test').collection(new ObjectId().toHexString());
215199

216200
await collection.dropSearchIndex('test-search-index');
217201
}

0 commit comments

Comments
 (0)