summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl_test.cpp
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2015-10-12 08:07:25 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2015-10-14 05:07:49 -0400
commitc860db7d39f8559054d1cebb83a6838accef8d94 (patch)
treeb3110c22e4afcdf6313144797957c8f6c4efe929 /src/mongo/db/repl/replication_coordinator_impl_test.cpp
parent7d43b0dba28b4b8e0184579a75c3dddab9d86e1f (diff)
downloadmongo-c860db7d39f8559054d1cebb83a6838accef8d94.tar.gz
SERVER-20822 make sync source decisions based on ReplSetMetadata
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_test.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index 674f50bfc9d..bf4c680f29a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -2617,19 +2617,20 @@ TEST_F(ReplCoordTest, MetadataWrongConfigVersion) {
// lower configVersion
StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion"
- << 1 << "primaryIndex" << 2 << "term" << 2)));
+ rpc::kReplSetMetadataFieldName << BSON(
+ "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion" << 1
+ << "primaryIndex" << 2 << "term" << 2 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
// higher configVersion
- StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion"
- << 100 << "primaryIndex" << 2 << "term" << 2)));
+ StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(
+ BSON(rpc::kReplSetMetadataFieldName
+ << BSON("lastOpCommitted"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "configVersion" << 100
+ << "primaryIndex" << 2 << "term" << 2 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(OpTime(Timestamp(0, 0), 0), getReplCoord()->getLastCommittedOpTime());
}
@@ -2660,20 +2661,20 @@ TEST_F(ReplCoordTest, MetadataUpdatesLastCommittedOpTime) {
// higher OpTime, should change
StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 1) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 1) << "configVersion"
- << 2 << "primaryIndex" << 2 << "term" << 1)));
+ rpc::kReplSetMetadataFieldName << BSON(
+ "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 1) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 1) << "configVersion" << 2
+ << "primaryIndex" << 2 << "term" << 1 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 1), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 1), getReplCoord()->getCurrentCommittedSnapshotOpTime());
// lower OpTime, should not change
StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << Timestamp(9, 0) << "t" << 1) << "lastOpVisible"
- << BSON("ts" << Timestamp(9, 0) << "t" << 1) << "configVersion"
- << 2 << "primaryIndex" << 2 << "term" << 1)));
+ rpc::kReplSetMetadataFieldName << BSON(
+ "lastOpCommitted" << BSON("ts" << Timestamp(9, 0) << "t" << 1) << "lastOpVisible"
+ << BSON("ts" << Timestamp(9, 0) << "t" << 1) << "configVersion" << 2
+ << "primaryIndex" << 2 << "term" << 1 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 1), getReplCoord()->getLastCommittedOpTime());
}
@@ -2700,10 +2701,10 @@ TEST_F(ReplCoordTest, MetadataUpdatesTermAndPrimaryId) {
// higher term, should change
StatusWith<rpc::ReplSetMetadata> metadata = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "lastOpVisible"
- << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "configVersion"
- << 2 << "primaryIndex" << 2 << "term" << 3)));
+ rpc::kReplSetMetadataFieldName << BSON(
+ "lastOpCommitted" << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "lastOpVisible"
+ << BSON("ts" << Timestamp(10, 0) << "t" << 3) << "configVersion" << 2
+ << "primaryIndex" << 2 << "term" << 3 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata.getValue());
ASSERT_EQUALS(OpTime(Timestamp(10, 0), 3), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
@@ -2711,10 +2712,10 @@ TEST_F(ReplCoordTest, MetadataUpdatesTermAndPrimaryId) {
// lower term, should not change
StatusWith<rpc::ReplSetMetadata> metadata2 = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
- << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion"
- << 2 << "primaryIndex" << 1 << "term" << 2)));
+ rpc::kReplSetMetadataFieldName << BSON(
+ "lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
+ << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion" << 2
+ << "primaryIndex" << 1 << "term" << 2 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata2.getValue());
ASSERT_EQUALS(OpTime(Timestamp(11, 0), 3), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(3, getReplCoord()->getTerm());
@@ -2722,10 +2723,10 @@ TEST_F(ReplCoordTest, MetadataUpdatesTermAndPrimaryId) {
// same term, should not change
StatusWith<rpc::ReplSetMetadata> metadata3 = rpc::ReplSetMetadata::readFromMetadata(BSON(
- rpc::kReplSetMetadataFieldName
- << BSON("lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
- << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion"
- << 2 << "primaryIndex" << 1 << "term" << 3)));
+ rpc::kReplSetMetadataFieldName << BSON(
+ "lastOpCommitted" << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "lastOpVisible"
+ << BSON("ts" << Timestamp(11, 0) << "t" << 3) << "configVersion" << 2
+ << "primaryIndex" << 1 << "term" << 3 << "syncSourceIndex" << 1)));
getReplCoord()->processReplSetMetadata(metadata3.getValue());
ASSERT_EQUALS(OpTime(Timestamp(11, 0), 3), getReplCoord()->getLastCommittedOpTime());
ASSERT_EQUALS(3, getReplCoord()->getTerm());