Skip to content

Commit f647542

Browse files
feat(NODE-5314): add search index helpers (#3672)
Co-authored-by: Durran Jordan <[email protected]>
1 parent e5e3c93 commit f647542

37 files changed

+1561
-92
lines changed

.evergreen/config.in.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ 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+
4857
"bootstrap mongo-orchestration":
4958
- command: subprocess.exec
5059
params:

.evergreen/config.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ 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
2836
bootstrap mongo-orchestration:
2937
- command: subprocess.exec
3038
params:
@@ -2596,6 +2604,17 @@ tasks:
25962604
variant: '*'
25972605
status: '*'
25982606
patch_optional: true
2607+
- name: test-search-index-helpers
2608+
tags: []
2609+
commands:
2610+
- func: install dependencies
2611+
vars:
2612+
NODE_LTS_NAME: 20
2613+
- func: bootstrap mongo-orchestration
2614+
vars:
2615+
VERSION: latest
2616+
TOPOLOGY: replica_set
2617+
- func: run search index management tests
25992618
- name: run-custom-csfle-tests-5.0-pinned-commit
26002619
tags:
26012620
- run-custom-dependency-tests
@@ -4008,3 +4027,8 @@ buildvariants:
40084027
- test-lambda-example
40094028
- test-lambda-aws-auth-example
40104029
- test-deployed-lambda
4030+
- name: rhel8-test-seach-index-management-helpers
4031+
display_name: Search Index Management Helpers Tests
4032+
run_on: rhel80-large
4033+
tasks:
4034+
- test-search-index-helpers

.evergreen/generate_evergreen_tasks.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,26 @@ const coverageTask = {
699699
};
700700

701701
SINGLETON_TASKS.push(coverageTask);
702+
SINGLETON_TASKS.push({
703+
name: 'test-search-index-helpers',
704+
tags: [],
705+
commands: [
706+
{
707+
func: 'install dependencies',
708+
vars: {
709+
NODE_LTS_NAME: LATEST_LTS
710+
}
711+
},
712+
{
713+
func: 'bootstrap mongo-orchestration',
714+
vars: {
715+
VERSION: 'latest',
716+
TOPOLOGY: 'replica_set'
717+
}
718+
},
719+
{ func: 'run search index management tests' }
720+
]
721+
})
702722
SINGLETON_TASKS.push(...oneOffFuncAsTasks);
703723

704724
BUILD_VARIANTS.push({
@@ -751,6 +771,13 @@ BUILD_VARIANTS.push({
751771
tasks: ['test-lambda-example', 'test-lambda-aws-auth-example', 'test-deployed-lambda']
752772
});
753773

774+
BUILD_VARIANTS.push({
775+
name: 'rhel8-test-seach-index-management-helpers',
776+
display_name: 'Search Index Management Helpers Tests',
777+
run_on: DEFAULT_OS,
778+
tasks: ['test-search-index-helpers']
779+
})
780+
754781
// TODO(NODE-4575): unskip zstd and snappy on node 16
755782
for (const variant of BUILD_VARIANTS.filter(
756783
variant =>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/bash
2+
3+
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
4+
5+
npm run check:search-indexes

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"check:tsd": "tsd --version && tsd",
121121
"check:dependencies": "mocha test/action/dependency.test.ts",
122122
"check:dts": "node ./node_modules/typescript/bin/tsc --noEmit mongodb.d.ts && tsd",
123+
"check:search-indexes": "nyc mocha --config test/mocha_mongodb.json test/manual/search-index-management.spec.test.ts",
123124
"check:test": "mocha --config test/mocha_mongodb.json test/integration",
124125
"check:unit": "mocha test/unit",
125126
"check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",

src/admin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class Admin {
7575
*/
7676
async command(command: Document, options?: RunCommandOptions): Promise<Document> {
7777
return executeOperation(
78-
this.s.db.s.client,
78+
this.s.db.client,
7979
new RunCommandOperation(this.s.db, command, { dbName: 'admin', ...options })
8080
);
8181
}
@@ -138,7 +138,7 @@ export class Admin {
138138
: undefined;
139139
const password = typeof passwordOrOptions === 'string' ? passwordOrOptions : undefined;
140140
return executeOperation(
141-
this.s.db.s.client,
141+
this.s.db.client,
142142
new AddUserOperation(this.s.db, username, password, { dbName: 'admin', ...options })
143143
);
144144
}
@@ -151,7 +151,7 @@ export class Admin {
151151
*/
152152
async removeUser(username: string, options?: RemoveUserOptions): Promise<boolean> {
153153
return executeOperation(
154-
this.s.db.s.client,
154+
this.s.db.client,
155155
new RemoveUserOperation(this.s.db, username, { dbName: 'admin', ...options })
156156
);
157157
}
@@ -167,7 +167,7 @@ export class Admin {
167167
options: ValidateCollectionOptions = {}
168168
): Promise<Document> {
169169
return executeOperation(
170-
this.s.db.s.client,
170+
this.s.db.client,
171171
new ValidateCollectionOperation(this, collectionName, options)
172172
);
173173
}
@@ -178,7 +178,7 @@ export class Admin {
178178
* @param options - Optional settings for the command
179179
*/
180180
async listDatabases(options?: ListDatabasesOptions): Promise<ListDatabasesResult> {
181-
return executeOperation(this.s.db.s.client, new ListDatabasesOperation(this.s.db, options));
181+
return executeOperation(this.s.db.client, new ListDatabasesOperation(this.s.db, options));
182182
}
183183

184184
/**

src/bulk/common.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,19 +597,19 @@ function executeCommands(
597597
try {
598598
if (isInsertBatch(batch)) {
599599
executeOperation(
600-
bulkOperation.s.collection.s.db.s.client,
600+
bulkOperation.s.collection.client,
601601
new InsertOperation(bulkOperation.s.namespace, batch.operations, finalOptions),
602602
resultHandler
603603
);
604604
} else if (isUpdateBatch(batch)) {
605605
executeOperation(
606-
bulkOperation.s.collection.s.db.s.client,
606+
bulkOperation.s.collection.client,
607607
new UpdateOperation(bulkOperation.s.namespace, batch.operations, finalOptions),
608608
resultHandler
609609
);
610610
} else if (isDeleteBatch(batch)) {
611611
executeOperation(
612-
bulkOperation.s.collection.s.db.s.client,
612+
bulkOperation.s.collection.client,
613613
new DeleteOperation(bulkOperation.s.namespace, batch.operations, finalOptions),
614614
resultHandler
615615
);
@@ -1222,7 +1222,7 @@ export abstract class BulkOperationBase {
12221222
const finalOptions = { ...this.s.options, ...options };
12231223
const operation = new BulkWriteShimOperation(this, finalOptions);
12241224

1225-
return executeOperation(this.s.collection.s.db.s.client, operation);
1225+
return executeOperation(this.s.collection.client, operation);
12261226
}
12271227

12281228
/**

src/change_stream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ export class ChangeStream<
818818
this.type === CHANGE_DOMAIN_TYPES.CLUSTER
819819
? (this.parent as MongoClient)
820820
: this.type === CHANGE_DOMAIN_TYPES.DATABASE
821-
? (this.parent as Db).s.client
821+
? (this.parent as Db).client
822822
: this.type === CHANGE_DOMAIN_TYPES.COLLECTION
823-
? (this.parent as Collection).s.db.s.client
823+
? (this.parent as Collection).client
824824
: null;
825825

826826
if (client == null) {

0 commit comments

Comments
 (0)