diff options
Diffstat (limited to 'jstests/noPassthrough/drop_connections_replSet.js')
-rw-r--r-- | jstests/noPassthrough/drop_connections_replSet.js | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/jstests/noPassthrough/drop_connections_replSet.js b/jstests/noPassthrough/drop_connections_replSet.js index d8e07397afe..b9ec6c93368 100644 --- a/jstests/noPassthrough/drop_connections_replSet.js +++ b/jstests/noPassthrough/drop_connections_replSet.js @@ -4,51 +4,51 @@ */ (function() { - "use strict"; - - const rst = new ReplSetTest({nodes: 3}); - rst.startSet(); - rst.initiate(); - - const primary = rst.getPrimary(); - rst.awaitSecondaryNodes(); - - function getConnPoolHosts() { - const ret = primary.adminCommand({connPoolStats: 1}); - assert.commandWorked(ret); - jsTestLog("Connection pool stats by host: " + tojson(ret.hosts)); - return ret.hosts; - } - - // To test the dropConnections command, first remove the secondary. This should have no effect - // on the existing connection pool, but it'll prevent the primary from reconnecting to it after - // dropConnections. Then, execute dropConnections and check that the primary has 0 connections - // to the secondary. - const cfg = primary.getDB('local').system.replset.findOne(); - const memberHost = cfg.members[2].host; - assert.eq(memberHost in getConnPoolHosts(), true); - - const removedMember = cfg.members.splice(2, 1); - assert.eq(removedMember[0].host, memberHost); - cfg.version++; - - jsTestLog("Reconfiguring to omit " + memberHost); - assert.commandWorked(primary.adminCommand({replSetReconfig: cfg})); - - // Reconfig did not affect the connection pool - assert.eq(memberHost in getConnPoolHosts(), true); - - // Test dropConnections - jsTestLog("Dropping connections to " + memberHost); - assert.commandWorked(primary.adminCommand({dropConnections: 1, hostAndPort: [memberHost]})); - assert.soon(() => { - return !(memberHost in getConnPoolHosts()); - }); - - // Need to re-add removed node, or the test complains about the replset config - cfg.members.push(removedMember[0]); - cfg.version++; - assert.commandWorked(primary.adminCommand({replSetReconfig: cfg})); - - rst.stopSet(); +"use strict"; + +const rst = new ReplSetTest({nodes: 3}); +rst.startSet(); +rst.initiate(); + +const primary = rst.getPrimary(); +rst.awaitSecondaryNodes(); + +function getConnPoolHosts() { + const ret = primary.adminCommand({connPoolStats: 1}); + assert.commandWorked(ret); + jsTestLog("Connection pool stats by host: " + tojson(ret.hosts)); + return ret.hosts; +} + +// To test the dropConnections command, first remove the secondary. This should have no effect +// on the existing connection pool, but it'll prevent the primary from reconnecting to it after +// dropConnections. Then, execute dropConnections and check that the primary has 0 connections +// to the secondary. +const cfg = primary.getDB('local').system.replset.findOne(); +const memberHost = cfg.members[2].host; +assert.eq(memberHost in getConnPoolHosts(), true); + +const removedMember = cfg.members.splice(2, 1); +assert.eq(removedMember[0].host, memberHost); +cfg.version++; + +jsTestLog("Reconfiguring to omit " + memberHost); +assert.commandWorked(primary.adminCommand({replSetReconfig: cfg})); + +// Reconfig did not affect the connection pool +assert.eq(memberHost in getConnPoolHosts(), true); + +// Test dropConnections +jsTestLog("Dropping connections to " + memberHost); +assert.commandWorked(primary.adminCommand({dropConnections: 1, hostAndPort: [memberHost]})); +assert.soon(() => { + return !(memberHost in getConnPoolHosts()); +}); + +// Need to re-add removed node, or the test complains about the replset config +cfg.members.push(removedMember[0]); +cfg.version++; +assert.commandWorked(primary.adminCommand({replSetReconfig: cfg})); + +rst.stopSet(); })(); |