diff options
-rw-r--r-- | jstests/noPassthrough/port_options.js | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/jstests/noPassthrough/port_options.js b/jstests/noPassthrough/port_options.js index d56fb02feba..8f4d4becc3e 100644 --- a/jstests/noPassthrough/port_options.js +++ b/jstests/noPassthrough/port_options.js @@ -7,27 +7,19 @@ 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); + clearRawMongoProgramOutput(); + + let pid = startMongoProgramNoConnect( + "mongod", "--ipv6", "--dbpath", MongoRunner.dataDir, "--bind_ip", bindIP, "--port", 0); jsTest.log("".concat("pid=[", pid, "]")); if (expectOk) { let port; - // We use assert.soonNoExcept() here because `cat(logpath)` may fail due to the mongod - // not yet having created the log file yet. + // We use assert.soonNoExcept() here because the mongod may not be logging yet. assert.soonNoExcept(() => { - const found = cat(logpath).match(/waiting for connections on port (\d+)/); + const logContents = rawMongoProgramOutput(); + const found = logContents.match(/waiting for connections on port (\d+)/); if (found !== null) { print("Found message from mongod with port it is listening on: " + found[0]); port = found[1]; @@ -49,12 +41,15 @@ } 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"); + assert.soonNoExcept(() => { + const logContents = rawMongoProgramOutput(); + const found = logContents.match( + /Port 0 \(ephemeral port\) is not allowed when listening on multiple IP interfaces/); + return (found !== null); + }, "No warning issued for invalid port=0 usage"); } } + runTest("127.0.0.1", true); runTest("127.0.0.1,::1", false); }()); |