Skip to content

feat(NODE-5314): add search index helpers #3672

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 25 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4f348d9
add search index helpers
baileympearson May 12, 2023
6f9ab16
add index management tests
baileympearson May 16, 2023
2849b11
scaffolding initial rn
baileympearson May 16, 2023
65c5406
CI passing
baileympearson May 16, 2023
7802d26
node changes done
baileympearson May 17, 2023
bdb14b2
make fields readonly
baileympearson May 17, 2023
e8ef374
misc test updates
baileympearson May 17, 2023
3ab6bc3
misc cleanups
baileympearson May 17, 2023
a152b27
sync tests
baileympearson May 17, 2023
2b84107
sync tests
baileympearson May 18, 2023
8fe15a5
fix failing schema tsets
baileympearson May 18, 2023
9949463
fix schema tests && update UTR operations
baileympearson May 18, 2023
0c1cacf
move search index tests to manual test directory
baileympearson May 22, 2023
cc4c43a
sync changes to tests from review
baileympearson May 24, 2023
2f95503
lower schema versoin to 1.3
baileympearson May 24, 2023
21d8e5f
rename options to AggregationOptions
baileympearson May 24, 2023
126dea3
rename 2 test files
baileympearson May 26, 2023
764d6ae
add doc comments and the internal tag to new collection helpers
baileympearson May 30, 2023
5038b22
address Neal's comments
baileympearson May 30, 2023
bf44098
address Neal's comments pt 2
baileympearson May 30, 2023
fb4a8c7
cleanups
baileympearson May 30, 2023
c67c717
address comments
baileympearson May 31, 2023
b66854c
account for Neal's runcommandcursor changes
baileympearson May 31, 2023
28ff583
rebuild config
baileympearson May 31, 2023
00cbf4f
Merge branch 'main' into NODE-5194-node-poc-search-indexes
durran May 31, 2023
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
9 changes: 9 additions & 0 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ 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
24 changes: 24 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ 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 @@ -2596,6 +2604,17 @@ 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 @@ -4008,3 +4027,8 @@ buildvariants:
- test-lambda-example
- test-lambda-aws-auth-example
- test-deployed-lambda
- name: rhel8-test-seach-index-management-helpers
display_name: Search Index Management Helpers Tests
run_on: rhel80-large
tasks:
- test-search-index-helpers
27 changes: 27 additions & 0 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,26 @@ 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 @@ -751,6 +771,13 @@ BUILD_VARIANTS.push({
tasks: ['test-lambda-example', 'test-lambda-aws-auth-example', 'test-deployed-lambda']
});

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

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

source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"

npm run check:search-indexes
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,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: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
10 changes: 5 additions & 5 deletions src/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Admin {
*/
async command(command: Document, options?: RunCommandOptions): Promise<Document> {
return executeOperation(
this.s.db.s.client,
this.s.db.client,
new RunCommandOperation(this.s.db, command, { dbName: 'admin', ...options })
);
}
Expand Down Expand Up @@ -138,7 +138,7 @@ export class Admin {
: undefined;
const password = typeof passwordOrOptions === 'string' ? passwordOrOptions : undefined;
return executeOperation(
this.s.db.s.client,
this.s.db.client,
new AddUserOperation(this.s.db, username, password, { dbName: 'admin', ...options })
);
}
Expand All @@ -151,7 +151,7 @@ export class Admin {
*/
async removeUser(username: string, options?: RemoveUserOptions): Promise<boolean> {
return executeOperation(
this.s.db.s.client,
this.s.db.client,
new RemoveUserOperation(this.s.db, username, { dbName: 'admin', ...options })
);
}
Expand All @@ -167,7 +167,7 @@ export class Admin {
options: ValidateCollectionOptions = {}
): Promise<Document> {
return executeOperation(
this.s.db.s.client,
this.s.db.client,
new ValidateCollectionOperation(this, collectionName, options)
);
}
Expand All @@ -178,7 +178,7 @@ export class Admin {
* @param options - Optional settings for the command
*/
async listDatabases(options?: ListDatabasesOptions): Promise<ListDatabasesResult> {
return executeOperation(this.s.db.s.client, new ListDatabasesOperation(this.s.db, options));
return executeOperation(this.s.db.client, new ListDatabasesOperation(this.s.db, options));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/bulk/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,19 +597,19 @@ function executeCommands(
try {
if (isInsertBatch(batch)) {
executeOperation(
bulkOperation.s.collection.s.db.s.client,
bulkOperation.s.collection.client,
new InsertOperation(bulkOperation.s.namespace, batch.operations, finalOptions),
resultHandler
);
} else if (isUpdateBatch(batch)) {
executeOperation(
bulkOperation.s.collection.s.db.s.client,
bulkOperation.s.collection.client,
new UpdateOperation(bulkOperation.s.namespace, batch.operations, finalOptions),
resultHandler
);
} else if (isDeleteBatch(batch)) {
executeOperation(
bulkOperation.s.collection.s.db.s.client,
bulkOperation.s.collection.client,
new DeleteOperation(bulkOperation.s.namespace, batch.operations, finalOptions),
resultHandler
);
Expand Down Expand Up @@ -1222,7 +1222,7 @@ export abstract class BulkOperationBase {
const finalOptions = { ...this.s.options, ...options };
const operation = new BulkWriteShimOperation(this, finalOptions);

return executeOperation(this.s.collection.s.db.s.client, operation);
return executeOperation(this.s.collection.client, operation);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/change_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,9 @@ export class ChangeStream<
this.type === CHANGE_DOMAIN_TYPES.CLUSTER
? (this.parent as MongoClient)
: this.type === CHANGE_DOMAIN_TYPES.DATABASE
? (this.parent as Db).s.client
? (this.parent as Db).client
: this.type === CHANGE_DOMAIN_TYPES.COLLECTION
? (this.parent as Collection).s.db.s.client
? (this.parent as Collection).client
: null;

if (client == null) {
Expand Down
Loading