From b6abb408c175b4311ef65ee18da3c15f236bd3fa Mon Sep 17 00:00:00 2001 From: Kaloian Manassiev Date: Wed, 15 Jun 2016 17:14:53 -0400 Subject: SERVER-24603 Re-enable auth tests in 'sharding_last_stable_mongos' This change makes auth tests with 3.2 mongos, which need to control the balancer state to go through a special control mongos instance running version 3.4. This reverts commit bfde0ecb1ca31c35a37f90a7706987acc0c217f7. --- jstests/sharding/authCommands.js | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'jstests/sharding/authCommands.js') diff --git a/jstests/sharding/authCommands.js b/jstests/sharding/authCommands.js index deb6512a6b0..ba015c556af 100644 --- a/jstests/sharding/authCommands.js +++ b/jstests/sharding/authCommands.js @@ -1,15 +1,17 @@ /** * This tests using DB commands with authentication enabled when sharded. */ -var doTest = function() { +(function() { + 'use strict'; - var rsOpts = {oplogSize: 10, useHostname: false}; var st = new ShardingTest({ - keyFile: 'jstests/libs/key1', shards: 2, - chunkSize: 2, - rs: rsOpts, - other: {useHostname: false}, + rs: {oplogSize: 10, useHostname: false}, + other: { + keyFile: 'jstests/libs/key1', + useHostname: false, + chunkSize: 2, + }, }); var mongos = st.s; @@ -35,7 +37,7 @@ var doTest = function() { testDB.createUser({user: rwUser, pwd: password, roles: jsTest.basicUserRoles}); testDB.createUser({user: roUser, pwd: password, roles: jsTest.readOnlyUserRoles}); - authenticatedConn = new Mongo(mongos.host); + var authenticatedConn = new Mongo(mongos.host); authenticatedConn.getDB('admin').auth(rwUser, password); // Add user to shards to prevent localhost connections from having automatic full access @@ -85,6 +87,7 @@ var doTest = function() { var map = function() { emit(this.i, this.j); }; + var reduce = function(key, values) { var jCount = 0; values.forEach(function(j) { @@ -96,7 +99,7 @@ var doTest = function() { var checkCommandSucceeded = function(db, cmdObj) { print("Running command that should succeed: "); printjson(cmdObj); - resultObj = db.runCommand(cmdObj); + var resultObj = db.runCommand(cmdObj); printjson(resultObj); assert(resultObj.ok); return resultObj; @@ -105,7 +108,7 @@ var doTest = function() { var checkCommandFailed = function(db, cmdObj) { print("Running command that should fail: "); printjson(cmdObj); - resultObj = db.runCommand(cmdObj); + var resultObj = db.runCommand(cmdObj); printjson(resultObj); assert(!resultObj.ok); return resultObj; @@ -154,7 +157,7 @@ var doTest = function() { if (hasWriteAuth) { print("Checking write operations, should work"); testDB.foo.insert({a: 1, i: 1, j: 1}); - res = checkCommandSucceeded( + var res = checkCommandSucceeded( testDB, {findAndModify: "foo", query: {a: 1, i: 1, j: 1}, update: {$set: {b: 1}}}); assert.eq(1, res.value.a); assert.eq(null, res.value.b); @@ -187,11 +190,11 @@ var doTest = function() { {mapreduce: 'foo', map: map, reduce: reduce, out: 'mrOutput'}); checkCommandFailed(testDB, {drop: 'foo'}); checkCommandFailed(testDB, {dropDatabase: 1}); - passed = true; + var passed = true; try { // For some reason when create fails it throws an exception instead of just // returning ok:0 - res = testDB.runCommand({create: 'baz'}); + var res = testDB.runCommand({create: 'baz'}); if (!res.ok) { passed = false; } @@ -213,7 +216,7 @@ var doTest = function() { checkCommandSucceeded(adminDB, {isdbgrid: 1}); checkCommandSucceeded(adminDB, {ismaster: 1}); checkCommandSucceeded(adminDB, {split: 'test.foo', find: {i: 1, j: 1}}); - chunk = configDB.chunks.findOne({shard: st.rs0.name}); + var chunk = configDB.chunks.findOne({shard: st.rs0.name}); checkCommandSucceeded( adminDB, {moveChunk: 'test.foo', find: chunk.min, to: st.rs1.name, _waitForDelete: true}); @@ -226,7 +229,7 @@ var doTest = function() { checkCommandSucceeded(adminDB, {isdbgrid: 1}); checkCommandSucceeded(adminDB, {ismaster: 1}); checkCommandFailed(adminDB, {split: 'test.foo', find: {i: 1, j: 1}}); - chunkKey = {i: {$minKey: 1}, j: {$minKey: 1}}; + var chunkKey = {i: {$minKey: 1}, j: {$minKey: 1}}; checkCommandFailed( adminDB, {moveChunk: 'test.foo', find: chunkKey, to: st.rs1.name, _waitForDelete: true}); @@ -239,7 +242,7 @@ var doTest = function() { checkCommandSucceeded(adminDB, {removeshard: st.rs1.name}); // Wait for shard to be completely removed checkRemoveShard = function() { - res = checkCommandSucceeded(adminDB, {removeshard: st.rs1.name}); + var res = checkCommandSucceeded(adminDB, {removeshard: st.rs1.name}); return res.msg == 'removeshard completed successfully'; }; assert.soon(checkRemoveShard, "failed to remove shard"); @@ -297,6 +300,4 @@ var doTest = function() { st.printShardingStatus(); st.stop(); -}; - -doTest(); +})(); -- cgit v1.2.1