Skip to content

test(NODE-5370): add e2e testing for the search index management API #3736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ functions:
params:
file: src/expansion.yml

"run search index management tests":
- command: subprocess.exec
params:
binary: bash
working_dir: src
add_expansions_to_env: true
args:
- .evergreen/run-search-index-management-tests.sh

"bootstrap mongo-orchestration":
- command: subprocess.exec
params:
Expand Down Expand Up @@ -1281,6 +1272,19 @@ tasks:
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
AWS_REGION: us-east-1

- name: test-search-index-helpers
commands:
- func: install dependencies
vars:
NODE_LTS_VERSION: 20
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- .evergreen/run-search-index-management-tests.sh

task_groups:
- name: serverless_task_group
setup_group_can_fail_task: true
Expand Down Expand Up @@ -1420,6 +1424,8 @@ task_groups:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
MONGODB_VERSION: "7.0"
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
Expand All @@ -1438,6 +1444,34 @@ task_groups:
tasks:
- test-aws-lambda-deployed

- name: test_atlas_task_group_search_indexes
setup_group:
- func: fetch source
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
MONGODB_VERSION: "7.0"
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
params:
file: src/atlas-expansion.yml
teardown_group:
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-search-index-helpers

pre:
- func: "fetch source"
- func: "windows fix"
Expand Down
66 changes: 44 additions & 22 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ functions:
- command: expansions.update
params:
file: src/expansion.yml
run search index management tests:
- command: subprocess.exec
params:
binary: bash
working_dir: src
add_expansions_to_env: true
args:
- .evergreen/run-search-index-management-tests.sh
bootstrap mongo-orchestration:
- command: subprocess.exec
params:
Expand Down Expand Up @@ -1204,6 +1196,18 @@ tasks:
env:
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
AWS_REGION: us-east-1
- name: test-search-index-helpers
commands:
- func: install dependencies
vars:
NODE_LTS_VERSION: 20
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- .evergreen/run-search-index-management-tests.sh
- name: test-latest-server
tags:
- latest
Expand Down Expand Up @@ -2651,17 +2655,6 @@ tasks:
variant: '*'
status: '*'
patch_optional: true
- name: test-search-index-helpers
tags: []
commands:
- func: install dependencies
vars:
NODE_LTS_NAME: 20
- func: bootstrap mongo-orchestration
vars:
VERSION: latest
TOPOLOGY: replica_set
- func: run search index management tests
- name: run-custom-csfle-tests-5.0-pinned-commit
tags:
- run-custom-dependency-tests
Expand Down Expand Up @@ -3473,6 +3466,8 @@ task_groups:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
MONGODB_VERSION: '7.0'
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
Expand All @@ -3490,6 +3485,33 @@ task_groups:
setup_group_timeout_secs: 1800
tasks:
- test-aws-lambda-deployed
- name: test_atlas_task_group_search_indexes
setup_group:
- func: fetch source
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
env:
MONGODB_VERSION: '7.0'
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
params:
file: src/atlas-expansion.yml
teardown_group:
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-search-index-helpers
pre:
- func: fetch source
- func: windows fix
Expand Down Expand Up @@ -4063,8 +4085,8 @@ buildvariants:
tasks:
- test-lambda-example
- test-lambda-aws-auth-example
- name: rhel8-test-seach-index-management-helpers
display_name: Search Index Management Helpers Tests
- name: rhel8-test-search-indexes
display_name: Search Index Tests
run_on: rhel80-large
tasks:
- test-search-index-helpers
- test_atlas_task_group_search_indexes
29 changes: 5 additions & 24 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ SINGLETON_TASKS.push(
]
);


function* makeTypescriptTasks() {
for (const TS_VERSION of ['next', 'current', '4.1.6']) {
// 4.1.6 can consume the public API but not compile the driver
Expand Down Expand Up @@ -688,26 +689,6 @@ const coverageTask = {
};

SINGLETON_TASKS.push(coverageTask);
SINGLETON_TASKS.push({
name: 'test-search-index-helpers',
tags: [],
commands: [
{
func: 'install dependencies',
vars: {
NODE_LTS_NAME: LATEST_LTS
}
},
{
func: 'bootstrap mongo-orchestration',
vars: {
VERSION: 'latest',
TOPOLOGY: 'replica_set'
}
},
{ func: 'run search index management tests' }
]
})
SINGLETON_TASKS.push(...oneOffFuncAsTasks);

BUILD_VARIANTS.push({
Expand Down Expand Up @@ -776,11 +757,11 @@ BUILD_VARIANTS.push({
});

BUILD_VARIANTS.push({
name: 'rhel8-test-seach-index-management-helpers',
display_name: 'Search Index Management Helpers Tests',
name: 'rhel8-test-search-indexes',
display_name: 'Search Index Tests',
run_on: DEFAULT_OS,
tasks: ['test-search-index-helpers']
})
tasks: ['test_atlas_task_group_search_indexes']
});

// TODO(NODE-4575): unskip zstd and snappy on node 16
for (const variant of BUILD_VARIANTS.filter(
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-search-index-management-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/bash

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

npm run check:search-indexes
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"check:tsd": "tsd --version && tsd",
"check:dependencies": "mocha test/action/dependency.test.ts",
"check:dts": "node ./node_modules/typescript/bin/tsc --noEmit mongodb.d.ts && tsd",
"check:search-indexes": "nyc mocha --config test/mocha_mongodb.json test/manual/search-index-management.spec.test.ts",
"check:search-indexes": "nyc mocha --config test/mocha_mongodb.json test/manual/search-index-management.prose.test.ts",
"check:test": "mocha --config test/mocha_mongodb.json test/integration",
"check:unit": "mocha test/unit",
"check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",
Expand Down
12 changes: 10 additions & 2 deletions src/operations/search_indexes/drop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Document } from 'bson';

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

await server.commandAsync(namespace, command, { session });
return;
try {
await server.commandAsync(namespace, command, { session });
} catch (error) {
const isNamespaceNotFoundError =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clarified in the spec based on discussion in dbx-devs. I think this is okay to pull in because it's non-breaking, even though it's a behavior change for users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3780
conflict from the async/await refactor here.

Should we make this change in v5 as well?

Copy link
Contributor Author

@baileympearson baileympearson Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a spec improvement, I think we're okay not backporting it (especially since I don't think we'll backport the e2e tests)

error instanceof MongoServerError && error.code === MONGODB_ERROR_CODES.NamespaceNotFound;
if (!isNamespaceNotFoundError) {
throw error;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path';

import { loadSpecTests } from '../spec';
import { runUnifiedSuite } from '../tools/unified-spec-runner/runner';
import { loadSpecTests } from '../../spec';
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';

describe('Search Index Management Tests (Unified)', function () {
runUnifiedSuite(loadSpecTests(join('index-management')));
Expand Down
Loading