summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replica_set_config_checks_test.cpp
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2014-10-29 10:06:16 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2014-11-13 07:23:38 -0500
commitbe6b276f8367b2165133599d631cec0c9813afab (patch)
treeed8c078ad77d1b21343b0777a00c0a6048bfe6f2 /src/mongo/db/repl/replica_set_config_checks_test.cpp
parent9a9b844828cdba0689484a6c18d9f04e8b5f950c (diff)
downloadmongo-be6b276f8367b2165133599d631cec0c9813afab.tar.gz
SERVER-15468 add forced reconfig tests to replica_set_config_checks_test
Diffstat (limited to 'src/mongo/db/repl/replica_set_config_checks_test.cpp')
-rw-r--r--src/mongo/db/repl/replica_set_config_checks_test.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replica_set_config_checks_test.cpp b/src/mongo/db/repl/replica_set_config_checks_test.cpp
index d7006016002..b957f888750 100644
--- a/src/mongo/db/repl/replica_set_config_checks_test.cpp
+++ b/src/mongo/db/repl/replica_set_config_checks_test.cpp
@@ -133,6 +133,12 @@ namespace {
oldConfig,
oldConfig,
false).getStatus());
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState,
+ oldConfig,
+ oldConfig,
+ true).getStatus());
// Cannot reconfig from new to old (versions must increase).
ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
@@ -140,6 +146,12 @@ namespace {
newConfig,
oldConfig,
false).getStatus());
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState,
+ newConfig,
+ oldConfig,
+ true).getStatus());
}
TEST(ValidateConfigForReconfig, NewConfigMustNotChangeSetName) {
@@ -173,6 +185,12 @@ namespace {
oldConfig,
newConfig,
false).getStatus());
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState,
+ newConfig,
+ oldConfig,
+ true).getStatus());
}
TEST(ValidateConfigForReconfig, NewConfigMustNotFlipBuildIndexesFlag) {
@@ -227,6 +245,13 @@ namespace {
oldConfig,
newConfig,
false).getStatus());
+
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState,
+ oldConfig,
+ newConfig,
+ true).getStatus());
}
TEST(ValidateConfigForReconfig, NewConfigMustNotFlipArbiterFlag) {
@@ -278,6 +303,12 @@ namespace {
oldConfig,
newConfig,
false).getStatus());
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState,
+ oldConfig,
+ newConfig,
+ true).getStatus());
}
TEST(ValidateConfigForReconfig, HostAndIdRemappingRestricted) {
@@ -336,6 +367,12 @@ namespace {
oldConfig,
illegalNewConfigReusingHost,
false).getStatus());
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::NewReplicaSetConfigurationIncompatible,
+ validateConfigForReconfig(&externalState,
+ oldConfig,
+ illegalNewConfigReusingHost,
+ true).getStatus());
//
// Here, the new config is valid, because all we've changed is the name of
// the host representing _id 2.
@@ -394,6 +431,21 @@ namespace {
oldConfig,
newConfig,
false)));
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::NodeNotFound,
+ validateConfigForReconfig(&notPresentExternalState,
+ oldConfig,
+ newConfig,
+ true).getStatus());
+ ASSERT_EQUALS(ErrorCodes::DuplicateKey,
+ validateConfigForReconfig(&presentThriceExternalState,
+ oldConfig,
+ newConfig,
+ true).getStatus());
+ ASSERT_EQUALS(1, unittest::assertGet(validateConfigForReconfig(&presentOnceExternalState,
+ oldConfig,
+ newConfig,
+ true)));
}
TEST(ValidateConfigForReconfig, SelfMustEndElectable) {
@@ -423,6 +475,11 @@ namespace {
oldConfig,
newConfig,
false).getStatus());
+ // Forced reconfig does not require electability.
+ ASSERT_OK(validateConfigForReconfig(&presentOnceExternalState,
+ oldConfig,
+ newConfig,
+ true).getStatus());
}
TEST(ValidateConfigForInitiate, NewConfigInvalid) {
@@ -465,6 +522,11 @@ namespace {
oldConfig,
newConfig,
false).getStatus());
+ // Forced reconfigs also do not allow this.
+ ASSERT_EQUALS(ErrorCodes::BadValue, validateConfigForReconfig(&presentOnceExternalState,
+ oldConfig,
+ newConfig,
+ true).getStatus());
}
TEST(ValidateConfigForStartUp, NewConfigInvalid) {