diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2017-11-20 15:20:59 -0500 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2017-12-14 23:36:38 -0500 |
commit | 661bb326d8a02dfa202b003d1766a939e264e2bd (patch) | |
tree | 897579968a0afb2dbddf19ef8a7281f1a5366c23 /jstests/noPassthrough/port_options.js | |
parent | 950fa6e6fd8f46248796dea3bc6c2392757b163d (diff) | |
download | mongo-661bb326d8a02dfa202b003d1766a939e264e2bd.tar.gz |
SERVER-30086 better log message when using --port 0
Diffstat (limited to 'jstests/noPassthrough/port_options.js')
-rw-r--r-- | jstests/noPassthrough/port_options.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/noPassthrough/port_options.js b/jstests/noPassthrough/port_options.js new file mode 100644 index 00000000000..6dbab50de61 --- /dev/null +++ b/jstests/noPassthrough/port_options.js @@ -0,0 +1,39 @@ +// Check --port= edge behaviors. + +(function() { + 'use strict'; + jsTest.log("Setting port=0 is okay unless binding to multiple IP interfaces."); + + function runTest(bindIP, expectOk) { + jsTest.log("".concat("Testing with bindIP=[", bindIP, "], expectOk=[", expectOk, "]")); + + const logpath = "".concat(MongoRunner.dataDir, "/mongod.log"); + + let pid = startMongoProgramNoConnect("mongod", + "--ipv6", + "--dbpath", + MongoRunner.dataDir, + "--logpath", + logpath, + "--bind_ip", + bindIP, + "--port", + 0); + jsTest.log("".concat("pid=[", pid, "]")); + + if (expectOk) { + const ec = stopMongoProgramByPid(pid); + const expect = _isWindows() ? 1 : -15; // SIGTERM is 15 + assert.eq(ec, expect, "Expected mongod terminate"); + } else { + const ec = waitProgram(pid); + assert.eq(ec, MongoRunner.EXIT_NET_ERROR); + assert( + /Port 0 \(ephemeral port\) is not allowed when listening on multiple IP interfaces/ + .test(cat(logpath)), + "No warning issued for invalid port=0 usage"); + } + } + runTest("127.0.0.1", true); + runTest("127.0.0.1,::1", false); +}()); |