diff options
author | Randolph Tan <randolph@10gen.com> | 2015-11-06 15:48:10 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2015-11-10 13:14:56 -0500 |
commit | 628cac98ba23741e6ec8fb9b0c5cb1d06a267517 (patch) | |
tree | 6b98c052e21ce963b7722ae034d92383d7ae4a25 /jstests | |
parent | 4e737bb1cce71238361c91ab82e8c289b24073a7 (diff) | |
download | mongo-628cac98ba23741e6ec8fb9b0c5cb1d06a267517.tar.gz |
SERVER-21222 minOpTime recovery should only be written if the config server is replica set
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/min_optime_recovery.js | 32 | ||||
-rw-r--r-- | jstests/sharding/sharding_state_after_stepdown.js | 16 |
2 files changed, 43 insertions, 5 deletions
diff --git a/jstests/sharding/min_optime_recovery.js b/jstests/sharding/min_optime_recovery.js new file mode 100644 index 00000000000..c0237bfa99c --- /dev/null +++ b/jstests/sharding/min_optime_recovery.js @@ -0,0 +1,32 @@ +/** + * Tests that the minOpTimeRecovery document will be created after a migration only + * if the config server is a replica set. + */ +(function() { +"use strict"; + +var st = new ShardingTest({ shards: 2 }); + +var testDB = st.s.getDB('test'); +testDB.adminCommand({ enableSharding: 'test' }); +st.ensurePrimaryShard('test', 'shard0000'); +testDB.adminCommand({ shardCollection: 'test.user', key: { x: 1 }}); +testDB.adminCommand({ moveChunk: 'test.user', find: { x: 0 }, to: 'shard0001' }); + +var shardAdmin = st.d0.getDB('admin'); +var doc = shardAdmin.system.version.findOne(); + +if (st.configRS) { + assert.neq(null, doc); + assert.eq('minOpTimeRecovery', doc._id); + assert.eq(st.configRS.getURL(), doc.configsvrConnectionString); + assert.eq('shard0000', doc.shardName); + assert.gt(doc.minOpTime.ts.getTime(), 0); +} +else { + assert.eq(null, doc); +} + +st.stop(); + +})(); diff --git a/jstests/sharding/sharding_state_after_stepdown.js b/jstests/sharding/sharding_state_after_stepdown.js index 07a0eb45109..a050be71eea 100644 --- a/jstests/sharding/sharding_state_after_stepdown.js +++ b/jstests/sharding/sharding_state_after_stepdown.js @@ -50,11 +50,17 @@ var restartPrimaries = function() { restartPrimaries(); // Sharding data gets initialized either when shards are hit by an unsharded query or if some -// metadata operation was run before the step down, which wrote a minOpTime recovery record. In -// this case we did a moveChunk above from shard0 to shard1, so we will have this record on -// shard0. -assert.neq("", - st.rs0.getPrimary().adminCommand({ getShardVersion : coll.toString() }).configServer); +// metadata operation was run before the step down, which wrote a minOpTime recovery record (CSRS +// only). In this case we did a moveChunk above from shard0 to shard1, so we will have this record +// on shard0. +if (st.configRS) { + assert.neq("", + st.rs0.getPrimary().adminCommand({ getShardVersion: coll.toString() }).configServer); +} +else { + assert.eq("", + st.rs0.getPrimary().adminCommand({ getShardVersion: coll.toString() }).configServer); +} assert.eq("", st.rs1.getPrimary().adminCommand({ getShardVersion : coll.toString() }).configServer); |