-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy pathcluster_parameter_op_observer_serverless.js
52 lines (44 loc) · 1.63 KB
/
cluster_parameter_op_observer_serverless.js
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
/**
* Test that ClusterServerParameterOpObserver fires appropriately on serverless replsets.
* @tags: [
* does_not_support_stepdowns,
* requires_replication,
* requires_fcv_71,
* serverless
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
import {
ChangeStreamMultitenantReplicaSetTest
} from "jstests/serverless/libs/change_collection_util.js";
const getTenantConnection = ChangeStreamMultitenantReplicaSetTest.getTenantConnection;
const tenantId = ObjectId();
function runTest(conn) {
const tenantConn = getTenantConnection(conn.host, tenantId);
let i = 0;
for (let myConn of [conn, tenantConn]) {
const myConnConfig = myConn.getDB('config');
// With given connection, insert into this tenant's cluster parameter collection. Should
// fail since this is an invalid parameter.
const res = myConnConfig.clusterParameters.insert(
{_id: 'foo_' + i, clusterParameterTime: Date(), value: 123});
assert(res.hasWriteError());
assert.neq(res.getWriteError().length, 0);
i += 1;
}
}
const rst = new ReplSetTest({nodes: 3});
rst.startSet({
setParameter: {
multitenancySupport: true,
featureFlagRequireTenantID: true,
featureFlagSecurityToken: true,
testOnlyValidatedTenancyScopeKey: ChangeStreamMultitenantReplicaSetTest.getTokenKey(),
}
});
rst.initiate();
// Create a root user within the multitenant environment so that getTenantConnection works.
assert.commandWorked(
rst.getPrimary().getDB("admin").runCommand({createUser: "root", pwd: "pwd", roles: ["root"]}));
runTest(rst.getPrimary());
rst.stopSet();