diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-07-25 19:32:22 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-08-01 13:19:05 -0400 |
commit | dd29b01f81bfc394509eedefaa0a524cd33fbbb1 (patch) | |
tree | 67733846bc980974ee15637f334151fafddb64c1 /jstests/replsets | |
parent | 19c0b59c3a5d6e5d2d7177cf4e9c83713c93cd68 (diff) | |
download | mongo-dd29b01f81bfc394509eedefaa0a524cd33fbbb1.tar.gz |
SERVER-42441 renameCollectionForApplyOps should always rename the target out of the way if it exists
Diffstat (limited to 'jstests/replsets')
-rw-r--r-- | jstests/replsets/apply_ops_idempotency.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/jstests/replsets/apply_ops_idempotency.js b/jstests/replsets/apply_ops_idempotency.js index 1a3167bdbde..16761c27bee 100644 --- a/jstests/replsets/apply_ops_idempotency.js +++ b/jstests/replsets/apply_ops_idempotency.js @@ -144,6 +144,29 @@ var tests = { mydb.adminCommand({renameCollection: z.getFullName(), to: y.getFullName()})); return [mydb, otherdb]; }, + renameCollectionAcrossDatabasesWithDropAndConvertToCapped: (db1) => { + let db2 = db1.getSiblingDB(db1 + '_'); + assert.commandWorked(db1.createCollection("a")); + assert.commandWorked(db1.createCollection("b")); + assert.commandWorked(db2.createCollection("c")); + assert.commandWorked(db2.createCollection("d")); + let [a, b] = getCollections(db1, ['a', 'b']); + let [c, d] = getCollections(db2, ['c', 'd']); + + assert.commandWorked(db1.adminCommand( + {renameCollection: a.getFullName(), to: c.getFullName(), dropTarget: true})); + + assert(d.drop()); + + assert.commandWorked(db1.adminCommand( + {renameCollection: c.getFullName(), to: d.getFullName(), dropTarget: false})); + + assert.commandWorked(db1.adminCommand( + {renameCollection: b.getFullName(), to: c.getFullName(), dropTarget: false})); + assert.commandWorked(db2.runCommand({convertToCapped: "d", size: 1000})); + + return [db1, db2]; + }, createIndex: (mydb) => { let [x, y] = getCollections(mydb, ['x', 'y']); assert.commandWorked(x.createIndex({x: 1})); |