diff options
author | Geert Bosch <geert@mongodb.com> | 2017-04-18 17:08:10 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2017-04-21 14:00:16 -0400 |
commit | 99531b4db7b7bda1ac2558db1786905d36c82d29 (patch) | |
tree | df59224d87ec2fb4c12c142e24870dfae321c49b /jstests/noPassthrough/atomic_rename_collection.js | |
parent | ab0fc1ebb4df846367d409e0223a085e0db1b98e (diff) | |
download | mongo-99531b4db7b7bda1ac2558db1786905d36c82d29.tar.gz |
SERVER-27989 Implement new oplog format with collection UUIDs
Diffstat (limited to 'jstests/noPassthrough/atomic_rename_collection.js')
-rw-r--r-- | jstests/noPassthrough/atomic_rename_collection.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/jstests/noPassthrough/atomic_rename_collection.js b/jstests/noPassthrough/atomic_rename_collection.js new file mode 100644 index 00000000000..8a1b5526a91 --- /dev/null +++ b/jstests/noPassthrough/atomic_rename_collection.js @@ -0,0 +1,33 @@ +(function() { + // SERVER-28285 When renameCollection drops the target collection, it should just generate + // a single oplog entry, so we cannot end up in a state where the drop has succeeded, but + // the rename didn't. + let rs = new ReplSetTest({nodes: 1}); + rs.startSet(); + rs.initiate(); + + let prim = rs.getPrimary(); + let first = prim.getDB("first"); + let second = prim.getDB("second"); + let local = prim.getDB("local"); + + // Test both for rename within a database as across databases. + [{source: first.x, target: first.y}, {source: first.x, target: second.x}].forEach((test) => { + test.source.drop(); + assert.writeOK(test.source.insert({})); + assert.writeOK(test.target.insert({})); + + let ts = local.oplog.rs.find().sort({$natural: -1}).limit(1).next().ts; + let cmd = { + renameCollection: test.source.toString(), + to: test.target.toString(), + dropTarget: true + }; + assert.commandWorked(local.adminCommand(cmd), tojson(cmd)); + ops = local.oplog.rs.find({ts: {$gt: ts}}).sort({$natural: 1}).toArray(); + assert.eq( + ops.length, + 1, + "renameCollection was supposed to only generate a single oplog entry: " + tojson(ops)); + }); +})(); |