blob: 6b61bd12a682eaaae2ac455fac413622368523d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// Ensure that a call to createIndexes in a sharded cluster will route to the primary, even when
// setSecondaryOk() is set to true.
(function() {
'use strict';
let st = new ShardingTest({shards: {rs0: {nodes: 2}}});
const testDBName = jsTestName();
const collName = 'coll';
const testDB = st.s.getDB(testDBName);
assert.commandWorked(testDB.adminCommand({enableSharding: testDBName}));
assert.commandWorked(
testDB.adminCommand({shardCollection: testDB[collName].getFullName(), key: {x: 1}}));
st.s.setSecondaryOk();
assert.commandWorked(
testDB.runCommand({createIndexes: collName, indexes: [{key: {a: 1}, name: "index"}]}));
st.stop();
})();
|