diff options
Diffstat (limited to 'jstests/sharding/shard_insert_getlasterror_w2.js')
-rw-r--r-- | jstests/sharding/shard_insert_getlasterror_w2.js | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/jstests/sharding/shard_insert_getlasterror_w2.js b/jstests/sharding/shard_insert_getlasterror_w2.js index 8df1b9caa8f..09ea5b5ec46 100644 --- a/jstests/sharding/shard_insert_getlasterror_w2.js +++ b/jstests/sharding/shard_insert_getlasterror_w2.js @@ -18,11 +18,11 @@ // Spin up a sharded cluster, but do not add the shards var shardingTestConfig = { - name : baseName, - mongos : 1, - shards : 1, - rs : { nodes : replNodes }, - other : { manualAddShard : true } + name: baseName, + mongos: 1, + shards: 1, + rs: {nodes: replNodes}, + other: {manualAddShard: true} }; var shardingTest = new ShardingTest(shardingTestConfig); @@ -33,7 +33,7 @@ var testDBReplSet1 = replSet1.getPrimary().getDB(testDBName); var bulk = testDBReplSet1.foo.initializeUnorderedBulkOp(); for (var i = 0; i < numDocs; i++) { - bulk.insert({ x: i, text: textString }); + bulk.insert({x: i, text: textString}); } assert.writeOK(bulk.execute()); @@ -42,44 +42,41 @@ var testDB = mongosConn.getDB(testDBName); // Add replSet1 as only shard - mongosConn.adminCommand({ addshard : replSet1.getURL() }); + mongosConn.adminCommand({addshard: replSet1.getURL()}); // Enable sharding on test db and its collection foo - assert.commandWorked(mongosConn.getDB('admin').runCommand({ enablesharding : testDBName })); - testDB[testCollName].ensureIndex({ x : 1 }); - assert.commandWorked(mongosConn.getDB('admin'). - runCommand({ shardcollection : testDBName + '.' + testCollName, - key : { x : 1 }})); + assert.commandWorked(mongosConn.getDB('admin').runCommand({enablesharding: testDBName})); + testDB[testCollName].ensureIndex({x: 1}); + assert.commandWorked(mongosConn.getDB('admin').runCommand( + {shardcollection: testDBName + '.' + testCollName, key: {x: 1}})); // Test case where GLE should return an error - testDB.foo.insert({_id:'a', x:1}); - assert.writeError(testDB.foo.insert({ _id: 'a', x: 1 }, - { writeConcern: { w: 2, wtimeout: 30000 }})); + testDB.foo.insert({_id: 'a', x: 1}); + assert.writeError(testDB.foo.insert({_id: 'a', x: 1}, {writeConcern: {w: 2, wtimeout: 30000}})); // Add more data bulk = testDB.foo.initializeUnorderedBulkOp(); for (var i = numDocs; i < 2 * numDocs; i++) { - bulk.insert({ x: i, text: textString }); + bulk.insert({x: i, text: textString}); } - assert.writeOK(bulk.execute({ w: replNodes, wtimeout: 30000 })); + assert.writeOK(bulk.execute({w: replNodes, wtimeout: 30000})); // Take down two nodes and make sure slaveOk reads still work replSet1.stop(1); replSet1.stop(2); - testDB.getMongo().adminCommand({ setParameter : 1, logLevel : 1 }); + testDB.getMongo().adminCommand({setParameter: 1, logLevel: 1}); testDB.getMongo().setSlaveOk(); print("trying some queries"); - assert.soon(function() { try { - testDB.foo.find().next(); - } - catch(e) { - print(e); - return false; - } - return true; - }, "Queries took too long to complete correctly.", - 2 * 60 * 1000); - + assert.soon(function() { + try { + testDB.foo.find().next(); + } catch (e) { + print(e); + return false; + } + return true; + }, "Queries took too long to complete correctly.", 2 * 60 * 1000); + // Shutdown cluster shardingTest.stop(); |