diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-01-07 06:15:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-07 06:15:12 +0100 |
commit | 776a02c236bb78b64d6bb7643f4a5acf2ab0f1e1 (patch) | |
tree | 3077f322cc345a30ab801c25da6fbdb845d951b2 /storage/src/tests | |
parent | 499d884cefeac2a4f5dc071814d1a64ddc249875 (diff) |
Revert "Revert "Balder/refactor docentry""
Diffstat (limited to 'storage/src/tests')
-rw-r--r-- | storage/src/tests/persistence/splitbitdetectortest.cpp | 14 | ||||
-rw-r--r-- | storage/src/tests/persistence/testandsettest.cpp | 11 | ||||
-rw-r--r-- | storage/src/tests/visiting/visitortest.cpp | 57 |
3 files changed, 42 insertions, 40 deletions
diff --git a/storage/src/tests/persistence/splitbitdetectortest.cpp b/storage/src/tests/persistence/splitbitdetectortest.cpp index d4e84836a5a..5c4dc85e825 100644 --- a/storage/src/tests/persistence/splitbitdetectortest.cpp +++ b/storage/src/tests/persistence/splitbitdetectortest.cpp @@ -15,6 +15,8 @@ using namespace ::testing; namespace storage { +using DocEntryList = std::vector<spi::DocEntry::UP>; + struct SplitBitDetectorTest : Test { document::TestDocMan testDocMan; spi::dummy::DummyPersistence provider; @@ -33,7 +35,7 @@ struct SplitBitDetectorTest : Test { }; TEST_F(SplitBitDetectorTest, two_users) { - std::vector<spi::DocEntry::UP> entries; + DocEntryList entries; for (uint32_t i = 0; i < 5; ++i) { document::Document::SP doc( testDocMan.createRandomDocumentAtLocation(1, i, 1, 1)); @@ -54,7 +56,7 @@ TEST_F(SplitBitDetectorTest, two_users) { } TEST_F(SplitBitDetectorTest, single_user) { - std::vector<spi::DocEntry::UP> entries; + DocEntryList entries; for (uint32_t i = 0; i < 10; ++i) { document::Document::SP doc( testDocMan.createRandomDocumentAtLocation(1, i, 1, 1)); @@ -71,7 +73,7 @@ TEST_F(SplitBitDetectorTest, single_user) { TEST_F(SplitBitDetectorTest, max_bits) { int minContentSize = 1, maxContentSize = 1; - std::vector<spi::DocEntry::UP> entries; + DocEntryList entries; for (uint32_t seed = 0; seed < 10; ++seed) { int location = 1; document::Document::SP doc(testDocMan.createRandomDocumentAtLocation( @@ -92,7 +94,7 @@ TEST_F(SplitBitDetectorTest, max_bits_one_below_max) { provider.createBucket(my_bucket, context); - std::vector<spi::DocEntry::UP> entries; + DocEntryList entries; for (uint32_t seed = 0; seed < 10; ++seed) { int location = 1 | (seed % 2 == 0 ? 0x8000 : 0); document::Document::SP doc(testDocMan.createRandomDocumentAtLocation( @@ -114,7 +116,7 @@ TEST_F(SplitBitDetectorTest, max_bits_one_below_max) { } TEST_F(SplitBitDetectorTest, unsplittable) { - std::vector<spi::DocEntry::UP> entries; + DocEntryList entries; for (uint32_t i = 0; i < 10; ++i) { document::Document::SP doc( @@ -130,7 +132,7 @@ TEST_F(SplitBitDetectorTest, unsplittable) { } TEST_F(SplitBitDetectorTest, unsplittable_min_count) { - std::vector<spi::DocEntry::UP> entries; + DocEntryList entries; for (uint32_t i = 0; i < 10; ++i) { document::Document::SP doc( diff --git a/storage/src/tests/persistence/testandsettest.cpp b/storage/src/tests/persistence/testandsettest.cpp index 146dcab2ba7..8cf89b55ad0 100644 --- a/storage/src/tests/persistence/testandsettest.cpp +++ b/storage/src/tests/persistence/testandsettest.cpp @@ -10,6 +10,7 @@ #include <vespa/document/fieldset/fieldsets.h> #include <vespa/persistence/spi/test.h> #include <vespa/persistence/spi/persistenceprovider.h> +#include <vespa/persistence/spi/docentry.h> #include <functional> using std::unique_ptr; @@ -73,7 +74,7 @@ struct TestAndSetTest : PersistenceTestUtils { static std::string expectedDocEntryString( api::Timestamp timestamp, const document::DocumentId & testDocId, - spi::DocumentMetaFlags removeFlag = spi::NONE); + spi::DocumentMetaEnum removeFlag = spi::DocumentMetaEnum::NONE); }; TEST_F(TestAndSetTest, conditional_put_not_executed_on_condition_mismatch) { @@ -150,7 +151,7 @@ TEST_F(TestAndSetTest, conditional_remove_executed_on_condition_match) { ASSERT_EQ(fetchResult(asyncHandler->handleRemove(*remove, createTracker(remove, BUCKET))).getResult(), api::ReturnCode::Result::OK); EXPECT_EQ(expectedDocEntryString(timestampOne, testDocId) + - expectedDocEntryString(timestampTwo, testDocId, spi::REMOVE_ENTRY), + expectedDocEntryString(timestampTwo, testDocId, spi::DocumentMetaEnum::REMOVE_ENTRY), dumpBucket(BUCKET_ID)); } @@ -291,12 +292,12 @@ void TestAndSetTest::assertTestDocumentFoundAndMatchesContent(const document::Fi std::string TestAndSetTest::expectedDocEntryString( api::Timestamp timestamp, const document::DocumentId & docId, - spi::DocumentMetaFlags removeFlag) + spi::DocumentMetaEnum removeFlag) { std::stringstream ss; - ss << "DocEntry(" << timestamp << ", " << removeFlag << ", "; - if (removeFlag == spi::REMOVE_ENTRY) { + ss << "DocEntry(" << timestamp << ", " << int(removeFlag) << ", "; + if (removeFlag == spi::DocumentMetaEnum::REMOVE_ENTRY) { ss << docId << ")\n"; } else { ss << "Doc(" << docId << "))\n"; diff --git a/storage/src/tests/visiting/visitortest.cpp b/storage/src/tests/visiting/visitortest.cpp index 494af8a0eff..945a08d910e 100644 --- a/storage/src/tests/visiting/visitortest.cpp +++ b/storage/src/tests/visiting/visitortest.cpp @@ -16,6 +16,7 @@ #include <tests/common/teststorageapp.h> #include <tests/common/dummystoragelink.h> #include <tests/storageserver/testvisitormessagesession.h> +#include <vespa/persistence/spi/docentry.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/gtest/gtest.h> #include <thread> @@ -23,6 +24,8 @@ using namespace std::chrono_literals; using document::test::makeBucketSpace; +using document::Document; +using document::DocumentId; using namespace ::testing; namespace storage { @@ -54,7 +57,7 @@ struct TestParams { struct VisitorTest : Test { static uint32_t docCount; - std::vector<document::Document::SP > _documents; + std::vector<Document::SP> _documents; std::unique_ptr<TestVisitorMessageSessionFactory> _messageSessionFactory; std::unique_ptr<TestServiceLayerApp> _node; std::unique_ptr<DummyStorageLink> _top; @@ -92,11 +95,11 @@ struct VisitorTest : Test { void getMessagesAndReply( int expectedCount, TestVisitorMessageSession& session, - std::vector<document::Document::SP >& docs, - std::vector<document::DocumentId>& docIds, + std::vector<Document::SP> & docs, + std::vector<DocumentId>& docIds, std::vector<std::string>& infoMessages, api::ReturnCode::Result returnCode = api::ReturnCode::OK); - uint32_t getMatchingDocuments(std::vector<document::Document::SP >& docs); + uint32_t getMatchingDocuments(std::vector<Document::SP>& docs); protected: void doTestVisitorInstanceHasConsistencyLevel( @@ -212,7 +215,7 @@ VisitorTest::initializeTest(const TestParams& params) uri << "id:test:testdoctype1:n=" << i % 10 << ":http://www.ntnu.no/" << i << ".html"; - _documents.push_back(document::Document::SP( + _documents.push_back(Document::SP( _node->getTestDocMan().createDocument(content, uri.str()))); const document::DocumentType& type(_documents.back()->getType()); _documents.back()->setValue(type.getField("headerval"), @@ -275,8 +278,8 @@ void VisitorTest::getMessagesAndReply( int expectedCount, TestVisitorMessageSession& session, - std::vector<document::Document::SP >& docs, - std::vector<document::DocumentId>& docIds, + std::vector<Document::SP >& docs, + std::vector<DocumentId>& docIds, std::vector<std::string>& infoMessages, api::ReturnCode::Result result) { @@ -351,7 +354,7 @@ VisitorTest::verifyCreateVisitorReply( } uint32_t -VisitorTest::getMatchingDocuments(std::vector<document::Document::SP >& docs) { +VisitorTest::getMatchingDocuments(std::vector<Document::SP >& docs) { uint32_t equalCount = 0; for (uint32_t i=0; i<docs.size(); ++i) { for (uint32_t j=0; j<_documents.size(); ++j) { @@ -381,11 +384,7 @@ VisitorTest::sendGetIterReply(GetIterCommand& cmd, assert(maxDocuments < _documents.size()); size_t documentCount = maxDocuments != 0 ? maxDocuments : _documents.size(); for (size_t i = 0; i < documentCount; ++i) { - reply->getEntries().emplace_back( - std::make_unique<spi::DocEntry>( - spi::Timestamp(1000 + i), - spi::NONE, - document::Document::UP(_documents[i]->clone()))); + reply->getEntries().push_back(spi::DocEntry::create(spi::Timestamp(1000 + i), Document::UP(_documents[i]->clone()))); } if (documentCount == _documents.size() || overrideCompleted) { reply->setCompleted(); @@ -481,8 +480,8 @@ TEST_F(VisitorTest, normal_usage) { sendGetIterReply(*getIterCmd); - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> docIds; + std::vector<Document::SP> docs; + std::vector<DocumentId> docIds; std::vector<std::string> infoMessages; getMessagesAndReply(_documents.size(), getSession(0), docs, docIds, infoMessages); ASSERT_EQ(0, infoMessages.size()); @@ -547,8 +546,8 @@ TEST_F(VisitorTest, document_api_client_error) { sendGetIterReply(*getIterCmd, api::ReturnCode(api::ReturnCode::OK), 1); } - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> docIds; + std::vector<Document::SP> docs; + std::vector<DocumentId> docIds; std::vector<std::string> infoMessages; getMessagesAndReply(1, getSession(0), docs, docIds, infoMessages, api::ReturnCode::INTERNAL_FAILURE); @@ -587,8 +586,8 @@ TEST_F(VisitorTest, no_document_api_resending_for_failed_visitor) { sendGetIterReply(*getIterCmd, api::ReturnCode(api::ReturnCode::OK), 2, true); } - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> docIds; + std::vector<Document::SP> docs; + std::vector<DocumentId> docIds; std::vector<std::string> infoMessages; // Use non-critical result. Visitor info message should be received // after we send a NOT_CONNECTED reply. Failing this message as well @@ -690,8 +689,8 @@ TEST_F(VisitorTest, no_visitor_notification_for_transient_failures) { ASSERT_NO_FATAL_FAILURE(initializeTest()); ASSERT_NO_FATAL_FAILURE(sendInitialCreateVisitorAndGetIterRound()); - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> docIds; + std::vector<Document::SP> docs; + std::vector<DocumentId> docIds; std::vector<std::string> infoMessages; // Have to make sure time increases in visitor thread so that resend // times are reached. @@ -734,8 +733,8 @@ TEST_F(VisitorTest, notification_sent_if_transient_error_retried_many_times) { ASSERT_NO_FATAL_FAILURE(initializeTest()); sendInitialCreateVisitorAndGetIterRound(); - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> docIds; + std::vector<Document::SP> docs; + std::vector<DocumentId> docIds; std::vector<std::string> infoMessages; // Have to make sure time increases in visitor thread so that resend // times are reached. @@ -774,8 +773,8 @@ VisitorTest::doCompleteVisitingSession( 1, true); - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> docIds; + std::vector<Document::SP> docs; + std::vector<DocumentId> docIds; std::vector<std::string> infoMessages; getMessagesAndReply(1, getSession(0), docs, docIds, infoMessages); @@ -835,8 +834,8 @@ TEST_F(VisitorTest, no_more_iterators_sent_while_memory_used_above_limit) { std::this_thread::sleep_for(100ms); ASSERT_EQ(0, _bottom->getNumCommands()); - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> docIds; + std::vector<Document::SP> docs; + std::vector<DocumentId> docIds; std::vector<std::string> infoMessages; getMessagesAndReply(1, getSession(0), docs, docIds, infoMessages); @@ -898,8 +897,8 @@ struct ReindexingVisitorTest : VisitorTest { void respond_to_client_put(api::ReturnCode::Result result) { // Reply to the Put from "client" back to the visitor - std::vector<document::Document::SP> docs; - std::vector<document::DocumentId> doc_ids; + std::vector<Document::SP> docs; + std::vector<DocumentId> doc_ids; std::vector<std::string> info_messages; getMessagesAndReply(1, getSession(0), docs, doc_ids, info_messages, result); } |