diff options
author | Martin Neupauer <martin.neupauer@10gen.com> | 2018-01-09 10:57:15 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2018-02-12 18:40:09 -0500 |
commit | e74bf273ef83cfbee332fe33079c0f640c71f7bb (patch) | |
tree | 359403f8210298ea9f901fcee324082fe63977b0 /src/mongo/db/pipeline/document_source_check_resume_token_test.cpp | |
parent | ac19d2bd2acbc63ba719bd6ddd3fe10fafdf2385 (diff) | |
download | mongo-e74bf273ef83cfbee332fe33079c0f640c71f7bb.tar.gz |
SERVER-32349 Change streams over sharded collections may produce merged op log entries
with the same timestamps if the operations are coming from multiple shards. When we
resume the change stream we have to position to the right place - the position is determined
both by the timestamp and the document id. Previously we checked the timestamp only,
now we loop over the equal timestamps and find the right document.
(cherry picked from commit 194ec4857fa0db8085da88e22eaae96687902d66)
Diffstat (limited to 'src/mongo/db/pipeline/document_source_check_resume_token_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_check_resume_token_test.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp index acf4f02e9e7..0323b6a1256 100644 --- a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp +++ b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp @@ -41,6 +41,7 @@ #include "mongo/db/pipeline/expression_context.h" #include "mongo/db/pipeline/resume_token.h" #include "mongo/db/pipeline/stub_mongo_process_interface.h" +#include "mongo/db/query/collation/collator_interface_mock.h" #include "mongo/db/service_context.h" #include "mongo/stdx/memory.h" #include "mongo/unittest/death_test.h" @@ -182,12 +183,12 @@ TEST_F(CheckResumeTokenTest, ShouldFailIfFirstDocHasWrongResumeToken) { ASSERT_THROWS_CODE(checkResumeToken->getNext(), AssertionException, 40585); } -TEST_F(CheckResumeTokenTest, ShouldFailIfTokenHasWrongDocumentId) { +TEST_F(CheckResumeTokenTest, ShouldIgnoreChangeWithEarlierTimestamp) { Timestamp resumeTimestamp(100, 1); - auto checkResumeToken = createCheckResumeToken(resumeTimestamp, "0"); - addDocument(resumeTimestamp, "1"); - ASSERT_THROWS_CODE(checkResumeToken->getNext(), AssertionException, 40585); + auto checkResumeToken = createCheckResumeToken(resumeTimestamp, "1"); + addDocument(resumeTimestamp, "0"); + ASSERT_TRUE(checkResumeToken->getNext().isEOF()); } TEST_F(CheckResumeTokenTest, ShouldFailIfTokenHasWrongNamespace) { @@ -200,6 +201,18 @@ TEST_F(CheckResumeTokenTest, ShouldFailIfTokenHasWrongNamespace) { ASSERT_THROWS_CODE(checkResumeToken->getNext(), AssertionException, 40585); } +TEST_F(CheckResumeTokenTest, ShouldSucceedWithBinaryCollation) { + CollatorInterfaceMock collatorCompareLower(CollatorInterfaceMock::MockType::kToLowerString); + getExpCtx()->setCollator(&collatorCompareLower); + + Timestamp resumeTimestamp(100, 1); + + auto checkResumeToken = createCheckResumeToken(resumeTimestamp, "abc"); + // We must not see the following document. + addDocument(resumeTimestamp, "ABC"); + ASSERT_TRUE(checkResumeToken->getNext().isEOF()); +} + /** * We should _error_ on the no-document case, because that means the resume token was not found. */ |