summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2023-02-03 18:01:23 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-09 04:53:28 +0000
commitbd66bc3e48a387f3388696cf75875fc64f564159 (patch)
treece0c56bd0502a818956b068278ec16113e4477ec
parent49b873dd916e94c03aaedd078e86a15ed271fa38 (diff)
downloadmongo-bd66bc3e48a387f3388696cf75875fc64f564159.tar.gz
SERVER-73273 Implement the search index commands
-rw-r--r--jstests/auth/lib/commands_lib.js31
-rw-r--r--jstests/core/views/views_all_commands.js4
-rw-r--r--jstests/replsets/all_commands_downgrading_to_upgraded.js8
-rw-r--r--jstests/replsets/db_reads_while_recovering_all_commands.js4
-rw-r--r--jstests/sharding/libs/last_lts_mongod_commands.js4
-rw-r--r--jstests/sharding/read_write_concern_defaults_application.js4
-rw-r--r--jstests/sharding/safe_secondary_reads_drop_recreate.js4
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js4
-rw-r--r--jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js4
-rw-r--r--src/mongo/db/auth/action_type.idl16
-rw-r--r--src/mongo/db/auth/builtin_roles.yml12
11 files changed, 55 insertions, 40 deletions
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js
index 2f5e8f8e4f7..915c84472b6 100644
--- a/jstests/auth/lib/commands_lib.js
+++ b/jstests/auth/lib/commands_lib.js
@@ -3650,8 +3650,11 @@ export const authCommandsLib = {
}]
},
{
- testname: "createSearchIndex",
- command: {createSearchIndex: "x", indexDefinition: {"testBlob": "blob"}},
+ testname: "createSearchIndexes",
+ command: {
+ createSearchIndexes: "x",
+ indexes: [{'definition': {'mappings': {'dynamic': true}}}],
+ },
// Only enterprise knows of this command.
skipTest: (conn) => {
return !getBuildInfo().modules.includes("enterprise");
@@ -3670,7 +3673,8 @@ export const authCommandsLib = {
__system: 1
}),
privileges:
- [{resource: {db: firstDbName, collection: "x"}, actions: ["createSearchIndex"]}],
+ [{resource: {db: firstDbName, collection: "x"}, actions: ["createSearchIndexes"]}],
+ expectFail: true,
}]
},
{
@@ -4032,7 +4036,10 @@ export const authCommandsLib = {
},
{
testname: "dropSearchIndex",
- command: {dropSearchIndex: "x", indexDefinition: {"testBlob": "blob"}},
+ command: {
+ dropSearchIndex: "x",
+ name: 'indexName',
+ },
// Only enterprise knows of this command.
skipTest: (conn) => {
return !getBuildInfo().modules.includes("enterprise");
@@ -4044,12 +4051,14 @@ export const authCommandsLib = {
roles: roles_writeDbAdmin,
privileges:
[{resource: {db: firstDbName, collection: "x"}, actions: ["dropSearchIndex"]}],
+ expectFail: true,
},
{
runOnDb: secondDbName,
roles: roles_writeDbAdminAny,
privileges:
[{resource: {db: secondDbName, collection: "x"}, actions: ["dropSearchIndex"]}],
+ expectFail: true,
}
]
},
@@ -5165,6 +5174,7 @@ export const authCommandsLib = {
},
privileges:
[{resource: {db: firstDbName, collection: ""}, actions: ["listSearchIndexes"]}],
+ expectFail: true,
}]
},
{
@@ -5301,8 +5311,12 @@ export const authCommandsLib = {
]
},
{
- testname: "modifySearchIndex",
- command: {modifySearchIndex: "foo", indexDefinition: {"textBlob": "blob"}},
+ testname: "updateSearchIndex",
+ command: {
+ updateSearchIndex: "foo",
+ indexID: 'index-ID-number',
+ indexDefinition: {"textBlob": "blob"},
+ },
// Only enterprise knows of this command.
skipTest: (conn) => {
return !getBuildInfo().modules.includes("enterprise");
@@ -5313,14 +5327,15 @@ export const authCommandsLib = {
runOnDb: firstDbName,
roles: Object.extend({restore: 1}, roles_dbAdmin),
privileges:
- [{resource: {db: firstDbName, collection: "foo"}, actions: ["modifySearchIndex"]}],
+ [{resource: {db: firstDbName, collection: "foo"}, actions: ["updateSearchIndex"]}],
expectFail: true,
},
{
runOnDb: secondDbName,
roles: Object.extend({restore: 1}, roles_dbAdminAny),
privileges:
- [{resource: {db: secondDbName, collection: "foo"}, actions: ["modifySearchIndex"]}],
+ [{resource: {db: secondDbName, collection: "foo"}, actions: ["updateSearchIndex"]}],
+ expectFail: true,
}
]
},
diff --git a/jstests/core/views/views_all_commands.js b/jstests/core/views/views_all_commands.js
index 442e4d9b8c4..68dda25a476 100644
--- a/jstests/core/views/views_all_commands.js
+++ b/jstests/core/views/views_all_commands.js
@@ -308,7 +308,7 @@ let viewsCommandTests = {
assert.commandWorked(conn.runCommand({dropAllRolesFromDatabase: 1}));
}
},
- createSearchIndex: {skip: isUnrelated},
+ createSearchIndexes: {skip: isUnrelated},
createUser: {
command: {createUser: "testuser", pwd: "testpass", roles: []},
setup: function(conn) {
@@ -525,7 +525,6 @@ let viewsCommandTests = {
expectFailure: true,
expectedErrorCode: ErrorCodes.NamespaceNotSharded,
},
- modifySearchIndex: {skip: isUnrelated},
moveChunk: {
command: {moveChunk: "test.view", find: {}, to: "a"},
skipStandalone: true,
@@ -721,6 +720,7 @@ let viewsCommandTests = {
assert.commandWorked(conn.runCommand({dropAllRolesFromDatabase: 1}));
}
},
+ updateSearchIndex: {skip: isUnrelated},
updateUser: {skip: isUnrelated},
updateZoneKeyRange: {skip: isUnrelated},
usersInfo: {skip: isUnrelated},
diff --git a/jstests/replsets/all_commands_downgrading_to_upgraded.js b/jstests/replsets/all_commands_downgrading_to_upgraded.js
index 79008dbc764..7cf836912af 100644
--- a/jstests/replsets/all_commands_downgrading_to_upgraded.js
+++ b/jstests/replsets/all_commands_downgrading_to_upgraded.js
@@ -470,7 +470,7 @@ const allCommands = {
assert.commandWorked(conn.getDB(dbName).runCommand({dropRole: "foo"}));
}
},
- createSearchIndex: {
+ createSearchIndexes: {
skip: isNotImplementedYet,
},
createUser: {
@@ -906,9 +906,6 @@ const allCommands = {
// },
// command: {mergeChunks: fullNs, bounds: [{_id: MinKey}, {_id: MaxKey}]}
},
- modifySearchIndex: {
- skip: isNotImplementedYet,
- },
moveChunk: {
skip: isNotImplementedYet,
isShardedOnly: true,
@@ -1174,6 +1171,9 @@ const allCommands = {
assert.commandWorked(conn.getDB(dbName).runCommand({dropRole: "foo"}));
}
},
+ updateSearchIndex: {
+ skip: isNotImplementedYet,
+ },
updateUser: {
setUp: function(conn) {
assert.commandWorked(
diff --git a/jstests/replsets/db_reads_while_recovering_all_commands.js b/jstests/replsets/db_reads_while_recovering_all_commands.js
index f14bbcd6b09..3ec85e7cb93 100644
--- a/jstests/replsets/db_reads_while_recovering_all_commands.js
+++ b/jstests/replsets/db_reads_while_recovering_all_commands.js
@@ -193,7 +193,7 @@ const allCommands = {
create: {skip: isPrimaryOnly},
createIndexes: {skip: isPrimaryOnly},
createRole: {skip: isPrimaryOnly},
- createSearchIndex: {skip: isNotAUserDataRead},
+ createSearchIndexes: {skip: isNotAUserDataRead},
createUser: {skip: isPrimaryOnly},
currentOp: {skip: isNotAUserDataRead},
dataSize: {
@@ -330,7 +330,6 @@ const allCommands = {
},
mergeAllChunksOnShard: {skip: "primary only"},
mergeChunks: {skip: isPrimaryOnly},
- modifySearchIndex: {skip: isNotAUserDataRead},
moveChunk: {skip: isPrimaryOnly},
moveRange: {skip: isPrimaryOnly},
oidcListKeys: {skip: isNotAUserDataRead},
@@ -408,6 +407,7 @@ const allCommands = {
top: {skip: isNotAUserDataRead},
update: {skip: isPrimaryOnly},
updateRole: {skip: isPrimaryOnly},
+ updateSearchIndex: {skip: isNotAUserDataRead},
updateUser: {skip: isPrimaryOnly},
usersInfo: {skip: isPrimaryOnly},
validate: {skip: isNotAUserDataRead},
diff --git a/jstests/sharding/libs/last_lts_mongod_commands.js b/jstests/sharding/libs/last_lts_mongod_commands.js
index 51a2f3cf986..bba921f0e1e 100644
--- a/jstests/sharding/libs/last_lts_mongod_commands.js
+++ b/jstests/sharding/libs/last_lts_mongod_commands.js
@@ -28,17 +28,17 @@ const commandsAddedToMongodSinceLastLTS = [
"clusterInsert",
"clusterUpdate",
"configureQueryAnalyzer", // TODO (SERVER-68977): Remove upgrade/downgrade for PM-1858.
- "createSearchIndex", // TODO (SERVER-73309): Remove once 7.0 becomes last LTS.
+ "createSearchIndexes", // TODO (SERVER-73309): Remove once 7.0 becomes last LTS.
"dropSearchIndex", // TODO (SERVER-73309): Remove once 7.0 becomes last LTS.
"getChangeStreamState",
"getClusterParameter",
"listDatabasesForAllTenants",
"listSearchIndexes", // TODO (SERVER-73309): Remove once 7.0 becomes last LTS.
- "modifySearchIndex", // TODO (SERVER-73309): Remove once 7.0 becomes last LTS.
"oidcListKeys",
"oidcRefreshKeys",
"rotateCertificates",
"setChangeStreamState",
"setClusterParameter",
"setUserWriteBlockMode",
+ "updateSearchIndex", // TODO (SERVER-73309): Remove once 7.0 becomes last LTS.
];
diff --git a/jstests/sharding/read_write_concern_defaults_application.js b/jstests/sharding/read_write_concern_defaults_application.js
index 508727be778..00b3c069317 100644
--- a/jstests/sharding/read_write_concern_defaults_application.js
+++ b/jstests/sharding/read_write_concern_defaults_application.js
@@ -351,7 +351,7 @@ let testCases = {
shardedTargetsConfigServer: true,
useLogs: true,
},
- createSearchIndex: {skip: "does not accept read or write concern"},
+ createSearchIndexes: {skip: "does not accept read or write concern"},
createUser: {
command: {createUser: "foo", pwd: "bar", roles: []},
checkReadConcern: false,
@@ -580,7 +580,6 @@ let testCases = {
mapReduce: {skip: "does not accept read or write concern"},
mergeAllChunksOnShard: {skip: "does not accept read or write concern"},
mergeChunks: {skip: "does not accept read or write concern"},
- modifySearchIndex: {skip: "does not accept read or write concern"},
moveChunk: {
skip:
"does not accept read or write concern (accepts writeConcern, but only explicitly and when _secondaryThrottle is true)"
@@ -755,6 +754,7 @@ let testCases = {
shardedTargetsConfigServer: true,
useLogs: true,
},
+ updateSearchIndex: {skip: "does not accept read or write concern"},
updateUser: {
setUp: function(conn) {
assert.commandWorked(conn.getDB(db).runCommand(
diff --git a/jstests/sharding/safe_secondary_reads_drop_recreate.js b/jstests/sharding/safe_secondary_reads_drop_recreate.js
index 491029b367f..d2d417ff181 100644
--- a/jstests/sharding/safe_secondary_reads_drop_recreate.js
+++ b/jstests/sharding/safe_secondary_reads_drop_recreate.js
@@ -162,7 +162,7 @@ let testCases = {
create: {skip: "primary only"},
createIndexes: {skip: "primary only"},
createRole: {skip: "primary only"},
- createSearchIndex: {skip: "does not return user data"},
+ createSearchIndexes: {skip: "does not return user data"},
createUser: {skip: "primary only"},
currentOp: {skip: "does not return user data"},
dataSize: {skip: "does not return user data"},
@@ -276,7 +276,6 @@ let testCases = {
},
mergeAllChunksOnShard: {skip: "primary only"},
mergeChunks: {skip: "primary only"},
- modifySearchIndex: {skip: "does not return user data"},
moveChunk: {skip: "primary only"},
movePrimary: {skip: "primary only"},
moveRange: {skip: "primary only"},
@@ -359,6 +358,7 @@ let testCases = {
top: {skip: "does not return user data"},
update: {skip: "primary only"},
updateRole: {skip: "primary only"},
+ updateSearchIndex: {skip: "does not return user data"},
updateUser: {skip: "primary only"},
updateZoneKeyRange: {skip: "primary only"},
usersInfo: {skip: "primary only"},
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
index 84dcd2fe1f3..fd5d066963e 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
@@ -184,7 +184,7 @@ let testCases = {
create: {skip: "primary only"},
createIndexes: {skip: "primary only"},
createRole: {skip: "primary only"},
- createSearchIndex: {skip: "does not return user data"},
+ createSearchIndexes: {skip: "does not return user data"},
createUser: {skip: "primary only"},
currentOp: {skip: "does not return user data"},
dataSize: {skip: "does not return user data"},
@@ -347,7 +347,6 @@ let testCases = {
},
mergeAllChunksOnShard: {skip: "primary only"},
mergeChunks: {skip: "primary only"},
- modifySearchIndex: {skip: "does not return user data"},
moveChunk: {skip: "primary only"},
movePrimary: {skip: "primary only"},
moveRange: {skip: "primary only"},
@@ -430,6 +429,7 @@ let testCases = {
top: {skip: "does not return user data"},
update: {skip: "primary only"},
updateRole: {skip: "primary only"},
+ updateSearchIndex: {skip: "does not return user data"},
updateUser: {skip: "primary only"},
updateZoneKeyRange: {skip: "primary only"},
usersInfo: {skip: "primary only"},
diff --git a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
index b939e1a3121..47d079f13b7 100644
--- a/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
+++ b/jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
@@ -166,7 +166,7 @@ let testCases = {
create: {skip: "primary only"},
createIndexes: {skip: "primary only"},
createRole: {skip: "primary only"},
- createSearchIndex: {skip: "does not return user data"},
+ createSearchIndexes: {skip: "does not return user data"},
createUser: {skip: "primary only"},
currentOp: {skip: "does not return user data"},
dataSize: {skip: "does not return user data"},
@@ -283,7 +283,6 @@ let testCases = {
},
mergeAllChunksOnShard: {skip: "primary only"},
mergeChunks: {skip: "primary only"},
- modifySearchIndex: {skip: "does not return user data"},
moveChunk: {skip: "primary only"},
movePrimary: {skip: "primary only"},
moveRange: {skip: "primary only"},
@@ -366,6 +365,7 @@ let testCases = {
top: {skip: "does not return user data"},
update: {skip: "primary only"},
updateRole: {skip: "primary only"},
+ updateSearchIndex: {skip: "does not return user data"},
updateUser: {skip: "primary only"},
updateZoneKeyRange: {skip: "primary only"},
usersInfo: {skip: "primary only"},
diff --git a/src/mongo/db/auth/action_type.idl b/src/mongo/db/auth/action_type.idl
index 0dadf041703..88231dbcdb6 100644
--- a/src/mongo/db/auth/action_type.idl
+++ b/src/mongo/db/auth/action_type.idl
@@ -78,7 +78,7 @@ enums:
createDatabase : "createDatabase" # ID only
createIndex : "createIndex" # ID only
createRole : "createRole"
- createSearchIndex : "createSearchIndex"
+ createSearchIndexes : "createSearchIndexes"
createUser : "createUser"
dbCheck : "dbCheck"
dbHash : "dbHash"
@@ -133,7 +133,7 @@ enums:
listSessions : "listSessions"
listShards : "listShards"
logRotate : "logRotate"
- modifySearchIndex : "modifySearchIndex"
+ updateSearchIndex : "updateSearchIndex"
moveChunk : "moveChunk"
netstat : "netstat"
oidcListKeys : "oidcListKeys"
@@ -242,7 +242,7 @@ enums:
- convertToCapped
- createCollection
- createIndex
- - createSearchIndex
+ - createSearchIndexes
- dbCheck
- dbHash
- dbStats
@@ -259,7 +259,7 @@ enums:
- listCollections
- listIndexes
- listSearchIndexes
- - modifySearchIndex
+ - updateSearchIndex
- planCacheIndexFilter
- planCacheRead
- planCacheWrite
@@ -290,7 +290,7 @@ enums:
- convertToCapped
- createCollection
- createIndex
- - createSearchIndex
+ - createSearchIndexes
- dbCheck
- dbHash
- dbStats
@@ -307,7 +307,7 @@ enums:
- listCollections
- listIndexes
- listSearchIndexes
- - modifySearchIndex
+ - updateSearchIndex
- planCacheIndexFilter
- planCacheRead
- planCacheWrite
@@ -362,7 +362,7 @@ enums:
- convertToCapped
- createCollection
- createIndex
- - createSearchIndex
+ - createSearchIndexes
- dbCheck
- dbHash
- dbStats
@@ -380,7 +380,7 @@ enums:
- listCollections
- listIndexes
- listSearchIndexes
- - modifySearchIndex
+ - updateSearchIndex
- planCacheIndexFilter
- planCacheRead
- planCacheWrite
diff --git a/src/mongo/db/auth/builtin_roles.yml b/src/mongo/db/auth/builtin_roles.yml
index f5d56942a6f..88417791fac 100644
--- a/src/mongo/db/auth/builtin_roles.yml
+++ b/src/mongo/db/auth/builtin_roles.yml
@@ -55,7 +55,7 @@ roles:
- convertToCapped # db admin gets this also
- createCollection # db admin gets this also
- createIndex
- - createSearchIndex
+ - createSearchIndexes
- dropCollection
- dropIndex
- dropSearchIndex
@@ -100,12 +100,12 @@ roles:
- dropIndex
- dropSearchIndex
- createIndex
- - createSearchIndex
+ - createSearchIndexes
- enableProfiler
- listCollections
- listIndexes
- listSearchIndexes
- - modifySearchIndex
+ - updateSearchIndex
- planCacheIndexFilter
- planCacheRead
- planCacheWrite
@@ -185,7 +185,7 @@ roles:
actions: &readRoleAndIndexActions
- *readRoleActions
- createIndex
- - createSearchIndex
+ - createSearchIndexes
- dropIndex
- dropSearchIndex
- matchType: exact_namespace
@@ -509,10 +509,10 @@ roles:
- convertToCapped
- createCollection
- createIndex
- - createSearchIndex
+ - createSearchIndexes
- dropCollection
- insert
- - modifySearchIndex
+ - updateSearchIndex
- matchType: database
db: 'config'
actions: *restoreRoleWriteActions