summaryrefslogtreecommitdiff
path: root/jstests/sharding/cursor_valid_after_shard_stepdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/cursor_valid_after_shard_stepdown.js')
-rw-r--r--jstests/sharding/cursor_valid_after_shard_stepdown.js57
1 files changed, 28 insertions, 29 deletions
diff --git a/jstests/sharding/cursor_valid_after_shard_stepdown.js b/jstests/sharding/cursor_valid_after_shard_stepdown.js
index b717d73cac8..c26de68b8c6 100644
--- a/jstests/sharding/cursor_valid_after_shard_stepdown.js
+++ b/jstests/sharding/cursor_valid_after_shard_stepdown.js
@@ -4,43 +4,42 @@
TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
(function() {
- 'use strict';
+'use strict';
- var st = new ShardingTest({shards: 1, rs: {nodes: 2}});
+var st = new ShardingTest({shards: 1, rs: {nodes: 2}});
- assert.commandWorked(st.s0.adminCommand({enablesharding: 'TestDB'}));
- st.ensurePrimaryShard('TestDB', st.shard0.shardName);
- assert.commandWorked(st.s0.adminCommand({shardcollection: 'TestDB.TestColl', key: {x: 1}}));
+assert.commandWorked(st.s0.adminCommand({enablesharding: 'TestDB'}));
+st.ensurePrimaryShard('TestDB', st.shard0.shardName);
+assert.commandWorked(st.s0.adminCommand({shardcollection: 'TestDB.TestColl', key: {x: 1}}));
- var db = st.s0.getDB('TestDB');
- var coll = db.TestColl;
+var db = st.s0.getDB('TestDB');
+var coll = db.TestColl;
- // Insert documents for the test
- assert.writeOK(coll.insert({x: 1, value: 'Test value 1'}));
- assert.writeOK(coll.insert({x: 2, value: 'Test value 2'}));
+// Insert documents for the test
+assert.writeOK(coll.insert({x: 1, value: 'Test value 1'}));
+assert.writeOK(coll.insert({x: 2, value: 'Test value 2'}));
- // Establish a cursor on the primary (by not using slaveOk read)
- var findCursor = assert.commandWorked(db.runCommand({find: 'TestColl', batchSize: 1})).cursor;
+// Establish a cursor on the primary (by not using slaveOk read)
+var findCursor = assert.commandWorked(db.runCommand({find: 'TestColl', batchSize: 1})).cursor;
- var shardVersionBeforeStepdown =
- assert.commandWorked(st.rs0.getPrimary().adminCommand({getShardVersion: 'TestDB.TestColl'}))
- .global;
- assert.neq(Timestamp(0, 0), shardVersionBeforeStepdown);
+var shardVersionBeforeStepdown =
+ assert.commandWorked(st.rs0.getPrimary().adminCommand({getShardVersion: 'TestDB.TestColl'}))
+ .global;
+assert.neq(Timestamp(0, 0), shardVersionBeforeStepdown);
- // Stepdown the primary of the shard and ensure that that cursor can still be read
- assert.commandWorked(st.rs0.getPrimary().adminCommand({replSetStepDown: 60, force: 1}));
+// Stepdown the primary of the shard and ensure that that cursor can still be read
+assert.commandWorked(st.rs0.getPrimary().adminCommand({replSetStepDown: 60, force: 1}));
- var getMoreCursor =
- assert.commandWorked(db.runCommand({getMore: findCursor.id, collection: 'TestColl'}))
- .cursor;
- assert.eq(0, getMoreCursor.id);
- assert.eq(2, getMoreCursor.nextBatch[0].x);
+var getMoreCursor =
+ assert.commandWorked(db.runCommand({getMore: findCursor.id, collection: 'TestColl'})).cursor;
+assert.eq(0, getMoreCursor.id);
+assert.eq(2, getMoreCursor.nextBatch[0].x);
- // After stepdown, the shard version will be reset
- var shardVersionAfterStepdown =
- assert.commandWorked(st.rs0.getPrimary().adminCommand({getShardVersion: 'TestDB.TestColl'}))
- .global;
- assert.eq("UNKNOWN", shardVersionAfterStepdown);
+// After stepdown, the shard version will be reset
+var shardVersionAfterStepdown =
+ assert.commandWorked(st.rs0.getPrimary().adminCommand({getShardVersion: 'TestDB.TestColl'}))
+ .global;
+assert.eq("UNKNOWN", shardVersionAfterStepdown);
- st.stop();
+st.stop();
})();