summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuayu Ouyang <huayu.ouyang@mongodb.com>2020-10-01 16:53:06 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-07 22:40:39 +0000
commit9fc56a7309e3e6a4b418dedc14729abc175d4ca5 (patch)
treebd8a4014423ee80ae7bbfaed3650b5115eccc14b
parentfe2f480e83e07369ffa2024faadd5c34e5e6415b (diff)
downloadmongo-9fc56a7309e3e6a4b418dedc14729abc175d4ca5.tar.gz
SERVER-50420 Change repl.ismaster to repl.isWritablePrimary in serverStatus
-rw-r--r--etc/backports_required_for_multiversion_tests.yml2
-rw-r--r--jstests/replsets/server_status_repl_is_writable_primary.js16
-rw-r--r--src/mongo/db/repl/replication_info.cpp4
3 files changed, 19 insertions, 3 deletions
diff --git a/etc/backports_required_for_multiversion_tests.yml b/etc/backports_required_for_multiversion_tests.yml
index b3c268b6e5b..c41f2e1a747 100644
--- a/etc/backports_required_for_multiversion_tests.yml
+++ b/etc/backports_required_for_multiversion_tests.yml
@@ -80,6 +80,8 @@ all:
test_file: jstests/replsets/change_sync_source_in_initial_sync.js
- ticket: SERVER-50415
test_file: jstests/sharding/awaitable_isMaster_primary_failures.js
+ - ticket: SERVER-50420
+ test_file: jstests/replsets/server_status_repl_is_writable_primary.js
# Tests that should only be excluded from particular suites should be listed under that suite.
suites:
diff --git a/jstests/replsets/server_status_repl_is_writable_primary.js b/jstests/replsets/server_status_repl_is_writable_primary.js
new file mode 100644
index 00000000000..d33eaee96b4
--- /dev/null
+++ b/jstests/replsets/server_status_repl_is_writable_primary.js
@@ -0,0 +1,16 @@
+/**
+ * Tests that serverStatus correctly returns repl.isWritablePrimary instead of repl.ismaster.
+ */
+(function() {
+"use strict";
+const replTest = new ReplSetTest({nodes: 1});
+replTest.startSet();
+replTest.initiate();
+const primary = replTest.getPrimary();
+
+const serverStatusMetricsRepl = primary.adminCommand({serverStatus: 1}).repl;
+assert.eq(serverStatusMetricsRepl.isWritablePrimary, true, "repl.isWritablePrimary should be true");
+assert.eq(
+ serverStatusMetricsRepl.hasOwnProperty('ismaster'), false, "repl.ismaster should be undefined");
+replTest.stopSet();
+})(); \ No newline at end of file
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 5b82d9303ca..b6c1667980c 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -173,12 +173,10 @@ public:
bool appendReplicationProcess = configElement.numberInt() > 0;
BSONObjBuilder result;
- // TODO SERVER-50219: Change useLegacyResponseFields to false once the serverStatus changes
- // to remove master-slave terminology are merged.
appendReplicationInfo(opCtx,
&result,
appendReplicationProcess,
- true /* useLegacyResponseFields */,
+ false /* useLegacyResponseFields */,
boost::none /* clientTopologyVersion */,
boost::none /* maxAwaitTimeMS */);