1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/**
* Tests to make sure that the mongos does not allow certain commands on the config and admin
* databases when configShard is enabled.
*
* @tags: [requires_fcv_70, featureFlagCatalogShard, featureFlagTransitionToCatalogShard]
*/
(function() {
"use strict";
var st = new ShardingTest({mongos: 1, shards: 1, config: 1, configShard: true});
let mongosAdminDB = st.s0.getDB("admin");
let mongosConfigDB = st.s0.getDB("config");
let configSvrAdminDB = st.config0.getDB("admin");
let configSvrConfigDB = st.config0.getDB("config");
// Create a role so that the admin.system.roles collection exists for the tests
var cmdObj = {createRole: "customRole", roles: [], privileges: []};
var res = mongosAdminDB.runCommand(cmdObj);
assert.commandWorked(res);
// Commands that should fail when run on collections in the config database when
// configShard is enabled
{
assert.commandFailedWithCode(
mongosAdminDB.runCommand({renameCollection: "config.shards", to: "config.joe"}),
ErrorCodes.IllegalOperation);
assert.commandFailedWithCode(mongosConfigDB.runCommand({drop: "shards"}),
ErrorCodes.IllegalOperation);
assert.commandFailedWithCode(
mongosConfigDB.runCommand(
{aggregate: "shards", pipeline: [{$out: "shards"}], cursor: {}, writeConcern: {w: 1}}),
31321);
assert.commandFailedWithCode(
mongosAdminDB.adminCommand(
{reshardCollection: "config.system.sessions", key: {uid: 1}, numInitialChunks: 2}),
ErrorCodes.IllegalOperation);
}
// Commands that should fail when run on collections in the admin database when
// configShard is enabled
{
assert.commandFailedWithCode(
mongosAdminDB.runCommand({renameCollection: "admin.system.roles", to: "admin.joe"}),
ErrorCodes.IllegalOperation);
assert.commandFailedWithCode(mongosAdminDB.runCommand({drop: "system.healthLog"}),
ErrorCodes.IllegalOperation);
assert.commandFailedWithCode(mongosAdminDB.runCommand({
aggregate: "system.roles",
pipeline: [{$out: "system.roles"}],
cursor: {},
writeConcern: {w: 1}
}),
17385);
assert.commandFailedWithCode(
mongosAdminDB.adminCommand(
{reshardCollection: "admin.system.roles", key: {uid: 1}, numInitialChunks: 2}),
ErrorCodes.NamespaceNotSharded);
}
// Mongos commands on the config database that previously failed that should still fail when run
// directly on the config server
{
assert.commandFailedWithCode(
configSvrConfigDB.runCommand(
{aggregate: "shards", pipeline: [{$out: "shards"}], cursor: {}, writeConcern: {w: 1}}),
31321);
}
// Mongos commands on the config database that previoulsy failed that should succeed when run
// directly on the config server
{
assert.commandWorked(
configSvrAdminDB.runCommand({renameCollection: "config.shards", to: "config.joe"}));
assert.commandWorked(
configSvrAdminDB.runCommand({renameCollection: "config.joe", to: "config.shards"}));
assert.commandWorked(configSvrConfigDB.runCommand({drop: "shards"}));
}
// Mongos commands on the admin database that previously failed that should still fail when run
// directly on the config server
{
assert.commandFailedWithCode(configSvrAdminDB.runCommand({
aggregate: "system.roles",
pipeline: [{$out: "system.roles"}],
cursor: {},
writeConcern: {w: 1}
}),
17385);
}
// Mongos commands on the admin database that previously failed that should succeed when run
// directly on the config server.
// Note: renameCollection and drop will still fail for certain collections in the admin databases.
{
assert.commandWorked(
configSvrAdminDB.runCommand({renameCollection: "admin.system.roles", to: "admin.joe"}));
assert.commandWorked(
configSvrAdminDB.runCommand({renameCollection: "admin.joe", to: "admin.system.roles"}));
assert.commandWorked(configSvrAdminDB.runCommand({drop: "system.healthLog"}));
}
// TODO SERVER-74570: Enable parallel shutdown
st.stop({parallelSupported: false});
})();
|