Skip to content

Commit

Permalink
feat(NODE-5314): add search index helpers (#3672)
Browse files Browse the repository at this point in the history
Co-authored-by: Durran Jordan <durran@gmail.com>
  • Loading branch information
baileympearson and durran committed May 31, 2023
1 parent e5e3c93 commit f647542
Show file tree
Hide file tree
Showing 37 changed files with 1,561 additions and 92 deletions.
9 changes: 9 additions & 0 deletions .evergreen/config.in.yml
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
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
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
@@ -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
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
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
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
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

0 comments on commit f647542

Please sign in to comment.