summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/member_config_test.cpp
diff options
context:
space:
mode:
authorAli Mir <ali.mir@mongodb.com>2020-11-04 17:25:32 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-28 04:26:57 +0000
commit35a6a97338930d75a7f5cfd89671ae9af65aaf85 (patch)
treed0f026c6f06c0a38795fa4eaa56040d145034679 /src/mongo/db/repl/member_config_test.cpp
parent5a5a75e4149faae8f1b6e95d60b84cc7f33d4e2b (diff)
downloadmongo-35a6a97338930d75a7f5cfd89671ae9af65aaf85.tar.gz
SERVER-50423 Change memberConfig's slaveDelay field to secondaryDelaySecs
Diffstat (limited to 'src/mongo/db/repl/member_config_test.cpp')
-rw-r--r--src/mongo/db/repl/member_config_test.cpp128
1 files changed, 120 insertions, 8 deletions
diff --git a/src/mongo/db/repl/member_config_test.cpp b/src/mongo/db/repl/member_config_test.cpp
index 00c9fb36765..a9cad26e77c 100644
--- a/src/mongo/db/repl/member_config_test.cpp
+++ b/src/mongo/db/repl/member_config_test.cpp
@@ -49,7 +49,7 @@ TEST(MemberConfig, ParseMinimalMemberConfigAndCheckDefaults) {
ASSERT_EQUALS(MemberId(0), mc.getId());
ASSERT_EQUALS(HostAndPort("localhost", 12345), mc.getHostAndPort());
ASSERT_EQUALS(1.0, mc.getPriority());
- ASSERT_EQUALS(Seconds(0), mc.getSlaveDelay());
+ ASSERT_EQUALS(Seconds(0), mc.getSecondaryDelay());
ASSERT_TRUE(mc.isVoter());
ASSERT_FALSE(mc.isHidden());
ASSERT_FALSE(mc.isArbiter());
@@ -675,7 +675,7 @@ TEST(MemberConfig, ParseSlaveDelay) {
<< "h"
<< "priority" << 0 << "slaveDelay" << 100),
&tagConfig);
- ASSERT_EQUALS(Seconds(100), mc.getSlaveDelay());
+ ASSERT_EQUALS(Seconds(100), mc.getSecondaryDelay());
}
{
ASSERT_THROWS(MemberConfig(BSON("_id" << 0 << "host"
@@ -715,6 +715,54 @@ TEST(MemberConfig, ParseSlaveDelay) {
}
}
+TEST(MemberConfig, ParseSecondaryDelay) {
+ ReplSetTagConfig tagConfig;
+ {
+ MemberConfig mc(BSON("_id" << 0 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 100),
+ &tagConfig);
+ ASSERT_EQUALS(Seconds(100), mc.getSecondaryDelay());
+ }
+ {
+ ASSERT_THROWS(MemberConfig(BSON("_id" << 0 << "host"
+ << "h"
+ << "secondaryDelaySecs" << 100),
+ &tagConfig),
+ ExceptionFor<ErrorCodes::BadValue>);
+ }
+ {
+ MemberConfig mc(BSON("_id" << 0 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 0),
+ &tagConfig);
+ }
+ {
+ MemberConfig mc(BSON("_id" << 0 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 3600 * 10),
+ &tagConfig);
+ }
+ {
+ ASSERT_THROWS_CODE(
+ MemberConfig(BSON("_id" << 0 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << -1),
+ &tagConfig),
+ AssertionException,
+ 51024);
+ }
+ {
+ ASSERT_THROWS_CODE(
+ MemberConfig(BSON("_id" << 0 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 3600 * 24 * 400),
+ &tagConfig),
+ AssertionException,
+ 51024);
+ }
+}
+
TEST(MemberConfig, ParseAcceptsAnyNumberSlaveDelay) {
ReplSetTagConfig tagConfig;
{
@@ -722,28 +770,28 @@ TEST(MemberConfig, ParseAcceptsAnyNumberSlaveDelay) {
<< "h"
<< "priority" << 0 << "slaveDelay" << 0),
&tagConfig);
- ASSERT_EQUALS(mc.getSlaveDelay(), Seconds(0));
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(0));
}
{
MemberConfig mc(BSON("_id" << 1 << "host"
<< "h"
<< "priority" << 0 << "slaveDelay" << 0.5),
&tagConfig);
- ASSERT_EQUALS(mc.getSlaveDelay(), Seconds(0));
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(0));
}
{
MemberConfig mc(BSON("_id" << 1 << "host"
<< "h"
<< "priority" << 0 << "slaveDelay" << -0.5),
&tagConfig);
- ASSERT_EQUALS(mc.getSlaveDelay(), Seconds(0));
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(0));
}
{
MemberConfig mc(BSON("_id" << 1 << "host"
<< "h"
<< "priority" << 0 << "slaveDelay" << 1),
&tagConfig);
- ASSERT_EQUALS(mc.getSlaveDelay(), Seconds(1));
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(1));
}
{
ASSERT_THROWS_CODE(MemberConfig(BSON("_id" << 1 << "host"
@@ -758,14 +806,69 @@ TEST(MemberConfig, ParseAcceptsAnyNumberSlaveDelay) {
<< "h"
<< "priority" << 0 << "slaveDelay" << 1.6),
&tagConfig);
- ASSERT_EQUALS(mc.getSlaveDelay(), Seconds(1));
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(1));
}
{
MemberConfig mc(BSON("_id" << 1 << "host"
<< "h"
<< "priority" << 0 << "slaveDelay" << 4),
&tagConfig);
- ASSERT_EQUALS(mc.getSlaveDelay(), Seconds(4));
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(4));
+ }
+}
+
+TEST(MemberConfig, ParseAcceptsAnyNumberSecondaryDelay) {
+ ReplSetTagConfig tagConfig;
+ {
+ MemberConfig mc(BSON("_id" << 1 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 0),
+ &tagConfig);
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(0));
+ }
+ {
+ MemberConfig mc(BSON("_id" << 1 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 0.5),
+ &tagConfig);
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(0));
+ }
+ {
+ MemberConfig mc(BSON("_id" << 1 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << -0.5),
+ &tagConfig);
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(0));
+ }
+ {
+ MemberConfig mc(BSON("_id" << 1 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 1),
+ &tagConfig);
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(1));
+ }
+ {
+ ASSERT_THROWS_CODE(
+ MemberConfig(BSON("_id" << 1 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << -1.5),
+ &tagConfig),
+ AssertionException,
+ 51024);
+ }
+ {
+ MemberConfig mc(BSON("_id" << 0 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 1.6),
+ &tagConfig);
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(1));
+ }
+ {
+ MemberConfig mc(BSON("_id" << 1 << "host"
+ << "h"
+ << "priority" << 0 << "secondaryDelaySecs" << 4),
+ &tagConfig);
+ ASSERT_EQUALS(mc.getSecondaryDelay(), Seconds(4));
}
}
@@ -990,6 +1093,15 @@ TEST(MemberConfig, ValidatePriorityAndSlaveDelayRelationship) {
ExceptionFor<ErrorCodes::BadValue>);
}
+TEST(MemberConfig, ValidatePriorityAndSecondaryDelayRelationship) {
+ ReplSetTagConfig tagConfig;
+ ASSERT_THROWS(MemberConfig(BSON("_id" << 0 << "host"
+ << "h"
+ << "priority" << 1 << "secondaryDelaySecs" << 60),
+ &tagConfig),
+ ExceptionFor<ErrorCodes::BadValue>);
+}
+
TEST(MemberConfig, ValidatePriorityAndHiddenRelationship) {
ReplSetTagConfig tagConfig;
{