blob: 11d6d8a925b7d08b510411b7ada450e0d15b1149 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// Perform a set number of renames from collA to collB and vice versa. This function is to be called
// from a parallel shell, and is useful for simulating executions of functions concurrently with
// collection renames.
function doRenames(dbName, collName, otherName) {
const repeatRename = 200;
// Signal to the parent shell that the parallel shell has started.
assert.commandWorked(db.await_data.insert({_id: "signal parent shell"}));
let renameDB = db.getSiblingDB(dbName);
for (let i = 0; i < repeatRename; i++) {
// Rename the collection back and forth.
assert.commandWorked(renameDB[collName].renameCollection(otherName));
assert.commandWorked(renameDB[otherName].renameCollection(collName));
}
// Signal to the parent shell that the renames have completed.
assert.commandWorked(db.await_data.insert({_id: "rename has ended"}));
}
|