summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/migration_session_id_test.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2016-09-12 16:22:19 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2016-09-13 14:12:21 -0400
commit0c8ffece21a601fe3861aba6cc191b2ce1be0f54 (patch)
tree5b8a6f156a6f4b7ee4425e3b6511bd84c6b4f934 /src/mongo/db/s/migration_session_id_test.cpp
parent729169964eeb34460608ab1f494059d094e31caa (diff)
downloadmongo-0c8ffece21a601fe3861aba6cc191b2ce1be0f54.tar.gz
SERVER-26077 Tighten checks around migration session id
Transmits the migration session id together with the abort command and ensures that the migration session id reported in the status matches that of the cloner.
Diffstat (limited to 'src/mongo/db/s/migration_session_id_test.cpp')
-rw-r--r--src/mongo/db/s/migration_session_id_test.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/mongo/db/s/migration_session_id_test.cpp b/src/mongo/db/s/migration_session_id_test.cpp
index 02625995941..9fb64bd21e4 100644
--- a/src/mongo/db/s/migration_session_id_test.cpp
+++ b/src/mongo/db/s/migration_session_id_test.cpp
@@ -54,23 +54,23 @@ TEST(MigrationSessionId, GenerateAndExtract) {
}
TEST(MigrationSessionId, Comparison) {
- MigrationSessionId emptySessionId =
- assertGet(MigrationSessionId::extractFromBSON(BSON("SomeField" << 1)));
- MigrationSessionId nonEmptySessionId =
+ MigrationSessionId sessionId =
assertGet(MigrationSessionId::extractFromBSON(BSON("SomeField" << 1 << "sessionId"
<< "TestSessionID")));
- ASSERT(!emptySessionId.matches(nonEmptySessionId));
- ASSERT(!nonEmptySessionId.matches(emptySessionId));
-
MigrationSessionId sessionIdToCompare =
assertGet(MigrationSessionId::extractFromBSON(BSON("SomeOtherField" << 1 << "sessionId"
<< "TestSessionID")));
- ASSERT(nonEmptySessionId.matches(sessionIdToCompare));
- ASSERT(sessionIdToCompare.matches(nonEmptySessionId));
+ ASSERT(sessionId.matches(sessionIdToCompare));
+ ASSERT(sessionIdToCompare.matches(sessionId));
+}
+
+TEST(MigrationSessionId, ErrorNoSuchKeyWhenSessionIdIsMissing) {
+ ASSERT_EQ(ErrorCodes::NoSuchKey,
+ MigrationSessionId::extractFromBSON(BSON("SomeField" << 1)).getStatus().code());
}
-TEST(MigrationSessionId, ErrorWhenTypeIsNotString) {
+TEST(MigrationSessionId, ErrorWhenSessionIdTypeIsNotString) {
ASSERT_NOT_OK(
MigrationSessionId::extractFromBSON(BSON("SomeField" << 1 << "sessionId" << Date_t::now()))
.getStatus());