diff options
author | Spencer T Brody <spencer@10gen.com> | 2011-09-14 18:03:38 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2011-09-14 18:23:33 -0400 |
commit | 19a94b8d2db9d2d028cdedba965dc4cae127a692 (patch) | |
tree | 807b222b621b6c803f947c516d5a86f63659b2c7 /jstests/replsets/reindex_secondary.js | |
parent | b88b810d28fc0060e3405702dcb492dfe9355af2 (diff) | |
download | mongo-19a94b8d2db9d2d028cdedba965dc4cae127a692.tar.gz |
Add test for reindexing on secondaries: SERVER-3866.
Diffstat (limited to 'jstests/replsets/reindex_secondary.js')
-rw-r--r-- | jstests/replsets/reindex_secondary.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jstests/replsets/reindex_secondary.js b/jstests/replsets/reindex_secondary.js new file mode 100644 index 00000000000..d0fd5d71123 --- /dev/null +++ b/jstests/replsets/reindex_secondary.js @@ -0,0 +1,34 @@ +var replTest = new ReplSetTest( {name: 'reindexTest', nodes: 2} ); + +var nodes = replTest.startSet(); + +replTest.initiate(); + +var master = replTest.getMaster(); +replTest.awaitSecondaryNodes() + +var slaves = replTest.liveNodes.slaves; +assert( slaves.length == 1, "Expected 1 slave but length was " + slaves.length ); +slave = slaves[0]; + +db = master.getDB("reindexTest"); +slaveDb = slave.getDB("reindexTest"); + +// Setup index +db.foo.insert({a:1000}); + +db.foo.ensureIndex({a:1}); + +replTest.awaitReplication(); + +assert.eq(2, db.system.indexes.count(), "Master didn't have proper indexes before reindex"); +assert.eq(2, slaveDb.system.indexes.count(), "Slave didn't have proper indexes before reindex"); + + +// Try to reindex secondary +slaveDb.foo.reIndex(); + +assert.eq(2, db.system.indexes.count(), "Master didn't have proper indexes after reindex"); +assert.eq(2, slaveDb.system.indexes.count(), "Slave didn't have proper indexes after reindex"); + +replTest.stopSet(15);
\ No newline at end of file |