summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2019-02-12 20:37:10 +0000
committerBilly Donahue <billy.donahue@mongodb.com>2019-03-04 15:44:51 -0500
commit01af550078c1c89201cbf861808f5a2c1fff7294 (patch)
tree18a6b00a75a03d2594f9b564641abd16b10c847e
parentbe6ea4b3c4fb945f47b881bb5c5ffce7952dc018 (diff)
downloadmongo-01af550078c1c89201cbf861808f5a2c1fff7294.tar.gz
SERVER-39590 improve port_options.js logfile polling
(cherry picked from commit 29d91ec77892f8b335bcc07ccf96e3240981ab05)
-rw-r--r--jstests/noPassthrough/port_options.js33
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);
}());