0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 16:46:00 +01:00
mongodb/jstests/replsets/get_status.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

27 lines
977 B
JavaScript

/*
* Sanity check that get_status works as expected. There are C++ unit tests for most of the
* functionality, so we'll just check that it succeeds and fails when it's supposed to.
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
var name = "getstatus";
var numNodes = 4;
var replTest = new ReplSetTest({name: name, nodes: numNodes});
var nodes = replTest.startSet();
var config = replTest.getReplSetConfig();
config.members[numNodes - 1].arbiterOnly = true;
// An invalid time to get status
var statusBeforeInitCode = 94;
assert.commandFailedWithCode(nodes[0].getDB("admin").runCommand({replSetGetStatus: 1}),
statusBeforeInitCode,
"replSetGetStatus should fail before initializing.");
replTest.initiate(config);
replTest.awaitSecondaryNodes();
// A valid status
var primary = replTest.getPrimary();
assert.commandWorked(primary.getDB("admin").runCommand({replSetGetStatus: 1}));
replTest.stopSet();