diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-09-01 16:19:57 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-09-09 13:14:48 -0400 |
commit | c15f4bb96d2ee86874582d45d1865e9358168e7e (patch) | |
tree | 92c788863ae91a8b9c5801e1d536d7ef1a02ec05 /jstests/noPassthroughWithMongod | |
parent | f5e063d4785b0460ab41de8cc4b537e5e2151338 (diff) | |
download | mongo-c15f4bb96d2ee86874582d45d1865e9358168e7e.tar.gz |
SERVER-18272 Update jstests to use allocatePort() instead of hard coding ports
Diffstat (limited to 'jstests/noPassthroughWithMongod')
7 files changed, 26 insertions, 33 deletions
diff --git a/jstests/noPassthroughWithMongod/httpinterface.js b/jstests/noPassthroughWithMongod/httpinterface.js index 191a185975e..d3804cc40f1 100644 --- a/jstests/noPassthroughWithMongod/httpinterface.js +++ b/jstests/noPassthroughWithMongod/httpinterface.js @@ -1,11 +1,10 @@ // SERVER-9137 test that the httpinterface parameter enables the web interface -port = allocatePorts(1)[0]; -httpPort = port + 1000; -var conn = MongoRunner.runMongod({port: port, smallfiles: ""}); +var conn = MongoRunner.runMongod({smallfiles: ""}); +var httpPort = conn.port + 1000; tryHttp = function() { try { - var mongo = new Mongo('localhost:'+httpPort) ; + var mongo = new Mongo('localhost:' + httpPort) ; } catch (e) { return false; @@ -18,7 +17,7 @@ assert.throws(function() {assert.soon(tryHttp, "tryHttp failed, like we expected MongoRunner.stopMongod(conn); -conn = MongoRunner.runMongod({ port:port, smallfiles: "", httpinterface: ""}); +conn = MongoRunner.runMongod({port: conn.port, smallfiles: "", httpinterface: ""}); assert.soon(tryHttp, "the web interface should be running on " + httpPort); diff --git a/jstests/noPassthroughWithMongod/index_no_retry.js b/jstests/noPassthroughWithMongod/index_no_retry.js index 0264f308f16..7f7c39a235f 100644 --- a/jstests/noPassthroughWithMongod/index_no_retry.js +++ b/jstests/noPassthroughWithMongod/index_no_retry.js @@ -3,10 +3,9 @@ 'use strict'; var baseName = 'index_retry'; var dbpath = MongoRunner.dataPath + baseName; - var ports = allocatePorts(1); + var conn = MongoRunner.runMongod({ dbpath: dbpath, - port: ports[0], journal: ''}); var test = conn.getDB("test"); @@ -64,7 +63,7 @@ function abortDuringIndexBuild(options) { var createIdx = startParallelShell( 'db.' + name + '.createIndex({ a: 1 }, { background: true });', - ports[0]); + conn.port); // Wait for the index build to start. var times = 0; @@ -75,7 +74,7 @@ ); print("killing the mongod"); - MongoRunner.stopMongod(ports[0], /* signal */ 9); + MongoRunner.stopMongod(conn.port, /* signal */ 9); var exitCode = createIdx({checkExitSuccess: false}); assert.neq(0, exitCode, "expected shell to exit abnormally due to mongod being terminated"); @@ -85,7 +84,6 @@ conn = MongoRunner.runMongod({ dbpath: dbpath, - port: ports[0], journal: '', noIndexBuildRetry: '', restart: true}); @@ -101,6 +99,6 @@ print("Index rebuilding disabled successfully"); - MongoRunner.stopMongod(ports[0]); + MongoRunner.stopMongod(conn.port); print("SUCCESS!"); }()); diff --git a/jstests/noPassthroughWithMongod/index_retry.js b/jstests/noPassthroughWithMongod/index_retry.js index cf26b780008..806c334e151 100644 --- a/jstests/noPassthroughWithMongod/index_retry.js +++ b/jstests/noPassthroughWithMongod/index_retry.js @@ -3,10 +3,9 @@ 'use strict'; var baseName = 'index_retry'; var dbpath = MongoRunner.dataPath + baseName; - var ports = allocatePorts(1); + var conn = MongoRunner.runMongod({ dbpath: dbpath, - port: ports[0], journal: ''}); var test = conn.getDB("test"); @@ -64,7 +63,7 @@ function abortDuringIndexBuild(options) { var createIdx = startParallelShell( 'db.' + name + '.createIndex({ a: 1 }, { background: true });', - ports[0]); + conn.port); // Wait for the index build to start. var times = 0; @@ -75,7 +74,7 @@ ); print("killing the mongod"); - MongoRunner.stopMongod(ports[0], /* signal */ 9); + MongoRunner.stopMongod(conn.port, /* signal */ 9); var exitCode = createIdx({checkExitSuccess: false}); assert.neq(0, exitCode, "expected shell to exit abnormally due to mongod being terminated"); @@ -85,7 +84,6 @@ conn = MongoRunner.runMongod({ dbpath: dbpath, - port: ports[0], journal: '', restart: true}); test = conn.getDB("test"); @@ -100,6 +98,6 @@ print("Index built"); - MongoRunner.stopMongod(ports[0]); + MongoRunner.stopMongod(conn.port); print("SUCCESS!"); }()); diff --git a/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js b/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js index c4896e56406..9f544248ef1 100644 --- a/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js +++ b/jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js @@ -6,28 +6,26 @@ // and a command line to run the test in inner_mode. The inner mode test is the actual test. if ("undefined" == typeof inner_mode) { - // Start a mongod with --ipv6 - port = allocatePorts( 1 )[ 0 ]; jsTest.log("Outer mode test starting mongod with --ipv6"); // NOTE: bind_ip arg is present to test if it can parse ipv6 addresses (::1 in this case). // Unfortunately, having bind_ip = ::1 won't work in the test framework (But does work when // tested manually), so 127.0.0.1 is also present so the test mongo shell can connect // with that address. - var mongod = MongoRunner.runMongod({port: port, ipv6: "", bind_ip: "::1,127.0.0.1"}); + var mongod = MongoRunner.runMongod({ipv6: "", bind_ip: "::1,127.0.0.1"}); var args = ["mongo", "--nodb", "--ipv6", "--host", "::1", - "--port", port, - "--eval", "inner_mode=true;port=" + port + ";", + "--port", mongod.port, + "--eval", "inner_mode=true;port=" + mongod.port + ";", "jstests/noPassthroughWithMongod/ipv6_connection_string_validation.js" ]; var exitCode = _runMongoProgram.apply(null, args); jsTest.log("Inner mode test finished, exit code was " + exitCode); // Stop the server we started jsTest.log("Outer mode test stopping server"); - MongoRunner.stopMongod(port, 15); + MongoRunner.stopMongod(mongod.port, 15); // Pass the inner test's exit code back as the outer test's exit code quit(exitCode); diff --git a/jstests/noPassthroughWithMongod/server7428.js b/jstests/noPassthroughWithMongod/server7428.js index ed62e7adbf6..1c6c2997804 100644 --- a/jstests/noPassthroughWithMongod/server7428.js +++ b/jstests/noPassthroughWithMongod/server7428.js @@ -6,15 +6,17 @@ // Verify that the copyDatabase command works appropriately when the // target mongo instance has authentication enabled. +(function() { // Setup fromDb with no auth -var fromDb = MongoRunner.runMongod({ port: 29000 }); - +var fromDb = MongoRunner.runMongod(); + // Setup toDb with auth -var toDb = MongoRunner.runMongod({auth : "", port : 31001}); +var toDb = MongoRunner.runMongod({auth: ""}); var admin = toDb.getDB("admin"); admin.createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}); admin.auth("foo","bar"); - + admin.copyDatabase('test', 'test', fromDb.host) +})(); diff --git a/jstests/noPassthroughWithMongod/sharding_rs_arb1.js b/jstests/noPassthroughWithMongod/sharding_rs_arb1.js index 4470a82ee88..4c36ff4f05d 100644 --- a/jstests/noPassthroughWithMongod/sharding_rs_arb1.js +++ b/jstests/noPassthroughWithMongod/sharding_rs_arb1.js @@ -1,5 +1,5 @@ var name = "sharding_rs_arb1" -var replTest = new ReplSetTest( { name : name , nodes : 3 , startPort : 31000 } ); +var replTest = new ReplSetTest( { name : name , nodes : 3 } ); replTest.startSet(); var port = replTest.ports; replTest.initiate({_id : name, members : @@ -25,4 +25,3 @@ assert( res.ok , tojson(res) ) st.stop(); replTest.stopSet(); - diff --git a/jstests/noPassthroughWithMongod/unix_socket1.js b/jstests/noPassthroughWithMongod/unix_socket1.js index 8e28715558c..1b607063923 100644 --- a/jstests/noPassthroughWithMongod/unix_socket1.js +++ b/jstests/noPassthroughWithMongod/unix_socket1.js @@ -22,15 +22,14 @@ if ( ! _isWindows() ) { sockdb = sock.getDB(db.getName()) assert( sockdb.runCommand('ping').ok ); - // test unix socket path - var ports = allocatePorts(1); + // Test unix socket path var path = MongoRunner.dataDir + "/sockpath"; mkdir(path); var dataPath = MongoRunner.dataDir + "/sockpath_data"; - var conn = MongoRunner.runMongod({port: ports[0], dbpath: dataPath, unixSocketPrefix: path}); + var conn = MongoRunner.runMongod({dbpath: dataPath, unixSocketPrefix: path}); - var sock2 = new Mongo(path+"/mongodb-"+ports[0]+".sock"); + var sock2 = new Mongo(path + "/mongodb-" + conn.port + ".sock"); sockdb2 = sock2.getDB(db.getName()) assert( sockdb2.runCommand('ping').ok ); |