Skip to content

Commit ee540dd

Browse files
test(NODE-5370): add e2e testing for the search index management API (#3736)
Co-authored-by: Durran Jordan <[email protected]>
1 parent e2e36cc commit ee540dd

19 files changed

+446
-74
lines changed

.evergreen/config.in.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ functions:
4545
params:
4646
file: src/expansion.yml
4747

48-
"run search index management tests":
49-
- command: subprocess.exec
50-
params:
51-
binary: bash
52-
working_dir: src
53-
add_expansions_to_env: true
54-
args:
55-
- .evergreen/run-search-index-management-tests.sh
56-
5748
"bootstrap mongo-orchestration":
5849
- command: subprocess.exec
5950
params:
@@ -1281,6 +1272,19 @@ tasks:
12811272
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
12821273
AWS_REGION: us-east-1
12831274

1275+
- name: test-search-index-helpers
1276+
commands:
1277+
- func: install dependencies
1278+
vars:
1279+
NODE_LTS_VERSION: 20
1280+
- command: subprocess.exec
1281+
params:
1282+
working_dir: src
1283+
binary: bash
1284+
add_expansions_to_env: true
1285+
args:
1286+
- .evergreen/run-search-index-management-tests.sh
1287+
12841288
task_groups:
12851289
- name: serverless_task_group
12861290
setup_group_can_fail_task: true
@@ -1420,6 +1424,8 @@ task_groups:
14201424
working_dir: src
14211425
binary: bash
14221426
add_expansions_to_env: true
1427+
env:
1428+
MONGODB_VERSION: "7.0"
14231429
args:
14241430
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
14251431
- command: expansions.update
@@ -1438,6 +1444,34 @@ task_groups:
14381444
tasks:
14391445
- test-aws-lambda-deployed
14401446

1447+
- name: test_atlas_task_group_search_indexes
1448+
setup_group:
1449+
- func: fetch source
1450+
- command: subprocess.exec
1451+
params:
1452+
working_dir: src
1453+
binary: bash
1454+
add_expansions_to_env: true
1455+
env:
1456+
MONGODB_VERSION: "7.0"
1457+
args:
1458+
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
1459+
- command: expansions.update
1460+
params:
1461+
file: src/atlas-expansion.yml
1462+
teardown_group:
1463+
- command: subprocess.exec
1464+
params:
1465+
working_dir: src
1466+
binary: bash
1467+
add_expansions_to_env: true
1468+
args:
1469+
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
1470+
setup_group_can_fail_task: true
1471+
setup_group_timeout_secs: 1800
1472+
tasks:
1473+
- test-search-index-helpers
1474+
14411475
pre:
14421476
- func: "fetch source"
14431477
- func: "windows fix"

.evergreen/config.yml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ functions:
2525
- command: expansions.update
2626
params:
2727
file: src/expansion.yml
28-
run search index management tests:
29-
- command: subprocess.exec
30-
params:
31-
binary: bash
32-
working_dir: src
33-
add_expansions_to_env: true
34-
args:
35-
- .evergreen/run-search-index-management-tests.sh
3628
bootstrap mongo-orchestration:
3729
- command: subprocess.exec
3830
params:
@@ -1204,6 +1196,18 @@ tasks:
12041196
env:
12051197
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
12061198
AWS_REGION: us-east-1
1199+
- name: test-search-index-helpers
1200+
commands:
1201+
- func: install dependencies
1202+
vars:
1203+
NODE_LTS_VERSION: 20
1204+
- command: subprocess.exec
1205+
params:
1206+
working_dir: src
1207+
binary: bash
1208+
add_expansions_to_env: true
1209+
args:
1210+
- .evergreen/run-search-index-management-tests.sh
12071211
- name: test-latest-server
12081212
tags:
12091213
- latest
@@ -2651,17 +2655,6 @@ tasks:
26512655
variant: '*'
26522656
status: '*'
26532657
patch_optional: true
2654-
- name: test-search-index-helpers
2655-
tags: []
2656-
commands:
2657-
- func: install dependencies
2658-
vars:
2659-
NODE_LTS_NAME: 20
2660-
- func: bootstrap mongo-orchestration
2661-
vars:
2662-
VERSION: latest
2663-
TOPOLOGY: replica_set
2664-
- func: run search index management tests
26652658
- name: run-custom-csfle-tests-5.0-pinned-commit
26662659
tags:
26672660
- run-custom-dependency-tests
@@ -3473,6 +3466,8 @@ task_groups:
34733466
working_dir: src
34743467
binary: bash
34753468
add_expansions_to_env: true
3469+
env:
3470+
MONGODB_VERSION: '7.0'
34763471
args:
34773472
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
34783473
- command: expansions.update
@@ -3490,6 +3485,33 @@ task_groups:
34903485
setup_group_timeout_secs: 1800
34913486
tasks:
34923487
- test-aws-lambda-deployed
3488+
- name: test_atlas_task_group_search_indexes
3489+
setup_group:
3490+
- func: fetch source
3491+
- command: subprocess.exec
3492+
params:
3493+
working_dir: src
3494+
binary: bash
3495+
add_expansions_to_env: true
3496+
env:
3497+
MONGODB_VERSION: '7.0'
3498+
args:
3499+
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
3500+
- command: expansions.update
3501+
params:
3502+
file: src/atlas-expansion.yml
3503+
teardown_group:
3504+
- command: subprocess.exec
3505+
params:
3506+
working_dir: src
3507+
binary: bash
3508+
add_expansions_to_env: true
3509+
args:
3510+
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
3511+
setup_group_can_fail_task: true
3512+
setup_group_timeout_secs: 1800
3513+
tasks:
3514+
- test-search-index-helpers
34933515
pre:
34943516
- func: fetch source
34953517
- func: windows fix
@@ -4063,8 +4085,8 @@ buildvariants:
40634085
tasks:
40644086
- test-lambda-example
40654087
- test-lambda-aws-auth-example
4066-
- name: rhel8-test-seach-index-management-helpers
4067-
display_name: Search Index Management Helpers Tests
4088+
- name: rhel8-test-search-indexes
4089+
display_name: Search Index Tests
40684090
run_on: rhel80-large
40694091
tasks:
4070-
- test-search-index-helpers
4092+
- test_atlas_task_group_search_indexes

.evergreen/generate_evergreen_tasks.js

Lines changed: 5 additions & 24 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
@@ -688,26 +689,6 @@ const coverageTask = {
688689
};
689690

690691
SINGLETON_TASKS.push(coverageTask);
691-
SINGLETON_TASKS.push({
692-
name: 'test-search-index-helpers',
693-
tags: [],
694-
commands: [
695-
{
696-
func: 'install dependencies',
697-
vars: {
698-
NODE_LTS_NAME: LATEST_LTS
699-
}
700-
},
701-
{
702-
func: 'bootstrap mongo-orchestration',
703-
vars: {
704-
VERSION: 'latest',
705-
TOPOLOGY: 'replica_set'
706-
}
707-
},
708-
{ func: 'run search index management tests' }
709-
]
710-
})
711692
SINGLETON_TASKS.push(...oneOffFuncAsTasks);
712693

713694
BUILD_VARIANTS.push({
@@ -776,11 +757,11 @@ BUILD_VARIANTS.push({
776757
});
777758

778759
BUILD_VARIANTS.push({
779-
name: 'rhel8-test-seach-index-management-helpers',
780-
display_name: 'Search Index Management Helpers Tests',
760+
name: 'rhel8-test-search-indexes',
761+
display_name: 'Search Index Tests',
781762
run_on: DEFAULT_OS,
782-
tasks: ['test-search-index-helpers']
783-
})
763+
tasks: ['test_atlas_task_group_search_indexes']
764+
});
784765

785766
// TODO(NODE-4575): unskip zstd and snappy on node 16
786767
for (const variant of BUILD_VARIANTS.filter(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/bash
22

3-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
3+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
44

55
npm run check:search-indexes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"check:tsd": "tsd --version && tsd",
141141
"check:dependencies": "mocha test/action/dependency.test.ts",
142142
"check:dts": "node ./node_modules/typescript/bin/tsc --noEmit mongodb.d.ts && tsd",
143-
"check:search-indexes": "nyc mocha --config test/mocha_mongodb.json test/manual/search-index-management.spec.test.ts",
143+
"check:search-indexes": "nyc mocha --config test/mocha_mongodb.json test/manual/search-index-management.prose.test.ts",
144144
"check:test": "mocha --config test/mocha_mongodb.json test/integration",
145145
"check:unit": "mocha test/unit",
146146
"check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",

src/operations/search_indexes/drop.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Document } from 'bson';
22

33
import type { Collection } from '../../collection';
4+
import { MONGODB_ERROR_CODES, MongoServerError } from '../../error';
45
import type { Server } from '../../sdam/server';
56
import type { ClientSession } from '../../sessions';
67
import { AbstractOperation } from '../operation';
@@ -22,7 +23,14 @@ export class DropSearchIndexOperation extends AbstractOperation<void> {
2223
command.name = this.name;
2324
}
2425

25-
await server.commandAsync(namespace, command, { session });
26-
return;
26+
try {
27+
await server.commandAsync(namespace, command, { session });
28+
} catch (error) {
29+
const isNamespaceNotFoundError =
30+
error instanceof MongoServerError && error.code === MONGODB_ERROR_CODES.NamespaceNotFound;
31+
if (!isNamespaceNotFoundError) {
32+
throw error;
33+
}
34+
}
2735
}
2836
}

test/manual/search-index-management.spec.test.ts renamed to test/integration/index-management/search-index-management.spec.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join } from 'path';
22

3-
import { loadSpecTests } from '../spec';
4-
import { runUnifiedSuite } from '../tools/unified-spec-runner/runner';
3+
import { loadSpecTests } from '../../spec';
4+
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
55

66
describe('Search Index Management Tests (Unified)', function () {
77
runUnifiedSuite(loadSpecTests(join('index-management')));

0 commit comments

Comments
 (0)