summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2019-07-17 10:13:47 -0400
committerWilliam Schultz <william.schultz@mongodb.com>2019-07-17 10:14:37 -0400
commit19d0d47fb83d01edb18e0bcb235d6c39bbe16bbd (patch)
treeed8e30881a20b67f2e9de55d534d33e5053810c9 /jstests
parent18da05b7e79beb6c6eb68c82d94d2f76003d9f8d (diff)
downloadmongo-19d0d47fb83d01edb18e0bcb235d6c39bbe16bbd.tar.gz
SERVER-42004 localhost JS tests should wait for an election to complete before shutting down
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/localhost1.js5
-rw-r--r--jstests/replsets/localhost2.js5
-rw-r--r--jstests/replsets/localhost3.js5
3 files changed, 12 insertions, 3 deletions
diff --git a/jstests/replsets/localhost1.js b/jstests/replsets/localhost1.js
index 62064adfb91..d44f9f6b2ba 100644
--- a/jstests/replsets/localhost1.js
+++ b/jstests/replsets/localhost1.js
@@ -4,10 +4,13 @@
'use strict';
// Select localhost when binding to localhost
- const rt = new ReplSetTest({name: "rsLocal", nodes: 2});
+ const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
const primary = rt.startSet({bind_ip: "127.0.0.1"})[0];
const db = primary.getDB('admin');
const resp = assert.commandWorked(db.adminCommand({replSetInitiate: undefined}));
assert(resp.me.startsWith('127.0.0.1'), tojson(resp.me) + " does not start with 127.0.0.1:");
+
+ // Wait for the primary to complete its election before shutting down the set.
+ assert.soon(() => db.runCommand({ismaster: 1}).ismaster);
rt.stopSet();
})();
diff --git a/jstests/replsets/localhost2.js b/jstests/replsets/localhost2.js
index ac4dd7e0a76..aa3655dd1a2 100644
--- a/jstests/replsets/localhost2.js
+++ b/jstests/replsets/localhost2.js
@@ -4,7 +4,7 @@
'use strict';
// Select localhost when binding to localhost
- const rt = new ReplSetTest({name: "rsLocal", nodes: 2});
+ const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
const primary = rt.startSet({bind_ip: "0.0.0.0"})[0];
const db = primary.getDB('admin');
const resp = assert.commandWorked(db.adminCommand({replSetInitiate: undefined}));
@@ -13,5 +13,8 @@
assert(!resp.me.startsWith('0.0.0.0:'), tojson(resp.me) + " should not start with 0.0.0.0:");
assert(!resp.me.startsWith('localhost:'),
tojson(resp.me) + " should not start with localhost:");
+
+ // Wait for the primary to complete its election before shutting down the set.
+ assert.soon(() => db.runCommand({ismaster: 1}).ismaster);
rt.stopSet();
})();
diff --git a/jstests/replsets/localhost3.js b/jstests/replsets/localhost3.js
index ed3238a9d04..4f46505aaa6 100644
--- a/jstests/replsets/localhost3.js
+++ b/jstests/replsets/localhost3.js
@@ -4,10 +4,13 @@
'use strict';
// Select localhost when binding to localhost
- const rt = new ReplSetTest({name: "rsLocal", nodes: 2});
+ const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
const primary = rt.startSet({bind_ip: undefined})[0];
const db = primary.getDB('admin');
const resp = assert.commandWorked(db.adminCommand({replSetInitiate: undefined}));
assert(resp.me.startsWith('localhost:'), tojson(resp.me) + " should start with localhost:");
+
+ // Wait for the primary to complete its election before shutting down the set.
+ assert.soon(() => db.runCommand({ismaster: 1}).ismaster);
rt.stopSet();
})();