diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-09-03 15:38:07 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-09-09 13:14:48 -0400 |
commit | 55415b9297de042844fcd6b65586ae8a726ce6f3 (patch) | |
tree | d790fc6d29ec23e974030cbd0d4aa2a2d70c0e99 | |
parent | c15f4bb96d2ee86874582d45d1865e9358168e7e (diff) | |
download | mongo-55415b9297de042844fcd6b65586ae8a726ce6f3.tar.gz |
SERVER-18271 Add TestData options to configure range of ports used in tests
-rw-r--r-- | src/mongo/shell/servers_misc.js | 14 | ||||
-rw-r--r-- | src/mongo/shell/utils.js | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/mongo/shell/servers_misc.js b/src/mongo/shell/servers_misc.js index 4c190586640..b0d7ff952b5 100644 --- a/src/mongo/shell/servers_misc.js +++ b/src/mongo/shell/servers_misc.js @@ -166,12 +166,18 @@ ReplTest.prototype.stop = function( master , signal ){ * Returns a port number that has not been given out to any other caller from the same mongo shell. */ allocatePort = (function() { - var maxPort = Math.pow(2, 16) - 1; - // Chosen in an attempt to have a large number of unassigned ports that are also outside the - // ephemeral port range. - var nextPort = 20000; + // Defer initializing these variables until the first call, as TestData attributes may be + // initialized as part of the --eval argument (e.g. by resmoke.py), which will not be evaluated + // until after this has loaded. + var maxPort; + var nextPort; return function() { + // The default port was chosen in an attempt to have a large number of unassigned ports that + // are also outside the ephemeral port range. + nextPort = nextPort || jsTestOptions().minPort || 20000; + maxPort = maxPort || jsTestOptions().maxPort || Math.pow(2, 16) - 1; + if (nextPort === maxPort) { throw new Error("Exceeded maximum port range in allocatePort()"); } diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index 8c126cf903c..fe56226dfad 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -177,6 +177,8 @@ jsTestOptions = function(){ useLegacyConfigServers: TestData.useLegacyConfigServers || false, enableEncryption: TestData.enableEncryption, encryptionKeyFile: TestData.encryptionKeyFile, + minPort: TestData.minPort, + maxPort: TestData.maxPort, } ); } |