From 0d542b3abe7a4769870edcfdbc90cb2568e87c2d Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 28 Sep 2018 21:32:58 +0200 Subject: Only allow document api protocol version 6.221 (C++) --- .../src/tests/messagebus/messagebus_test.cpp | 4 +- documentapi/src/tests/messages/CMakeLists.txt | 10 - documentapi/src/tests/messages/messages52app.cpp | 5 - documentapi/src/tests/messages/messages52test.cpp | 1061 -------------------- documentapi/src/tests/messages/messages52test.h | 56 -- documentapi/src/tests/messages/messages60test.cpp | 1029 ++++++++++++++++++- documentapi/src/tests/messages/messages60test.h | 48 +- .../documentapi/messagebus/documentprotocol.cpp | 78 +- 8 files changed, 1084 insertions(+), 1207 deletions(-) delete mode 100644 documentapi/src/tests/messages/messages52app.cpp delete mode 100644 documentapi/src/tests/messages/messages52test.cpp delete mode 100644 documentapi/src/tests/messages/messages52test.h diff --git a/documentapi/src/tests/messagebus/messagebus_test.cpp b/documentapi/src/tests/messagebus/messagebus_test.cpp index 22a46951ecc..05275870a2e 100644 --- a/documentapi/src/tests/messagebus/messagebus_test.cpp +++ b/documentapi/src/tests/messagebus/messagebus_test.cpp @@ -70,10 +70,10 @@ void Test::testMessage() { LoadTypeSet set; DocumentProtocol protocol(set, _repo); - Blob blob = protocol.encode(vespalib::Version(5,115), upd1); + Blob blob = protocol.encode(vespalib::Version(6,221), upd1); EXPECT_TRUE(blob.size() > 0); - Routable::UP dec1 = protocol.decode(vespalib::Version(5,115), blob); + Routable::UP dec1 = protocol.decode(vespalib::Version(6,221), blob); EXPECT_TRUE(dec1.get() != NULL); EXPECT_TRUE(dec1->isReply() == false); EXPECT_TRUE(dec1->getType() == DocumentProtocol::MESSAGE_UPDATEDOCUMENT); diff --git a/documentapi/src/tests/messages/CMakeLists.txt b/documentapi/src/tests/messages/CMakeLists.txt index 576557968e8..87f8d4d01cd 100644 --- a/documentapi/src/tests/messages/CMakeLists.txt +++ b/documentapi/src/tests/messages/CMakeLists.txt @@ -1,17 +1,7 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(documentapi_messages52_test_app TEST - SOURCES - testbase.cpp - messages52test.cpp - messages52app.cpp - DEPENDS - documentapi -) -vespa_add_test(NAME documentapi_messages52_test_app COMMAND documentapi_messages52_test_app) vespa_add_executable(documentapi_messages60_test_app TEST SOURCES testbase.cpp - messages52test.cpp messages60test.cpp messages60app.cpp DEPENDS diff --git a/documentapi/src/tests/messages/messages52app.cpp b/documentapi/src/tests/messages/messages52app.cpp deleted file mode 100644 index 4a925fd554f..00000000000 --- a/documentapi/src/tests/messages/messages52app.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "messages52test.h" - -TEST_APPHOOK(Messages52Test); diff --git a/documentapi/src/tests/messages/messages52test.cpp b/documentapi/src/tests/messages/messages52test.cpp deleted file mode 100644 index 21307326a75..00000000000 --- a/documentapi/src/tests/messages/messages52test.cpp +++ /dev/null @@ -1,1061 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// @author Vegard Sjonfjell - -#include "messages52test.h" -#include -#include -#include -#include -#include -#include -#include -#include - -using document::DataType; -using document::DocumentTypeRepo; - -/////////////////////////////////////////////////////////////////////////////// -// -// Setup -// -/////////////////////////////////////////////////////////////////////////////// - -Messages52Test::Messages52Test() -{ - // This list MUST mirror the list of routable factories from the DocumentProtocol constructor that support - // version 5.0. When adding tests to this list, please KEEP THEM ORDERED alphabetically like they are now. - putTest(DocumentProtocol::MESSAGE_CREATEVISITOR, TEST_METHOD(Messages52Test::testCreateVisitorMessage)); - putTest(DocumentProtocol::MESSAGE_DESTROYVISITOR, TEST_METHOD(Messages52Test::testDestroyVisitorMessage)); - putTest(DocumentProtocol::MESSAGE_DOCUMENTLIST, TEST_METHOD(Messages52Test::testDocumentListMessage)); - putTest(DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, TEST_METHOD(Messages52Test::testDocumentSummaryMessage)); - putTest(DocumentProtocol::MESSAGE_EMPTYBUCKETS, TEST_METHOD(Messages52Test::testEmptyBucketsMessage)); - putTest(DocumentProtocol::MESSAGE_GETBUCKETLIST, TEST_METHOD(Messages52Test::testGetBucketListMessage)); - putTest(DocumentProtocol::MESSAGE_GETBUCKETSTATE, TEST_METHOD(Messages52Test::testGetBucketStateMessage)); - putTest(DocumentProtocol::MESSAGE_GETDOCUMENT, TEST_METHOD(Messages52Test::testGetDocumentMessage)); - putTest(DocumentProtocol::MESSAGE_MAPVISITOR, TEST_METHOD(Messages52Test::testMapVisitorMessage)); - putTest(DocumentProtocol::MESSAGE_PUTDOCUMENT, TEST_METHOD(Messages52Test::testPutDocumentMessage)); - putTest(DocumentProtocol::MESSAGE_QUERYRESULT, TEST_METHOD(Messages52Test::testQueryResultMessage)); - putTest(DocumentProtocol::MESSAGE_REMOVEDOCUMENT, TEST_METHOD(Messages52Test::testRemoveDocumentMessage)); - putTest(DocumentProtocol::MESSAGE_REMOVELOCATION, TEST_METHOD(Messages52Test::testRemoveLocationMessage)); - putTest(DocumentProtocol::MESSAGE_SEARCHRESULT, TEST_METHOD(Messages52Test::testSearchResultMessage)); - putTest(DocumentProtocol::MESSAGE_STATBUCKET, TEST_METHOD(Messages52Test::testStatBucketMessage)); - putTest(DocumentProtocol::MESSAGE_UPDATEDOCUMENT, TEST_METHOD(Messages52Test::testUpdateDocumentMessage)); - putTest(DocumentProtocol::MESSAGE_VISITORINFO, TEST_METHOD(Messages52Test::testVisitorInfoMessage)); - - putTest(DocumentProtocol::REPLY_CREATEVISITOR, TEST_METHOD(Messages52Test::testCreateVisitorReply)); - putTest(DocumentProtocol::REPLY_DESTROYVISITOR, TEST_METHOD(Messages52Test::testDestroyVisitorReply)); - putTest(DocumentProtocol::REPLY_DOCUMENTIGNORED, TEST_METHOD(Messages52Test::testDocumentIgnoredReply)); - putTest(DocumentProtocol::REPLY_DOCUMENTLIST, TEST_METHOD(Messages52Test::testDocumentListReply)); - putTest(DocumentProtocol::REPLY_DOCUMENTSUMMARY, TEST_METHOD(Messages52Test::testDocumentSummaryReply)); - putTest(DocumentProtocol::REPLY_EMPTYBUCKETS, TEST_METHOD(Messages52Test::testEmptyBucketsReply)); - putTest(DocumentProtocol::REPLY_GETBUCKETLIST, TEST_METHOD(Messages52Test::testGetBucketListReply)); - putTest(DocumentProtocol::REPLY_GETBUCKETSTATE, TEST_METHOD(Messages52Test::testGetBucketStateReply)); - putTest(DocumentProtocol::REPLY_GETDOCUMENT, TEST_METHOD(Messages52Test::testGetDocumentReply)); - putTest(DocumentProtocol::REPLY_MAPVISITOR, TEST_METHOD(Messages52Test::testMapVisitorReply)); - putTest(DocumentProtocol::REPLY_PUTDOCUMENT, TEST_METHOD(Messages52Test::testPutDocumentReply)); - putTest(DocumentProtocol::REPLY_QUERYRESULT, TEST_METHOD(Messages52Test::testQueryResultReply)); - putTest(DocumentProtocol::REPLY_REMOVEDOCUMENT, TEST_METHOD(Messages52Test::testRemoveDocumentReply)); - putTest(DocumentProtocol::REPLY_REMOVELOCATION, TEST_METHOD(Messages52Test::testRemoveLocationReply)); - putTest(DocumentProtocol::REPLY_SEARCHRESULT, TEST_METHOD(Messages52Test::testSearchResultReply)); - putTest(DocumentProtocol::REPLY_STATBUCKET, TEST_METHOD(Messages52Test::testStatBucketReply)); - putTest(DocumentProtocol::REPLY_UPDATEDOCUMENT, TEST_METHOD(Messages52Test::testUpdateDocumentReply)); - putTest(DocumentProtocol::REPLY_VISITORINFO, TEST_METHOD(Messages52Test::testVisitorInfoReply)); - putTest(DocumentProtocol::REPLY_WRONGDISTRIBUTION, TEST_METHOD(Messages52Test::testWrongDistributionReply)); -} - - - -/////////////////////////////////////////////////////////////////////////////// -// -// Tests -// -/////////////////////////////////////////////////////////////////////////////// - -static const int MESSAGE_BASE_LENGTH = 5; - -namespace { - -document::Document::SP -createDoc(const DocumentTypeRepo &repo, const string &type_name, const string &id) -{ - return document::Document::SP(new document::Document( - *repo.getDocumentType(type_name), - document::DocumentId(id))); -} - -} // namespace - -bool -Messages52Test::testGetBucketListMessage() -{ - GetBucketListMessage msg(document::BucketId(16, 123)); - msg.setLoadType(_loadTypes["foo"]); - EXPECT_EQUAL(string("foo"), msg.getLoadType().getName()); - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 12u, serialize("GetBucketListMessage", msg)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("GetBucketListMessage", DocumentProtocol::MESSAGE_GETBUCKETLIST, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - GetBucketListMessage &ref = static_cast(*obj); - EXPECT_EQUAL(string("foo"), ref.getLoadType().getName()); - EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucketId()); - } - } - return true; -} - -bool -Messages52Test::testEmptyBucketsMessage() -{ - std::vector bids; - for (size_t i=0; i < 13; ++i) { - bids.push_back(document::BucketId(16, i)); - } - - EmptyBucketsMessage msg(bids); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 112u, serialize("EmptyBucketsMessage", msg)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("EmptyBucketsMessage", DocumentProtocol::MESSAGE_EMPTYBUCKETS, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - EmptyBucketsMessage &ref = static_cast(*obj); - for (size_t i=0; i < 13; ++i) { - EXPECT_EQUAL(document::BucketId(16, i), ref.getBucketIds()[i]); - } - } - } - return true; -} - - -bool -Messages52Test::testStatBucketMessage() -{ - StatBucketMessage msg(document::BucketId(16, 123), "id.user=123"); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 27u, serialize("StatBucketMessage", msg)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("StatBucketMessage", DocumentProtocol::MESSAGE_STATBUCKET, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - StatBucketMessage &ref = static_cast(*obj); - EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucketId()); - EXPECT_EQUAL("id.user=123", ref.getDocumentSelection()); - } - } - return true; -} - -bool -Messages52Test::testCreateVisitorMessage() { - CreateVisitorMessage tmp("SomeLibrary", "myvisitor", "newyork", "london"); - tmp.setDocumentSelection("true and false or true"); - tmp.getParameters().set("myvar", "somevalue"); - tmp.getParameters().set("anothervar", uint64_t(34)); - tmp.getBuckets().push_back(document::BucketId(16, 1234)); - tmp.setVisitRemoves(true); - tmp.setFieldSet("foo bar"); - tmp.setVisitorOrdering(document::OrderingSpecification::DESCENDING); - tmp.setMaxBucketsPerVisitor(2); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)178, serialize("CreateVisitorMessage", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("CreateVisitorMessage", DocumentProtocol::MESSAGE_CREATEVISITOR, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - CreateVisitorMessage &ref = static_cast(*obj); - - EXPECT_EQUAL(string("SomeLibrary"), ref.getLibraryName()); - EXPECT_EQUAL(string("myvisitor"), ref.getInstanceId()); - EXPECT_EQUAL(string("newyork"), ref.getControlDestination()); - EXPECT_EQUAL(string("london"), ref.getDataDestination()); - EXPECT_EQUAL(string("true and false or true"), ref.getDocumentSelection()); - EXPECT_EQUAL(string("foo bar"), ref.getFieldSet()); - EXPECT_EQUAL(uint32_t(8), ref.getMaximumPendingReplyCount()); - EXPECT_EQUAL(true, ref.visitRemoves()); - EXPECT_EQUAL(false, ref.visitHeadersOnly()); - EXPECT_EQUAL(false, ref.visitInconsistentBuckets()); - EXPECT_EQUAL(size_t(1), ref.getBuckets().size()); - EXPECT_EQUAL(document::BucketId(16, 1234), ref.getBuckets()[0]); - EXPECT_EQUAL(string("somevalue"), ref.getParameters().get("myvar")); - EXPECT_EQUAL(uint64_t(34), ref.getParameters().get("anothervar", uint64_t(1))); - EXPECT_EQUAL(document::OrderingSpecification::DESCENDING, ref.getVisitorOrdering()); - EXPECT_EQUAL(uint32_t(2), ref.getMaxBucketsPerVisitor()); - } - } - return true; -} - -bool -Messages52Test::testDestroyVisitorMessage() -{ - DestroyVisitorMessage tmp("myvisitor"); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)17, serialize("DestroyVisitorMessage", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("DestroyVisitorMessage", DocumentProtocol::MESSAGE_DESTROYVISITOR, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - DestroyVisitorMessage &ref = static_cast(*obj); - EXPECT_EQUAL(string("myvisitor"), ref.getInstanceId()); - } - } - return true; -} - -bool -Messages52Test::testDocumentListMessage() -{ - document::Document::SP doc = - createDoc(getTypeRepo(), "testdoc", "userdoc:scheme:1234:"); - DocumentListMessage::Entry entry(1234, doc, false); - - DocumentListMessage tmp(document::BucketId(16, 1234)); - tmp.getDocuments().push_back(entry); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)63, serialize("DocumentListMessage", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("DocumentListMessage", DocumentProtocol::MESSAGE_DOCUMENTLIST, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - DocumentListMessage &ref = static_cast(*obj); - - EXPECT_EQUAL("userdoc:scheme:1234:", ref.getDocuments()[0].getDocument()->getId().toString()); - EXPECT_EQUAL(1234, ref.getDocuments()[0].getTimestamp()); - EXPECT_TRUE(!ref.getDocuments()[0].isRemoveEntry()); - } - } - return true; -} - - -bool -Messages52Test::testRemoveLocationMessage() -{ - { - document::BucketIdFactory factory; - document::select::Parser parser(getTypeRepo(), factory); - RemoveLocationMessage msg(factory, parser, "id.group == \"mygroup\""); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 29u, serialize("RemoveLocationMessage", msg)); - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("RemoveLocationMessage", DocumentProtocol::MESSAGE_REMOVELOCATION, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - RemoveLocationMessage &ref = static_cast(*obj); - EXPECT_EQUAL(string("id.group == \"mygroup\""), ref.getDocumentSelection()); - // FIXME add to wire format, currently hardcoded. - EXPECT_EQUAL(string(document::FixedBucketSpaces::default_space_name()), ref.getBucketSpace()); - } - } - } - - return true; -} - - - -bool -Messages52Test::testDocumentSummaryMessage() -{ - DocumentSummaryMessage srm; - EXPECT_EQUAL(srm.hasSequenceId(), false); - EXPECT_EQUAL(srm.getSummaryCount(), size_t(0)); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(12), serialize("DocumentSummaryMessage-1", srm)); - - mbus::Routable::UP routable = deserialize("DocumentSummaryMessage-1", DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - DocumentSummaryMessage * dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getSummaryCount(), size_t(0)); - - srm.addSummary("doc1", "summary1", 8); - srm.addSummary("aoc17", "summary45", 9); - - const void *summary(NULL); - const char *docId(NULL); - size_t sz(0); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 52u, serialize("DocumentSummaryMessage-2", srm)); - routable = deserialize("DocumentSummaryMessage-2", DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getSummaryCount(), size_t(2)); - dm->getSummary(0, docId, summary, sz); - EXPECT_EQUAL(sz, 8u); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - EXPECT_EQUAL(memcmp("summary1", summary, sz), 0); - dm->getSummary(1, docId, summary, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(strcmp("aoc17", docId), 0); - EXPECT_EQUAL(memcmp("summary45", summary, sz), 0); - - srm.sort(); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 52u, serialize("DocumentSummaryMessage-3", srm)); - routable = deserialize("DocumentSummaryMessage-3", DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getSummaryCount(), size_t(2)); - dm->getSummary(0, docId, summary, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(strcmp("aoc17", docId), 0); - EXPECT_EQUAL(memcmp("summary45", summary, sz), 0); - dm->getSummary(1, docId, summary, sz); - EXPECT_EQUAL(sz, 8u); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - EXPECT_EQUAL(memcmp("summary1", summary, sz), 0); - return true; -} - -bool -Messages52Test::testGetDocumentMessage() -{ - GetDocumentMessage tmp(document::DocumentId("doc:scheme:"), "foo bar"); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)27, serialize("GetDocumentMessage", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("GetDocumentMessage", DocumentProtocol::MESSAGE_GETDOCUMENT, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - GetDocumentMessage &ref = static_cast(*obj); - EXPECT_EQUAL(string("doc:scheme:"), ref.getDocumentId().toString()); - EXPECT_EQUAL(string("foo bar"), ref.getFieldSet()); - } - } - return true; -} - -bool -Messages52Test::testMapVisitorMessage() -{ - MapVisitorMessage tmp; - tmp.getData().set("foo", 3); - tmp.getData().set("bar", 5); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)32, serialize("MapVisitorMessage", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("MapVisitorMessage", DocumentProtocol::MESSAGE_MAPVISITOR, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - MapVisitorMessage &ref = static_cast(*obj); - EXPECT_EQUAL(3, ref.getData().get("foo", 0)); - EXPECT_EQUAL(5, ref.getData().get("bar", 0)); - } - } - return true; -} - -bool -Messages52Test::testCreateVisitorReply() -{ - CreateVisitorReply reply(DocumentProtocol::REPLY_CREATEVISITOR); - reply.setLastBucket(document::BucketId(16, 123)); - vdslib::VisitorStatistics vs; - vs.setBucketsVisited(3); - vs.setDocumentsVisited(1000); - vs.setBytesVisited(1024000); - vs.setDocumentsReturned(123); - vs.setBytesReturned(512000); - vs.setSecondPassDocumentsReturned(456); - vs.setSecondPassBytesReturned(789100); - reply.setVisitorStatistics(vs); - - EXPECT_EQUAL(65u, serialize("CreateVisitorReply", reply)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("CreateVisitorReply", DocumentProtocol::REPLY_CREATEVISITOR, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - CreateVisitorReply &ref = static_cast(*obj); - - EXPECT_EQUAL(ref.getLastBucket(), document::BucketId(16, 123)); - EXPECT_EQUAL(ref.getVisitorStatistics().getBucketsVisited(), (uint32_t)3); - EXPECT_EQUAL(ref.getVisitorStatistics().getDocumentsVisited(), (uint64_t)1000); - EXPECT_EQUAL(ref.getVisitorStatistics().getBytesVisited(), (uint64_t)1024000); - EXPECT_EQUAL(ref.getVisitorStatistics().getDocumentsReturned(), (uint64_t)123); - EXPECT_EQUAL(ref.getVisitorStatistics().getBytesReturned(), (uint64_t)512000); - EXPECT_EQUAL(ref.getVisitorStatistics().getSecondPassDocumentsReturned(), (uint64_t)456); - EXPECT_EQUAL(ref.getVisitorStatistics().getSecondPassBytesReturned(), (uint64_t)789100); - } - } - return true; -} - -bool -Messages52Test::testPutDocumentMessage() -{ - auto doc = createDoc(getTypeRepo(), "testdoc", "doc:scheme:"); - PutDocumentMessage msg(doc); - - msg.setTimestamp(666); - msg.setCondition(TestAndSetCondition("There's just one condition")); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + - 41u + - serializedLength(msg.getCondition().getSelection()), - serialize("PutDocumentMessage", msg)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - auto routableUp = deserialize("PutDocumentMessage", DocumentProtocol::MESSAGE_PUTDOCUMENT, lang); - if (EXPECT_TRUE(routableUp.get() != nullptr)) { - auto & deserializedMsg = static_cast(*routableUp); - - EXPECT_EQUAL(msg.getDocument().getType().getName(), deserializedMsg.getDocument().getType().getName()); - EXPECT_EQUAL(msg.getDocument().getId().toString(), deserializedMsg.getDocument().getId().toString()); - EXPECT_EQUAL(msg.getTimestamp(), deserializedMsg.getTimestamp()); - EXPECT_EQUAL(67u, deserializedMsg.getApproxSize()); - EXPECT_EQUAL(msg.getCondition().getSelection(), deserializedMsg.getCondition().getSelection()); - } - } - - return true; -} - -bool -Messages52Test::testGetBucketStateMessage() -{ - GetBucketStateMessage tmp; - tmp.setBucketId(document::BucketId(16, 666)); - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 12u, serialize("GetBucketStateMessage", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("GetBucketStateMessage", DocumentProtocol::MESSAGE_GETBUCKETSTATE, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - GetBucketStateMessage &ref = static_cast(*obj); - - EXPECT_EQUAL(16u, ref.getBucketId().getUsedBits()); - EXPECT_EQUAL(4611686018427388570ull, ref.getBucketId().getId()); - } - } - return true; -} - -bool -Messages52Test::testPutDocumentReply() -{ - WriteDocumentReply reply(DocumentProtocol::REPLY_PUTDOCUMENT); - reply.setHighestModificationTimestamp(30); - - EXPECT_EQUAL(13u, serialize("PutDocumentReply", reply)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("PutDocumentReply", DocumentProtocol::REPLY_PUTDOCUMENT, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - WriteDocumentReply &ref = static_cast(*obj); - EXPECT_EQUAL(30u, ref.getHighestModificationTimestamp()); - } - } - return true; -} - -bool -Messages52Test::testUpdateDocumentReply() -{ - UpdateDocumentReply reply; - reply.setWasFound(false); - reply.setHighestModificationTimestamp(30); - - EXPECT_EQUAL(14u, serialize("UpdateDocumentReply", reply)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("UpdateDocumentReply", DocumentProtocol::REPLY_UPDATEDOCUMENT, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - UpdateDocumentReply &ref = static_cast(*obj); - EXPECT_EQUAL(30u, ref.getHighestModificationTimestamp()); - EXPECT_EQUAL(false, ref.wasFound()); - } - } - return true; -} - -bool -Messages52Test::testRemoveDocumentMessage() -{ - RemoveDocumentMessage msg(document::DocumentId("doc:scheme:")); - - msg.setCondition(TestAndSetCondition("There's just one condition")); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(16) + serializedLength(msg.getCondition().getSelection()), serialize("RemoveDocumentMessage", msg)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - auto routablePtr = deserialize("RemoveDocumentMessage", DocumentProtocol::MESSAGE_REMOVEDOCUMENT, lang); - - if (EXPECT_TRUE(routablePtr.get() != nullptr)) { - auto & ref = static_cast(*routablePtr); - EXPECT_EQUAL(string("doc:scheme:"), ref.getDocumentId().toString()); - EXPECT_EQUAL(msg.getCondition().getSelection(), ref.getCondition().getSelection()); - } - } - return true; -} - -bool -Messages52Test::testRemoveDocumentReply() -{ - RemoveDocumentReply reply; - std::vector ts; - reply.setWasFound(false); - reply.setHighestModificationTimestamp(30); - - EXPECT_EQUAL(14u, serialize("RemoveDocumentReply", reply)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("RemoveDocumentReply", DocumentProtocol::REPLY_REMOVEDOCUMENT, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - RemoveDocumentReply &ref = static_cast(*obj); - EXPECT_EQUAL(30u, ref.getHighestModificationTimestamp()); - EXPECT_EQUAL(false, ref.wasFound()); - } - } - return true; -} - -bool -Messages52Test::testSearchResultMessage() -{ - SearchResultMessage srm; - EXPECT_EQUAL(srm.getSequenceId(), 0u); - EXPECT_EQUAL(srm.getHitCount(), 0u); - EXPECT_EQUAL(srm.getAggregatorList().getSerializedSize(), 4u); - EXPECT_EQUAL(srm.vdslib::SearchResult::getSerializedSize(), 20u); - EXPECT_EQUAL(srm.getSerializedSize(), 20u); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(24), serialize("SearchResultMessage-1", srm)); - - mbus::Routable::UP routable = deserialize("SearchResultMessage-1", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - SearchResultMessage * dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getSequenceId(), size_t(0)); - EXPECT_EQUAL(dm->getHitCount(), size_t(0)); - - srm.addHit(0, "doc1", 89); - srm.addHit(1, "doc17", 109); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 55u, serialize("SearchResultMessage-2", srm)); - routable = deserialize("SearchResultMessage-2", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getHitCount(), size_t(2)); - const char *docId; - SearchResultMessage::RankType rank; - dm->getHit(0, docId, rank); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - dm->getHit(1, docId, rank); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - - srm.sort(); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 55u, serialize("SearchResultMessage-3", srm)); - routable = deserialize("SearchResultMessage-3", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getHitCount(), size_t(2)); - dm->getHit(0, docId, rank); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - dm->getHit(1, docId, rank); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - - SearchResultMessage srm2; - srm2.addHit(0, "doc1", 89, "sortdata2", 9); - srm2.addHit(1, "doc17", 109, "sortdata1", 9); - srm2.addHit(2, "doc18", 90, "sortdata3", 9); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 108u, serialize("SearchResultMessage-4", srm2)); - routable = deserialize("SearchResultMessage-4", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getHitCount(), size_t(3)); - dm->getHit(0, docId, rank); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - dm->getHit(1, docId, rank); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - dm->getHit(2, docId, rank); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(90)); - EXPECT_EQUAL(strcmp("doc18", docId), 0); - - srm2.sort(); - const void *buf; - size_t sz; - srm2.getHit(0, docId, rank); - srm2.getSortBlob(0, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - srm2.getHit(1, docId, rank); - srm2.getSortBlob(1, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - srm2.getHit(2, docId, rank); - srm2.getSortBlob(2, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(90)); - EXPECT_EQUAL(strcmp("doc18", docId), 0); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 108u, serialize("SearchResultMessage-5", srm2)); - routable = deserialize("SearchResultMessage-5", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - EXPECT_EQUAL(dm->getHitCount(), size_t(3)); - dm->getHit(0, docId, rank); - dm->getSortBlob(0, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - dm->getHit(1, docId, rank); - dm->getSortBlob(1, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - dm->getHit(2, docId, rank); - dm->getSortBlob(2, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); - EXPECT_EQUAL(rank, SearchResultMessage::RankType(90)); - EXPECT_EQUAL(strcmp("doc18", docId), 0); - return true; -} - -bool -Messages52Test::testUpdateDocumentMessage() -{ - const DocumentTypeRepo & repo = getTypeRepo(); - const document::DocumentType & docType = *repo.getDocumentType("testdoc"); - - auto docUpdate = std::make_shared(repo, docType, document::DocumentId("doc:scheme:")); - - docUpdate->addFieldPathUpdate(document::FieldPathUpdate::CP( - new document::RemoveFieldPathUpdate("intfield", "testdoc.intfield > 0"))); - - UpdateDocumentMessage msg(docUpdate); - msg.setOldTimestamp(666u); - msg.setNewTimestamp(777u); - msg.setCondition(TestAndSetCondition("There's just one condition")); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 89u + serializedLength(msg.getCondition().getSelection()), serialize("UpdateDocumentMessage", msg)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - auto routableUp = deserialize("UpdateDocumentMessage", DocumentProtocol::MESSAGE_UPDATEDOCUMENT, lang); - - if (EXPECT_TRUE(routableUp.get() != nullptr)) { - auto & deserializedMsg = static_cast(*routableUp); - EXPECT_EQUAL(msg.getDocumentUpdate(), deserializedMsg.getDocumentUpdate()); - EXPECT_EQUAL(msg.getOldTimestamp(), deserializedMsg.getOldTimestamp()); - EXPECT_EQUAL(msg.getNewTimestamp(), deserializedMsg.getNewTimestamp()); - EXPECT_EQUAL(115u, deserializedMsg.getApproxSize()); - EXPECT_EQUAL(msg.getCondition().getSelection(), deserializedMsg.getCondition().getSelection()); - } - } - return true; -} - -bool -Messages52Test::testQueryResultMessage() -{ - QueryResultMessage srm; - vdslib::SearchResult & sr(srm.getSearchResult()); - EXPECT_EQUAL(srm.getSequenceId(), 0u); - EXPECT_EQUAL(sr.getHitCount(), 0u); - EXPECT_EQUAL(sr.getAggregatorList().getSerializedSize(), 4u); - EXPECT_EQUAL(sr.getSerializedSize(), 20u); - EXPECT_EQUAL(srm.getApproxSize(), 28u); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(32), serialize("QueryResultMessage-1", srm)); - - mbus::Routable::UP routable = deserialize("QueryResultMessage-1", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - QueryResultMessage * dm = static_cast(routable.get()); - vdslib::SearchResult * dr(&dm->getSearchResult()); - EXPECT_EQUAL(dm->getSequenceId(), size_t(0)); - EXPECT_EQUAL(dr->getHitCount(), size_t(0)); - - sr.addHit(0, "doc1", 89); - sr.addHit(1, "doc17", 109); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 63u, serialize("QueryResultMessage-2", srm)); - routable = deserialize("QueryResultMessage-2", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - dr = &dm->getSearchResult(); - EXPECT_EQUAL(dr->getHitCount(), size_t(2)); - const char *docId; - vdslib::SearchResult::RankType rank; - dr->getHit(0, docId, rank); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - dr->getHit(1, docId, rank); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - - sr.sort(); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 63u, serialize("QueryResultMessage-3", srm)); - routable = deserialize("QueryResultMessage-3", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - dr = &dm->getSearchResult(); - EXPECT_EQUAL(dr->getHitCount(), size_t(2)); - dr->getHit(0, docId, rank); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - dr->getHit(1, docId, rank); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - - QueryResultMessage srm2; - vdslib::SearchResult & sr2(srm2.getSearchResult()); - sr2.addHit(0, "doc1", 89, "sortdata2", 9); - sr2.addHit(1, "doc17", 109, "sortdata1", 9); - sr2.addHit(2, "doc18", 90, "sortdata3", 9); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 116u, serialize("QueryResultMessage-4", srm2)); - routable = deserialize("QueryResultMessage-4", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - dr = &dm->getSearchResult(); - EXPECT_EQUAL(dr->getHitCount(), size_t(3)); - dr->getHit(0, docId, rank); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - dr->getHit(1, docId, rank); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - dr->getHit(2, docId, rank); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(90)); - EXPECT_EQUAL(strcmp("doc18", docId), 0); - - sr2.sort(); - const void *buf; - size_t sz; - sr2.getHit(0, docId, rank); - sr2.getSortBlob(0, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - sr2.getHit(1, docId, rank); - sr2.getSortBlob(1, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - sr2.getHit(2, docId, rank); - sr2.getSortBlob(2, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(90)); - EXPECT_EQUAL(strcmp("doc18", docId), 0); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 116u, serialize("QueryResultMessage-5", srm2)); - routable = deserialize("QueryResultMessage-5", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); - if (!EXPECT_TRUE(routable.get() != NULL)) { - return false; - } - dm = static_cast(routable.get()); - dr = &dm->getSearchResult(); - EXPECT_EQUAL(dr->getHitCount(), size_t(3)); - dr->getHit(0, docId, rank); - dr->getSortBlob(0, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); - EXPECT_EQUAL(strcmp("doc17", docId), 0); - dr->getHit(1, docId, rank); - dr->getSortBlob(1, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); - EXPECT_EQUAL(strcmp("doc1", docId), 0); - dr->getHit(2, docId, rank); - dr->getSortBlob(2, buf, sz); - EXPECT_EQUAL(sz, 9u); - EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); - EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(90)); - EXPECT_EQUAL(strcmp("doc18", docId), 0); - return true; -} - -bool -Messages52Test::testQueryResultReply() -{ - return tryVisitorReply("QueryResultReply", DocumentProtocol::REPLY_QUERYRESULT); -} - -bool -Messages52Test::testVisitorInfoMessage() -{ - - VisitorInfoMessage tmp; - tmp.getFinishedBuckets().push_back(document::BucketId(16, 1)); - tmp.getFinishedBuckets().push_back(document::BucketId(16, 2)); - tmp.getFinishedBuckets().push_back(document::BucketId(16, 4)); - string utf8 = "error message: \u00e6\u00c6\u00f8\u00d8\u00e5\u00c5\u00f6\u00d6"; - tmp.setErrorMessage(utf8); - - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 67u, serialize("VisitorInfoMessage", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("VisitorInfoMessage", DocumentProtocol::MESSAGE_VISITORINFO, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - VisitorInfoMessage &ref = static_cast(*obj); - EXPECT_EQUAL(document::BucketId(16, 1), ref.getFinishedBuckets()[0]); - EXPECT_EQUAL(document::BucketId(16, 2), ref.getFinishedBuckets()[1]); - EXPECT_EQUAL(document::BucketId(16, 4), ref.getFinishedBuckets()[2]); - EXPECT_EQUAL(utf8, ref.getErrorMessage()); - } - } - return true; -} - -bool -Messages52Test::testDestroyVisitorReply() -{ - return tryDocumentReply("DestroyVisitorReply", DocumentProtocol::REPLY_DESTROYVISITOR); -} - -bool -Messages52Test::testDocumentIgnoredReply() -{ - DocumentIgnoredReply tmp; - serialize("DocumentIgnoredReply", tmp); - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj( - deserialize("DocumentIgnoredReply", - DocumentProtocol::REPLY_DOCUMENTIGNORED, lang)); - EXPECT_TRUE(obj.get() != NULL); - } - return true; -} - -bool -Messages52Test::testDocumentListReply() -{ - return tryVisitorReply("DocumentListReply", DocumentProtocol::REPLY_DOCUMENTLIST); -} - -bool -Messages52Test::testDocumentSummaryReply() -{ - return tryVisitorReply("DocumentSummaryReply", DocumentProtocol::REPLY_DOCUMENTSUMMARY); -} - -bool -Messages52Test::testGetDocumentReply() -{ - document::Document::SP doc = - createDoc(getTypeRepo(), "testdoc", "doc:scheme:"); - GetDocumentReply tmp(doc); - - EXPECT_EQUAL((size_t)43, serialize("GetDocumentReply", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("GetDocumentReply", DocumentProtocol::REPLY_GETDOCUMENT, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - GetDocumentReply &ref = static_cast(*obj); - - EXPECT_EQUAL(string("testdoc"), ref.getDocument().getType().getName()); - EXPECT_EQUAL(string("doc:scheme:"), ref.getDocument().getId().toString()); - } - } - return true; -} - -bool -Messages52Test::testMapVisitorReply() -{ - return tryVisitorReply("MapVisitorReply", DocumentProtocol::REPLY_MAPVISITOR); -} - -bool -Messages52Test::testSearchResultReply() -{ - return tryVisitorReply("SearchResultReply", DocumentProtocol::REPLY_SEARCHRESULT); -} - -bool -Messages52Test::testStatBucketReply() -{ - StatBucketReply msg; - msg.setResults("These are the votes of the Norwegian jury"); - - EXPECT_EQUAL(50u, serialize("StatBucketReply", msg)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("StatBucketReply", DocumentProtocol::REPLY_STATBUCKET, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - StatBucketReply &ref = static_cast(*obj); - EXPECT_EQUAL("These are the votes of the Norwegian jury", ref.getResults()); - } - } - return true; -} - -bool -Messages52Test::testVisitorInfoReply() -{ - return tryVisitorReply("VisitorInfoReply", DocumentProtocol::REPLY_VISITORINFO); -} - -bool -Messages52Test::testWrongDistributionReply() -{ - WrongDistributionReply tmp("distributor:3 storage:2"); - - serialize("WrongDistributionReply", tmp); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("WrongDistributionReply", DocumentProtocol::REPLY_WRONGDISTRIBUTION, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - WrongDistributionReply &ref = static_cast(*obj); - EXPECT_EQUAL(string("distributor:3 storage:2"), ref.getSystemState()); - } - } - return true; -} - -bool -Messages52Test::testGetBucketListReply() -{ - GetBucketListReply reply; - reply.getBuckets().push_back(GetBucketListReply::BucketInfo(document::BucketId(16, 123), "foo")); - reply.getBuckets().push_back(GetBucketListReply::BucketInfo(document::BucketId(17, 1123), "bar")); - reply.getBuckets().push_back(GetBucketListReply::BucketInfo(document::BucketId(18, 11123), "zoink")); - - EXPECT_EQUAL(56u, serialize("GetBucketListReply", reply)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("GetBucketListReply", DocumentProtocol::REPLY_GETBUCKETLIST, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - GetBucketListReply &ref = static_cast(*obj); - - EXPECT_EQUAL(ref.getBuckets()[0], GetBucketListReply::BucketInfo(document::BucketId(16, 123), "foo")); - EXPECT_EQUAL(ref.getBuckets()[1], GetBucketListReply::BucketInfo(document::BucketId(17, 1123), "bar")); - EXPECT_EQUAL(ref.getBuckets()[2], GetBucketListReply::BucketInfo(document::BucketId(18, 11123), "zoink")); - } - } - return true; -} - -bool -Messages52Test::testGetBucketStateReply() -{ - document::GlobalId foo = document::DocumentId("doc:scheme:foo").getGlobalId(); - document::GlobalId bar = document::DocumentId("doc:scheme:bar").getGlobalId(); - - GetBucketStateReply reply; - reply.getBucketState().push_back(DocumentState(foo, 777, false)); - reply.getBucketState().push_back(DocumentState(bar, 888, true)); - EXPECT_EQUAL(53u, serialize("GetBucketStateReply", reply)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("GetBucketStateReply", DocumentProtocol::REPLY_GETBUCKETSTATE, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - GetBucketStateReply &ref = static_cast(*obj); - - EXPECT_EQUAL(777u, ref.getBucketState()[0].getTimestamp()); - EXPECT_EQUAL(foo, ref.getBucketState()[0].getGlobalId()); - EXPECT_EQUAL(false, ref.getBucketState()[0].isRemoveEntry()); - EXPECT_EQUAL(888u, ref.getBucketState()[1].getTimestamp()); - EXPECT_EQUAL(bar, ref.getBucketState()[1].getGlobalId()); - EXPECT_EQUAL(true, ref.getBucketState()[1].isRemoveEntry()); - } - } - return true; -} - -bool -Messages52Test::testEmptyBucketsReply() -{ - return tryVisitorReply("EmptyBucketsReply", DocumentProtocol::REPLY_EMPTYBUCKETS); -} - -bool -Messages52Test::testRemoveLocationReply() -{ - DocumentReply tmp(DocumentProtocol::REPLY_REMOVELOCATION); - - EXPECT_EQUAL((uint32_t)5, serialize("RemoveLocationReply", tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("RemoveLocationReply", DocumentProtocol::REPLY_REMOVELOCATION, lang); - EXPECT_TRUE(obj.get() != NULL); - } - return true; -} - - - -//////////////////////////////////////////////////////////////////////////////// -// -// Utilities -// -//////////////////////////////////////////////////////////////////////////////// - -bool -Messages52Test::tryDocumentReply(const string &filename, uint32_t type) -{ - DocumentReply tmp(type); - - EXPECT_EQUAL((uint32_t)5, serialize(filename, tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize(filename, type, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - DocumentReply *ref = dynamic_cast(obj.get()); - EXPECT_TRUE(ref != NULL); - } - } - return true; -} - -bool -Messages52Test::tryVisitorReply(const string &filename, uint32_t type) -{ - VisitorReply tmp(type); - - EXPECT_EQUAL((uint32_t)5, serialize(filename, tmp)); - - for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize(filename, type, lang); - if (EXPECT_TRUE(obj.get() != NULL)) { - VisitorReply *ref = dynamic_cast(obj.get()); - EXPECT_TRUE(ref != NULL); - } - } - return true; -} diff --git a/documentapi/src/tests/messages/messages52test.h b/documentapi/src/tests/messages/messages52test.h deleted file mode 100644 index 6b019d77bde..00000000000 --- a/documentapi/src/tests/messages/messages52test.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// @author Vegard Sjonfjell -#pragma once - -#include "testbase.h" - -class Messages52Test : public TestBase { -protected: - const vespalib::Version getVersion() const override { return vespalib::Version(5, 115); } - bool shouldTestCoverage() const override { return true; } - bool tryDocumentReply(const string &filename, uint32_t type); - bool tryVisitorReply(const string &filename, uint32_t type); - - static size_t serializedLength(const string & str) { return sizeof(int32_t) + str.size(); } - -public: - Messages52Test(); - - bool testCreateVisitorMessage(); - bool testCreateVisitorReply(); - bool testDestroyVisitorMessage(); - bool testDestroyVisitorReply(); - bool testDocumentIgnoredReply(); - bool testDocumentListMessage(); - bool testDocumentListReply(); - bool testDocumentSummaryMessage(); - bool testDocumentSummaryReply(); - bool testEmptyBucketsMessage(); - bool testEmptyBucketsReply(); - bool testGetBucketListMessage(); - bool testGetBucketListReply(); - bool testGetBucketStateMessage(); - bool testGetBucketStateReply(); - bool testGetDocumentMessage(); - bool testGetDocumentReply(); - bool testMapVisitorMessage(); - bool testMapVisitorReply(); - bool testPutDocumentMessage(); - bool testPutDocumentReply(); - bool testQueryResultMessage(); - bool testQueryResultReply(); - bool testRemoveDocumentMessage(); - bool testRemoveDocumentReply(); - bool testRemoveLocationMessage(); - bool testRemoveLocationReply(); - bool testSearchResultMessage(); - bool testSearchResultReply(); - bool testStatBucketMessage(); - bool testStatBucketReply(); - bool testUpdateDocumentMessage(); - bool testUpdateDocumentReply(); - bool testVisitorInfoMessage(); - bool testVisitorInfoReply(); - bool testWrongDistributionReply(); -}; - diff --git a/documentapi/src/tests/messages/messages60test.cpp b/documentapi/src/tests/messages/messages60test.cpp index e553744452b..350bc368a64 100644 --- a/documentapi/src/tests/messages/messages60test.cpp +++ b/documentapi/src/tests/messages/messages60test.cpp @@ -1,20 +1,159 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// @author Vegard Sjonfjell #include "messages60test.h" +#include +#include +#include +#include +#include +#include #include +#include -static constexpr int MESSAGE_BASE_LENGTH = 5; +using document::DataType; +using document::DocumentTypeRepo; -Messages60Test::Messages60Test() { +/////////////////////////////////////////////////////////////////////////////// +// +// Setup +// +/////////////////////////////////////////////////////////////////////////////// + +Messages60Test::Messages60Test() +{ // This list MUST mirror the list of routable factories from the DocumentProtocol constructor that support - // version 6.x. When adding tests to this list, please KEEP THEM ORDERED alphabetically like they are now. + // version 5.0. When adding tests to this list, please KEEP THEM ORDERED alphabetically like they are now. putTest(DocumentProtocol::MESSAGE_CREATEVISITOR, TEST_METHOD(Messages60Test::testCreateVisitorMessage)); - putTest(DocumentProtocol::MESSAGE_STATBUCKET, TEST_METHOD(Messages60Test::testStatBucketMessage)); + putTest(DocumentProtocol::MESSAGE_DESTROYVISITOR, TEST_METHOD(Messages60Test::testDestroyVisitorMessage)); + putTest(DocumentProtocol::MESSAGE_DOCUMENTLIST, TEST_METHOD(Messages60Test::testDocumentListMessage)); + putTest(DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, TEST_METHOD(Messages60Test::testDocumentSummaryMessage)); + putTest(DocumentProtocol::MESSAGE_EMPTYBUCKETS, TEST_METHOD(Messages60Test::testEmptyBucketsMessage)); putTest(DocumentProtocol::MESSAGE_GETBUCKETLIST, TEST_METHOD(Messages60Test::testGetBucketListMessage)); + putTest(DocumentProtocol::MESSAGE_GETBUCKETSTATE, TEST_METHOD(Messages60Test::testGetBucketStateMessage)); + putTest(DocumentProtocol::MESSAGE_GETDOCUMENT, TEST_METHOD(Messages60Test::testGetDocumentMessage)); + putTest(DocumentProtocol::MESSAGE_MAPVISITOR, TEST_METHOD(Messages60Test::testMapVisitorMessage)); + putTest(DocumentProtocol::MESSAGE_PUTDOCUMENT, TEST_METHOD(Messages60Test::testPutDocumentMessage)); + putTest(DocumentProtocol::MESSAGE_QUERYRESULT, TEST_METHOD(Messages60Test::testQueryResultMessage)); + putTest(DocumentProtocol::MESSAGE_REMOVEDOCUMENT, TEST_METHOD(Messages60Test::testRemoveDocumentMessage)); + putTest(DocumentProtocol::MESSAGE_REMOVELOCATION, TEST_METHOD(Messages60Test::testRemoveLocationMessage)); + putTest(DocumentProtocol::MESSAGE_SEARCHRESULT, TEST_METHOD(Messages60Test::testSearchResultMessage)); + putTest(DocumentProtocol::MESSAGE_STATBUCKET, TEST_METHOD(Messages60Test::testStatBucketMessage)); + putTest(DocumentProtocol::MESSAGE_UPDATEDOCUMENT, TEST_METHOD(Messages60Test::testUpdateDocumentMessage)); + putTest(DocumentProtocol::MESSAGE_VISITORINFO, TEST_METHOD(Messages60Test::testVisitorInfoMessage)); + + putTest(DocumentProtocol::REPLY_CREATEVISITOR, TEST_METHOD(Messages60Test::testCreateVisitorReply)); + putTest(DocumentProtocol::REPLY_DESTROYVISITOR, TEST_METHOD(Messages60Test::testDestroyVisitorReply)); + putTest(DocumentProtocol::REPLY_DOCUMENTIGNORED, TEST_METHOD(Messages60Test::testDocumentIgnoredReply)); + putTest(DocumentProtocol::REPLY_DOCUMENTLIST, TEST_METHOD(Messages60Test::testDocumentListReply)); + putTest(DocumentProtocol::REPLY_DOCUMENTSUMMARY, TEST_METHOD(Messages60Test::testDocumentSummaryReply)); + putTest(DocumentProtocol::REPLY_EMPTYBUCKETS, TEST_METHOD(Messages60Test::testEmptyBucketsReply)); + putTest(DocumentProtocol::REPLY_GETBUCKETLIST, TEST_METHOD(Messages60Test::testGetBucketListReply)); + putTest(DocumentProtocol::REPLY_GETBUCKETSTATE, TEST_METHOD(Messages60Test::testGetBucketStateReply)); + putTest(DocumentProtocol::REPLY_GETDOCUMENT, TEST_METHOD(Messages60Test::testGetDocumentReply)); + putTest(DocumentProtocol::REPLY_MAPVISITOR, TEST_METHOD(Messages60Test::testMapVisitorReply)); + putTest(DocumentProtocol::REPLY_PUTDOCUMENT, TEST_METHOD(Messages60Test::testPutDocumentReply)); + putTest(DocumentProtocol::REPLY_QUERYRESULT, TEST_METHOD(Messages60Test::testQueryResultReply)); + putTest(DocumentProtocol::REPLY_REMOVEDOCUMENT, TEST_METHOD(Messages60Test::testRemoveDocumentReply)); + putTest(DocumentProtocol::REPLY_REMOVELOCATION, TEST_METHOD(Messages60Test::testRemoveLocationReply)); + putTest(DocumentProtocol::REPLY_SEARCHRESULT, TEST_METHOD(Messages60Test::testSearchResultReply)); + putTest(DocumentProtocol::REPLY_STATBUCKET, TEST_METHOD(Messages60Test::testStatBucketReply)); + putTest(DocumentProtocol::REPLY_UPDATEDOCUMENT, TEST_METHOD(Messages60Test::testUpdateDocumentReply)); + putTest(DocumentProtocol::REPLY_VISITORINFO, TEST_METHOD(Messages60Test::testVisitorInfoReply)); + putTest(DocumentProtocol::REPLY_WRONGDISTRIBUTION, TEST_METHOD(Messages60Test::testWrongDistributionReply)); +} + + + +/////////////////////////////////////////////////////////////////////////////// +// +// Tests +// +/////////////////////////////////////////////////////////////////////////////// + +static const int MESSAGE_BASE_LENGTH = 5; + +namespace { + +document::Document::SP +createDoc(const DocumentTypeRepo &repo, const string &type_name, const string &id) +{ + return document::Document::SP(new document::Document( + *repo.getDocumentType(type_name), + document::DocumentId(id))); +} + +} // namespace + +bool +Messages60Test::testGetBucketListMessage() +{ + GetBucketListMessage msg(document::BucketId(16, 123)); + msg.setLoadType(_loadTypes["foo"]); + msg.setBucketSpace("beartato"); + EXPECT_EQUAL(string("foo"), msg.getLoadType().getName()); + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 12u + serializedLength("beartato"), serialize("GetBucketListMessage", msg)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("GetBucketListMessage", DocumentProtocol::MESSAGE_GETBUCKETLIST, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + GetBucketListMessage &ref = static_cast(*obj); + EXPECT_EQUAL(string("foo"), ref.getLoadType().getName()); + EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucketId()); + EXPECT_EQUAL("beartato", ref.getBucketSpace()); + } + } + return true; +} + +bool +Messages60Test::testEmptyBucketsMessage() +{ + std::vector bids; + for (size_t i=0; i < 13; ++i) { + bids.push_back(document::BucketId(16, i)); + } + + EmptyBucketsMessage msg(bids); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 112u, serialize("EmptyBucketsMessage", msg)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("EmptyBucketsMessage", DocumentProtocol::MESSAGE_EMPTYBUCKETS, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + EmptyBucketsMessage &ref = static_cast(*obj); + for (size_t i=0; i < 13; ++i) { + EXPECT_EQUAL(document::BucketId(16, i), ref.getBucketIds()[i]); + } + } + } + return true; } -// TODO code dupe with parent classes -bool Messages60Test::testCreateVisitorMessage() { + +bool +Messages60Test::testStatBucketMessage() +{ + StatBucketMessage msg(document::BucketId(16, 123), "id.user=123"); + msg.setBucketSpace("andrei"); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 27u + serializedLength("andrei"), serialize("StatBucketMessage", msg)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("StatBucketMessage", DocumentProtocol::MESSAGE_STATBUCKET, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + StatBucketMessage &ref = static_cast(*obj); + EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucketId()); + EXPECT_EQUAL("id.user=123", ref.getDocumentSelection()); + EXPECT_EQUAL("andrei", ref.getBucketSpace()); + } + } + return true; +} + +bool +Messages60Test::testCreateVisitorMessage() +{ CreateVisitorMessage tmp("SomeLibrary", "myvisitor", "newyork", "london"); tmp.setDocumentSelection("true and false or true"); tmp.getParameters().set("myvar", "somevalue"); @@ -55,39 +194,875 @@ bool Messages60Test::testCreateVisitorMessage() { return true; } -bool Messages60Test::testStatBucketMessage() { - StatBucketMessage msg(document::BucketId(16, 123), "id.user=123"); - msg.setBucketSpace("andrei"); +bool +Messages60Test::testDestroyVisitorMessage() +{ + DestroyVisitorMessage tmp("myvisitor"); - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 27u + serializedLength("andrei"), serialize("StatBucketMessage", msg)); + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)17, serialize("DestroyVisitorMessage", tmp)); for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("StatBucketMessage", DocumentProtocol::MESSAGE_STATBUCKET, lang); + mbus::Routable::UP obj = deserialize("DestroyVisitorMessage", DocumentProtocol::MESSAGE_DESTROYVISITOR, lang); if (EXPECT_TRUE(obj.get() != NULL)) { - StatBucketMessage &ref = static_cast(*obj); - EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucketId()); - EXPECT_EQUAL("id.user=123", ref.getDocumentSelection()); - EXPECT_EQUAL("andrei", ref.getBucketSpace()); + DestroyVisitorMessage &ref = static_cast(*obj); + EXPECT_EQUAL(string("myvisitor"), ref.getInstanceId()); } } return true; } -bool Messages60Test::testGetBucketListMessage() { - GetBucketListMessage msg(document::BucketId(16, 123)); - msg.setLoadType(_loadTypes["foo"]); - msg.setBucketSpace("beartato"); - EXPECT_EQUAL(string("foo"), msg.getLoadType().getName()); - EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 12u + serializedLength("beartato"), serialize("GetBucketListMessage", msg)); +bool +Messages60Test::testDocumentListMessage() +{ + document::Document::SP doc = + createDoc(getTypeRepo(), "testdoc", "userdoc:scheme:1234:"); + DocumentListMessage::Entry entry(1234, doc, false); + + DocumentListMessage tmp(document::BucketId(16, 1234)); + tmp.getDocuments().push_back(entry); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)63, serialize("DocumentListMessage", tmp)); for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { - mbus::Routable::UP obj = deserialize("GetBucketListMessage", DocumentProtocol::MESSAGE_GETBUCKETLIST, lang); + mbus::Routable::UP obj = deserialize("DocumentListMessage", DocumentProtocol::MESSAGE_DOCUMENTLIST, lang); if (EXPECT_TRUE(obj.get() != NULL)) { - GetBucketListMessage &ref = static_cast(*obj); - EXPECT_EQUAL(string("foo"), ref.getLoadType().getName()); - EXPECT_EQUAL(document::BucketId(16, 123), ref.getBucketId()); - EXPECT_EQUAL("beartato", ref.getBucketSpace()); + DocumentListMessage &ref = static_cast(*obj); + + EXPECT_EQUAL("userdoc:scheme:1234:", ref.getDocuments()[0].getDocument()->getId().toString()); + EXPECT_EQUAL(1234, ref.getDocuments()[0].getTimestamp()); + EXPECT_TRUE(!ref.getDocuments()[0].isRemoveEntry()); + } + } + return true; +} + + +bool +Messages60Test::testRemoveLocationMessage() +{ + { + document::BucketIdFactory factory; + document::select::Parser parser(getTypeRepo(), factory); + RemoveLocationMessage msg(factory, parser, "id.group == \"mygroup\""); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 29u, serialize("RemoveLocationMessage", msg)); + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("RemoveLocationMessage", DocumentProtocol::MESSAGE_REMOVELOCATION, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + RemoveLocationMessage &ref = static_cast(*obj); + EXPECT_EQUAL(string("id.group == \"mygroup\""), ref.getDocumentSelection()); + // FIXME add to wire format, currently hardcoded. + EXPECT_EQUAL(string(document::FixedBucketSpaces::default_space_name()), ref.getBucketSpace()); + } + } + } + + return true; +} + + + +bool +Messages60Test::testDocumentSummaryMessage() +{ + DocumentSummaryMessage srm; + EXPECT_EQUAL(srm.hasSequenceId(), false); + EXPECT_EQUAL(srm.getSummaryCount(), size_t(0)); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(12), serialize("DocumentSummaryMessage-1", srm)); + + mbus::Routable::UP routable = deserialize("DocumentSummaryMessage-1", DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + DocumentSummaryMessage * dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getSummaryCount(), size_t(0)); + + srm.addSummary("doc1", "summary1", 8); + srm.addSummary("aoc17", "summary45", 9); + + const void *summary(NULL); + const char *docId(NULL); + size_t sz(0); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 52u, serialize("DocumentSummaryMessage-2", srm)); + routable = deserialize("DocumentSummaryMessage-2", DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getSummaryCount(), size_t(2)); + dm->getSummary(0, docId, summary, sz); + EXPECT_EQUAL(sz, 8u); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + EXPECT_EQUAL(memcmp("summary1", summary, sz), 0); + dm->getSummary(1, docId, summary, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(strcmp("aoc17", docId), 0); + EXPECT_EQUAL(memcmp("summary45", summary, sz), 0); + + srm.sort(); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 52u, serialize("DocumentSummaryMessage-3", srm)); + routable = deserialize("DocumentSummaryMessage-3", DocumentProtocol::MESSAGE_DOCUMENTSUMMARY, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getSummaryCount(), size_t(2)); + dm->getSummary(0, docId, summary, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(strcmp("aoc17", docId), 0); + EXPECT_EQUAL(memcmp("summary45", summary, sz), 0); + dm->getSummary(1, docId, summary, sz); + EXPECT_EQUAL(sz, 8u); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + EXPECT_EQUAL(memcmp("summary1", summary, sz), 0); + return true; +} + +bool +Messages60Test::testGetDocumentMessage() +{ + GetDocumentMessage tmp(document::DocumentId("doc:scheme:"), "foo bar"); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)27, serialize("GetDocumentMessage", tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("GetDocumentMessage", DocumentProtocol::MESSAGE_GETDOCUMENT, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + GetDocumentMessage &ref = static_cast(*obj); + EXPECT_EQUAL(string("doc:scheme:"), ref.getDocumentId().toString()); + EXPECT_EQUAL(string("foo bar"), ref.getFieldSet()); + } + } + return true; +} + +bool +Messages60Test::testMapVisitorMessage() +{ + MapVisitorMessage tmp; + tmp.getData().set("foo", 3); + tmp.getData().set("bar", 5); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + (size_t)32, serialize("MapVisitorMessage", tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("MapVisitorMessage", DocumentProtocol::MESSAGE_MAPVISITOR, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + MapVisitorMessage &ref = static_cast(*obj); + EXPECT_EQUAL(3, ref.getData().get("foo", 0)); + EXPECT_EQUAL(5, ref.getData().get("bar", 0)); + } + } + return true; +} + +bool +Messages60Test::testCreateVisitorReply() +{ + CreateVisitorReply reply(DocumentProtocol::REPLY_CREATEVISITOR); + reply.setLastBucket(document::BucketId(16, 123)); + vdslib::VisitorStatistics vs; + vs.setBucketsVisited(3); + vs.setDocumentsVisited(1000); + vs.setBytesVisited(1024000); + vs.setDocumentsReturned(123); + vs.setBytesReturned(512000); + vs.setSecondPassDocumentsReturned(456); + vs.setSecondPassBytesReturned(789100); + reply.setVisitorStatistics(vs); + + EXPECT_EQUAL(65u, serialize("CreateVisitorReply", reply)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("CreateVisitorReply", DocumentProtocol::REPLY_CREATEVISITOR, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + CreateVisitorReply &ref = static_cast(*obj); + + EXPECT_EQUAL(ref.getLastBucket(), document::BucketId(16, 123)); + EXPECT_EQUAL(ref.getVisitorStatistics().getBucketsVisited(), (uint32_t)3); + EXPECT_EQUAL(ref.getVisitorStatistics().getDocumentsVisited(), (uint64_t)1000); + EXPECT_EQUAL(ref.getVisitorStatistics().getBytesVisited(), (uint64_t)1024000); + EXPECT_EQUAL(ref.getVisitorStatistics().getDocumentsReturned(), (uint64_t)123); + EXPECT_EQUAL(ref.getVisitorStatistics().getBytesReturned(), (uint64_t)512000); + EXPECT_EQUAL(ref.getVisitorStatistics().getSecondPassDocumentsReturned(), (uint64_t)456); + EXPECT_EQUAL(ref.getVisitorStatistics().getSecondPassBytesReturned(), (uint64_t)789100); + } + } + return true; +} + +bool +Messages60Test::testPutDocumentMessage() +{ + auto doc = createDoc(getTypeRepo(), "testdoc", "doc:scheme:"); + PutDocumentMessage msg(doc); + + msg.setTimestamp(666); + msg.setCondition(TestAndSetCondition("There's just one condition")); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + + 41u + + serializedLength(msg.getCondition().getSelection()), + serialize("PutDocumentMessage", msg)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + auto routableUp = deserialize("PutDocumentMessage", DocumentProtocol::MESSAGE_PUTDOCUMENT, lang); + if (EXPECT_TRUE(routableUp.get() != nullptr)) { + auto & deserializedMsg = static_cast(*routableUp); + + EXPECT_EQUAL(msg.getDocument().getType().getName(), deserializedMsg.getDocument().getType().getName()); + EXPECT_EQUAL(msg.getDocument().getId().toString(), deserializedMsg.getDocument().getId().toString()); + EXPECT_EQUAL(msg.getTimestamp(), deserializedMsg.getTimestamp()); + EXPECT_EQUAL(67u, deserializedMsg.getApproxSize()); + EXPECT_EQUAL(msg.getCondition().getSelection(), deserializedMsg.getCondition().getSelection()); + } + } + + return true; +} + +bool +Messages60Test::testGetBucketStateMessage() +{ + GetBucketStateMessage tmp; + tmp.setBucketId(document::BucketId(16, 666)); + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 12u, serialize("GetBucketStateMessage", tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("GetBucketStateMessage", DocumentProtocol::MESSAGE_GETBUCKETSTATE, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + GetBucketStateMessage &ref = static_cast(*obj); + + EXPECT_EQUAL(16u, ref.getBucketId().getUsedBits()); + EXPECT_EQUAL(4611686018427388570ull, ref.getBucketId().getId()); + } + } + return true; +} + +bool +Messages60Test::testPutDocumentReply() +{ + WriteDocumentReply reply(DocumentProtocol::REPLY_PUTDOCUMENT); + reply.setHighestModificationTimestamp(30); + + EXPECT_EQUAL(13u, serialize("PutDocumentReply", reply)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("PutDocumentReply", DocumentProtocol::REPLY_PUTDOCUMENT, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + WriteDocumentReply &ref = static_cast(*obj); + EXPECT_EQUAL(30u, ref.getHighestModificationTimestamp()); + } + } + return true; +} + +bool +Messages60Test::testUpdateDocumentReply() +{ + UpdateDocumentReply reply; + reply.setWasFound(false); + reply.setHighestModificationTimestamp(30); + + EXPECT_EQUAL(14u, serialize("UpdateDocumentReply", reply)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("UpdateDocumentReply", DocumentProtocol::REPLY_UPDATEDOCUMENT, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + UpdateDocumentReply &ref = static_cast(*obj); + EXPECT_EQUAL(30u, ref.getHighestModificationTimestamp()); + EXPECT_EQUAL(false, ref.wasFound()); + } + } + return true; +} + +bool +Messages60Test::testRemoveDocumentMessage() +{ + RemoveDocumentMessage msg(document::DocumentId("doc:scheme:")); + + msg.setCondition(TestAndSetCondition("There's just one condition")); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(16) + serializedLength(msg.getCondition().getSelection()), serialize("RemoveDocumentMessage", msg)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + auto routablePtr = deserialize("RemoveDocumentMessage", DocumentProtocol::MESSAGE_REMOVEDOCUMENT, lang); + + if (EXPECT_TRUE(routablePtr.get() != nullptr)) { + auto & ref = static_cast(*routablePtr); + EXPECT_EQUAL(string("doc:scheme:"), ref.getDocumentId().toString()); + EXPECT_EQUAL(msg.getCondition().getSelection(), ref.getCondition().getSelection()); + } + } + return true; +} + +bool +Messages60Test::testRemoveDocumentReply() +{ + RemoveDocumentReply reply; + std::vector ts; + reply.setWasFound(false); + reply.setHighestModificationTimestamp(30); + + EXPECT_EQUAL(14u, serialize("RemoveDocumentReply", reply)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("RemoveDocumentReply", DocumentProtocol::REPLY_REMOVEDOCUMENT, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + RemoveDocumentReply &ref = static_cast(*obj); + EXPECT_EQUAL(30u, ref.getHighestModificationTimestamp()); + EXPECT_EQUAL(false, ref.wasFound()); } } return true; -} \ No newline at end of file +} + +bool +Messages60Test::testSearchResultMessage() +{ + SearchResultMessage srm; + EXPECT_EQUAL(srm.getSequenceId(), 0u); + EXPECT_EQUAL(srm.getHitCount(), 0u); + EXPECT_EQUAL(srm.getAggregatorList().getSerializedSize(), 4u); + EXPECT_EQUAL(srm.vdslib::SearchResult::getSerializedSize(), 20u); + EXPECT_EQUAL(srm.getSerializedSize(), 20u); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(24), serialize("SearchResultMessage-1", srm)); + + mbus::Routable::UP routable = deserialize("SearchResultMessage-1", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + SearchResultMessage * dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getSequenceId(), size_t(0)); + EXPECT_EQUAL(dm->getHitCount(), size_t(0)); + + srm.addHit(0, "doc1", 89); + srm.addHit(1, "doc17", 109); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 55u, serialize("SearchResultMessage-2", srm)); + routable = deserialize("SearchResultMessage-2", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getHitCount(), size_t(2)); + const char *docId; + SearchResultMessage::RankType rank; + dm->getHit(0, docId, rank); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + dm->getHit(1, docId, rank); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + + srm.sort(); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 55u, serialize("SearchResultMessage-3", srm)); + routable = deserialize("SearchResultMessage-3", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getHitCount(), size_t(2)); + dm->getHit(0, docId, rank); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + dm->getHit(1, docId, rank); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + + SearchResultMessage srm2; + srm2.addHit(0, "doc1", 89, "sortdata2", 9); + srm2.addHit(1, "doc17", 109, "sortdata1", 9); + srm2.addHit(2, "doc18", 90, "sortdata3", 9); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 108u, serialize("SearchResultMessage-4", srm2)); + routable = deserialize("SearchResultMessage-4", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getHitCount(), size_t(3)); + dm->getHit(0, docId, rank); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + dm->getHit(1, docId, rank); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + dm->getHit(2, docId, rank); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(90)); + EXPECT_EQUAL(strcmp("doc18", docId), 0); + + srm2.sort(); + const void *buf; + size_t sz; + srm2.getHit(0, docId, rank); + srm2.getSortBlob(0, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + srm2.getHit(1, docId, rank); + srm2.getSortBlob(1, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + srm2.getHit(2, docId, rank); + srm2.getSortBlob(2, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(90)); + EXPECT_EQUAL(strcmp("doc18", docId), 0); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 108u, serialize("SearchResultMessage-5", srm2)); + routable = deserialize("SearchResultMessage-5", DocumentProtocol::MESSAGE_SEARCHRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + EXPECT_EQUAL(dm->getHitCount(), size_t(3)); + dm->getHit(0, docId, rank); + dm->getSortBlob(0, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + dm->getHit(1, docId, rank); + dm->getSortBlob(1, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + dm->getHit(2, docId, rank); + dm->getSortBlob(2, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); + EXPECT_EQUAL(rank, SearchResultMessage::RankType(90)); + EXPECT_EQUAL(strcmp("doc18", docId), 0); + return true; +} + +bool +Messages60Test::testUpdateDocumentMessage() +{ + const DocumentTypeRepo & repo = getTypeRepo(); + const document::DocumentType & docType = *repo.getDocumentType("testdoc"); + + auto docUpdate = std::make_shared(repo, docType, document::DocumentId("doc:scheme:")); + + docUpdate->addFieldPathUpdate(document::FieldPathUpdate::CP( + new document::RemoveFieldPathUpdate("intfield", "testdoc.intfield > 0"))); + + UpdateDocumentMessage msg(docUpdate); + msg.setOldTimestamp(666u); + msg.setNewTimestamp(777u); + msg.setCondition(TestAndSetCondition("There's just one condition")); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 89u + serializedLength(msg.getCondition().getSelection()), serialize("UpdateDocumentMessage", msg)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + auto routableUp = deserialize("UpdateDocumentMessage", DocumentProtocol::MESSAGE_UPDATEDOCUMENT, lang); + + if (EXPECT_TRUE(routableUp.get() != nullptr)) { + auto & deserializedMsg = static_cast(*routableUp); + EXPECT_EQUAL(msg.getDocumentUpdate(), deserializedMsg.getDocumentUpdate()); + EXPECT_EQUAL(msg.getOldTimestamp(), deserializedMsg.getOldTimestamp()); + EXPECT_EQUAL(msg.getNewTimestamp(), deserializedMsg.getNewTimestamp()); + EXPECT_EQUAL(115u, deserializedMsg.getApproxSize()); + EXPECT_EQUAL(msg.getCondition().getSelection(), deserializedMsg.getCondition().getSelection()); + } + } + return true; +} + +bool +Messages60Test::testQueryResultMessage() +{ + QueryResultMessage srm; + vdslib::SearchResult & sr(srm.getSearchResult()); + EXPECT_EQUAL(srm.getSequenceId(), 0u); + EXPECT_EQUAL(sr.getHitCount(), 0u); + EXPECT_EQUAL(sr.getAggregatorList().getSerializedSize(), 4u); + EXPECT_EQUAL(sr.getSerializedSize(), 20u); + EXPECT_EQUAL(srm.getApproxSize(), 28u); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + size_t(32), serialize("QueryResultMessage-1", srm)); + + mbus::Routable::UP routable = deserialize("QueryResultMessage-1", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + QueryResultMessage * dm = static_cast(routable.get()); + vdslib::SearchResult * dr(&dm->getSearchResult()); + EXPECT_EQUAL(dm->getSequenceId(), size_t(0)); + EXPECT_EQUAL(dr->getHitCount(), size_t(0)); + + sr.addHit(0, "doc1", 89); + sr.addHit(1, "doc17", 109); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 63u, serialize("QueryResultMessage-2", srm)); + routable = deserialize("QueryResultMessage-2", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + dr = &dm->getSearchResult(); + EXPECT_EQUAL(dr->getHitCount(), size_t(2)); + const char *docId; + vdslib::SearchResult::RankType rank; + dr->getHit(0, docId, rank); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + dr->getHit(1, docId, rank); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + + sr.sort(); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 63u, serialize("QueryResultMessage-3", srm)); + routable = deserialize("QueryResultMessage-3", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + dr = &dm->getSearchResult(); + EXPECT_EQUAL(dr->getHitCount(), size_t(2)); + dr->getHit(0, docId, rank); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + dr->getHit(1, docId, rank); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + + QueryResultMessage srm2; + vdslib::SearchResult & sr2(srm2.getSearchResult()); + sr2.addHit(0, "doc1", 89, "sortdata2", 9); + sr2.addHit(1, "doc17", 109, "sortdata1", 9); + sr2.addHit(2, "doc18", 90, "sortdata3", 9); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 116u, serialize("QueryResultMessage-4", srm2)); + routable = deserialize("QueryResultMessage-4", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + dr = &dm->getSearchResult(); + EXPECT_EQUAL(dr->getHitCount(), size_t(3)); + dr->getHit(0, docId, rank); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + dr->getHit(1, docId, rank); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + dr->getHit(2, docId, rank); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(90)); + EXPECT_EQUAL(strcmp("doc18", docId), 0); + + sr2.sort(); + const void *buf; + size_t sz; + sr2.getHit(0, docId, rank); + sr2.getSortBlob(0, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + sr2.getHit(1, docId, rank); + sr2.getSortBlob(1, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + sr2.getHit(2, docId, rank); + sr2.getSortBlob(2, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(90)); + EXPECT_EQUAL(strcmp("doc18", docId), 0); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 116u, serialize("QueryResultMessage-5", srm2)); + routable = deserialize("QueryResultMessage-5", DocumentProtocol::MESSAGE_QUERYRESULT, LANG_CPP); + if (!EXPECT_TRUE(routable.get() != NULL)) { + return false; + } + dm = static_cast(routable.get()); + dr = &dm->getSearchResult(); + EXPECT_EQUAL(dr->getHitCount(), size_t(3)); + dr->getHit(0, docId, rank); + dr->getSortBlob(0, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata1", buf, sz), 0); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(109)); + EXPECT_EQUAL(strcmp("doc17", docId), 0); + dr->getHit(1, docId, rank); + dr->getSortBlob(1, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata2", buf, sz), 0); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(89)); + EXPECT_EQUAL(strcmp("doc1", docId), 0); + dr->getHit(2, docId, rank); + dr->getSortBlob(2, buf, sz); + EXPECT_EQUAL(sz, 9u); + EXPECT_EQUAL(memcmp("sortdata3", buf, sz), 0); + EXPECT_EQUAL(rank, vdslib::SearchResult::RankType(90)); + EXPECT_EQUAL(strcmp("doc18", docId), 0); + return true; +} + +bool +Messages60Test::testQueryResultReply() +{ + return tryVisitorReply("QueryResultReply", DocumentProtocol::REPLY_QUERYRESULT); +} + +bool +Messages60Test::testVisitorInfoMessage() +{ + + VisitorInfoMessage tmp; + tmp.getFinishedBuckets().push_back(document::BucketId(16, 1)); + tmp.getFinishedBuckets().push_back(document::BucketId(16, 2)); + tmp.getFinishedBuckets().push_back(document::BucketId(16, 4)); + string utf8 = "error message: \u00e6\u00c6\u00f8\u00d8\u00e5\u00c5\u00f6\u00d6"; + tmp.setErrorMessage(utf8); + + EXPECT_EQUAL(MESSAGE_BASE_LENGTH + 67u, serialize("VisitorInfoMessage", tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("VisitorInfoMessage", DocumentProtocol::MESSAGE_VISITORINFO, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + VisitorInfoMessage &ref = static_cast(*obj); + EXPECT_EQUAL(document::BucketId(16, 1), ref.getFinishedBuckets()[0]); + EXPECT_EQUAL(document::BucketId(16, 2), ref.getFinishedBuckets()[1]); + EXPECT_EQUAL(document::BucketId(16, 4), ref.getFinishedBuckets()[2]); + EXPECT_EQUAL(utf8, ref.getErrorMessage()); + } + } + return true; +} + +bool +Messages60Test::testDestroyVisitorReply() +{ + return tryDocumentReply("DestroyVisitorReply", DocumentProtocol::REPLY_DESTROYVISITOR); +} + +bool +Messages60Test::testDocumentIgnoredReply() +{ + DocumentIgnoredReply tmp; + serialize("DocumentIgnoredReply", tmp); + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj( + deserialize("DocumentIgnoredReply", + DocumentProtocol::REPLY_DOCUMENTIGNORED, lang)); + EXPECT_TRUE(obj.get() != NULL); + } + return true; +} + +bool +Messages60Test::testDocumentListReply() +{ + return tryVisitorReply("DocumentListReply", DocumentProtocol::REPLY_DOCUMENTLIST); +} + +bool +Messages60Test::testDocumentSummaryReply() +{ + return tryVisitorReply("DocumentSummaryReply", DocumentProtocol::REPLY_DOCUMENTSUMMARY); +} + +bool +Messages60Test::testGetDocumentReply() +{ + document::Document::SP doc = + createDoc(getTypeRepo(), "testdoc", "doc:scheme:"); + GetDocumentReply tmp(doc); + + EXPECT_EQUAL((size_t)43, serialize("GetDocumentReply", tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("GetDocumentReply", DocumentProtocol::REPLY_GETDOCUMENT, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + GetDocumentReply &ref = static_cast(*obj); + + EXPECT_EQUAL(string("testdoc"), ref.getDocument().getType().getName()); + EXPECT_EQUAL(string("doc:scheme:"), ref.getDocument().getId().toString()); + } + } + return true; +} + +bool +Messages60Test::testMapVisitorReply() +{ + return tryVisitorReply("MapVisitorReply", DocumentProtocol::REPLY_MAPVISITOR); +} + +bool +Messages60Test::testSearchResultReply() +{ + return tryVisitorReply("SearchResultReply", DocumentProtocol::REPLY_SEARCHRESULT); +} + +bool +Messages60Test::testStatBucketReply() +{ + StatBucketReply msg; + msg.setResults("These are the votes of the Norwegian jury"); + + EXPECT_EQUAL(50u, serialize("StatBucketReply", msg)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("StatBucketReply", DocumentProtocol::REPLY_STATBUCKET, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + StatBucketReply &ref = static_cast(*obj); + EXPECT_EQUAL("These are the votes of the Norwegian jury", ref.getResults()); + } + } + return true; +} + +bool +Messages60Test::testVisitorInfoReply() +{ + return tryVisitorReply("VisitorInfoReply", DocumentProtocol::REPLY_VISITORINFO); +} + +bool +Messages60Test::testWrongDistributionReply() +{ + WrongDistributionReply tmp("distributor:3 storage:2"); + + serialize("WrongDistributionReply", tmp); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("WrongDistributionReply", DocumentProtocol::REPLY_WRONGDISTRIBUTION, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + WrongDistributionReply &ref = static_cast(*obj); + EXPECT_EQUAL(string("distributor:3 storage:2"), ref.getSystemState()); + } + } + return true; +} + +bool +Messages60Test::testGetBucketListReply() +{ + GetBucketListReply reply; + reply.getBuckets().push_back(GetBucketListReply::BucketInfo(document::BucketId(16, 123), "foo")); + reply.getBuckets().push_back(GetBucketListReply::BucketInfo(document::BucketId(17, 1123), "bar")); + reply.getBuckets().push_back(GetBucketListReply::BucketInfo(document::BucketId(18, 11123), "zoink")); + + EXPECT_EQUAL(56u, serialize("GetBucketListReply", reply)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("GetBucketListReply", DocumentProtocol::REPLY_GETBUCKETLIST, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + GetBucketListReply &ref = static_cast(*obj); + + EXPECT_EQUAL(ref.getBuckets()[0], GetBucketListReply::BucketInfo(document::BucketId(16, 123), "foo")); + EXPECT_EQUAL(ref.getBuckets()[1], GetBucketListReply::BucketInfo(document::BucketId(17, 1123), "bar")); + EXPECT_EQUAL(ref.getBuckets()[2], GetBucketListReply::BucketInfo(document::BucketId(18, 11123), "zoink")); + } + } + return true; +} + +bool +Messages60Test::testGetBucketStateReply() +{ + document::GlobalId foo = document::DocumentId("doc:scheme:foo").getGlobalId(); + document::GlobalId bar = document::DocumentId("doc:scheme:bar").getGlobalId(); + + GetBucketStateReply reply; + reply.getBucketState().push_back(DocumentState(foo, 777, false)); + reply.getBucketState().push_back(DocumentState(bar, 888, true)); + EXPECT_EQUAL(53u, serialize("GetBucketStateReply", reply)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("GetBucketStateReply", DocumentProtocol::REPLY_GETBUCKETSTATE, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + GetBucketStateReply &ref = static_cast(*obj); + + EXPECT_EQUAL(777u, ref.getBucketState()[0].getTimestamp()); + EXPECT_EQUAL(foo, ref.getBucketState()[0].getGlobalId()); + EXPECT_EQUAL(false, ref.getBucketState()[0].isRemoveEntry()); + EXPECT_EQUAL(888u, ref.getBucketState()[1].getTimestamp()); + EXPECT_EQUAL(bar, ref.getBucketState()[1].getGlobalId()); + EXPECT_EQUAL(true, ref.getBucketState()[1].isRemoveEntry()); + } + } + return true; +} + +bool +Messages60Test::testEmptyBucketsReply() +{ + return tryVisitorReply("EmptyBucketsReply", DocumentProtocol::REPLY_EMPTYBUCKETS); +} + +bool +Messages60Test::testRemoveLocationReply() +{ + DocumentReply tmp(DocumentProtocol::REPLY_REMOVELOCATION); + + EXPECT_EQUAL((uint32_t)5, serialize("RemoveLocationReply", tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize("RemoveLocationReply", DocumentProtocol::REPLY_REMOVELOCATION, lang); + EXPECT_TRUE(obj.get() != NULL); + } + return true; +} + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Utilities +// +//////////////////////////////////////////////////////////////////////////////// + +bool +Messages60Test::tryDocumentReply(const string &filename, uint32_t type) +{ + DocumentReply tmp(type); + + EXPECT_EQUAL((uint32_t)5, serialize(filename, tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize(filename, type, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + DocumentReply *ref = dynamic_cast(obj.get()); + EXPECT_TRUE(ref != NULL); + } + } + return true; +} + +bool +Messages60Test::tryVisitorReply(const string &filename, uint32_t type) +{ + VisitorReply tmp(type); + + EXPECT_EQUAL((uint32_t)5, serialize(filename, tmp)); + + for (uint32_t lang = 0; lang < NUM_LANGUAGES; ++lang) { + mbus::Routable::UP obj = deserialize(filename, type, lang); + if (EXPECT_TRUE(obj.get() != NULL)) { + VisitorReply *ref = dynamic_cast(obj.get()); + EXPECT_TRUE(ref != NULL); + } + } + return true; +} diff --git a/documentapi/src/tests/messages/messages60test.h b/documentapi/src/tests/messages/messages60test.h index 78224e5a808..87954310536 100644 --- a/documentapi/src/tests/messages/messages60test.h +++ b/documentapi/src/tests/messages/messages60test.h @@ -1,14 +1,56 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// @author Vegard Sjonfjell #pragma once -#include "messages52test.h" +#include "testbase.h" -class Messages60Test : public Messages52Test { +class Messages60Test : public TestBase { protected: const vespalib::Version getVersion() const override { return vespalib::Version(6, 221); } + bool shouldTestCoverage() const override { return true; } + bool tryDocumentReply(const string &filename, uint32_t type); + bool tryVisitorReply(const string &filename, uint32_t type); + + static size_t serializedLength(const string & str) { return sizeof(int32_t) + str.size(); } + public: Messages60Test(); + bool testCreateVisitorMessage(); - bool testStatBucketMessage(); + bool testCreateVisitorReply(); + bool testDestroyVisitorMessage(); + bool testDestroyVisitorReply(); + bool testDocumentIgnoredReply(); + bool testDocumentListMessage(); + bool testDocumentListReply(); + bool testDocumentSummaryMessage(); + bool testDocumentSummaryReply(); + bool testEmptyBucketsMessage(); + bool testEmptyBucketsReply(); bool testGetBucketListMessage(); + bool testGetBucketListReply(); + bool testGetBucketStateMessage(); + bool testGetBucketStateReply(); + bool testGetDocumentMessage(); + bool testGetDocumentReply(); + bool testMapVisitorMessage(); + bool testMapVisitorReply(); + bool testPutDocumentMessage(); + bool testPutDocumentReply(); + bool testQueryResultMessage(); + bool testQueryResultReply(); + bool testRemoveDocumentMessage(); + bool testRemoveDocumentReply(); + bool testRemoveLocationMessage(); + bool testRemoveLocationReply(); + bool testSearchResultMessage(); + bool testSearchResultReply(); + bool testStatBucketMessage(); + bool testStatBucketReply(); + bool testUpdateDocumentMessage(); + bool testUpdateDocumentReply(); + bool testVisitorInfoMessage(); + bool testVisitorInfoReply(); + bool testWrongDistributionReply(); }; + diff --git a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp index b70a76690f9..e8cc7a03e94 100644 --- a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp @@ -1,6 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "routablefactories52.h" #include "routablefactories60.h" #include "routingpolicyfactories.h" #include "routablerepository.h" @@ -44,54 +43,47 @@ DocumentProtocol::DocumentProtocol(const LoadTypeSet& loadTypes, putRoutingPolicyFactory("LoadBalancer", IRoutingPolicyFactory::SP(new RoutingPolicyFactories::LoadBalancerPolicyFactory())); // Prepare version specifications to use when adding routable factories. - vespalib::VersionSpecification version52(5, 115); vespalib::VersionSpecification version6(6, 221); - std::vector from52 = { version52, version6 }; std::vector from6 = { version6 }; - // Add 5.2 serialization - putRoutableFactory(MESSAGE_CREATEVISITOR, IRoutableFactory::SP(new RoutableFactories52::CreateVisitorMessageFactory(*_repo)), from52); - putRoutableFactory(MESSAGE_DESTROYVISITOR, IRoutableFactory::SP(new RoutableFactories52::DestroyVisitorMessageFactory()), from52); - putRoutableFactory(MESSAGE_DOCUMENTLIST, IRoutableFactory::SP(new RoutableFactories52::DocumentListMessageFactory(*_repo)), from52); - putRoutableFactory(MESSAGE_DOCUMENTSUMMARY, IRoutableFactory::SP(new RoutableFactories52::DocumentSummaryMessageFactory()), from52); - putRoutableFactory(MESSAGE_EMPTYBUCKETS, IRoutableFactory::SP(new RoutableFactories52::EmptyBucketsMessageFactory()), from52); - putRoutableFactory(MESSAGE_GETBUCKETLIST, IRoutableFactory::SP(new RoutableFactories52::GetBucketListMessageFactory()), from52); - putRoutableFactory(MESSAGE_GETBUCKETSTATE, IRoutableFactory::SP(new RoutableFactories52::GetBucketStateMessageFactory()), from52); - putRoutableFactory(MESSAGE_GETDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::GetDocumentMessageFactory()), from52); - putRoutableFactory(MESSAGE_MAPVISITOR, IRoutableFactory::SP(new RoutableFactories52::MapVisitorMessageFactory(*_repo)), from52); - putRoutableFactory(MESSAGE_PUTDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::PutDocumentMessageFactory(*_repo)), from52); - putRoutableFactory(MESSAGE_QUERYRESULT, IRoutableFactory::SP(new RoutableFactories52::QueryResultMessageFactory()), from52); - putRoutableFactory(MESSAGE_REMOVEDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::RemoveDocumentMessageFactory()), from52); - putRoutableFactory(MESSAGE_REMOVELOCATION, IRoutableFactory::SP(new RoutableFactories52::RemoveLocationMessageFactory(*_repo)), from52); - putRoutableFactory(MESSAGE_SEARCHRESULT, IRoutableFactory::SP(new RoutableFactories52::SearchResultMessageFactory()), from52); - putRoutableFactory(MESSAGE_STATBUCKET, IRoutableFactory::SP(new RoutableFactories52::StatBucketMessageFactory()), from52); - putRoutableFactory(MESSAGE_UPDATEDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::UpdateDocumentMessageFactory(*_repo)), from52); - putRoutableFactory(MESSAGE_VISITORINFO, IRoutableFactory::SP(new RoutableFactories52::VisitorInfoMessageFactory()), from52); - putRoutableFactory(REPLY_CREATEVISITOR, IRoutableFactory::SP(new RoutableFactories52::CreateVisitorReplyFactory()), from52); - putRoutableFactory(REPLY_DESTROYVISITOR, IRoutableFactory::SP(new RoutableFactories52::DestroyVisitorReplyFactory()), from52); - putRoutableFactory(REPLY_DOCUMENTIGNORED, IRoutableFactory::SP(new RoutableFactories52::DocumentIgnoredReplyFactory()), from52); - putRoutableFactory(REPLY_DOCUMENTLIST, IRoutableFactory::SP(new RoutableFactories52::DocumentListReplyFactory()), from52); - putRoutableFactory(REPLY_DOCUMENTSUMMARY, IRoutableFactory::SP(new RoutableFactories52::DocumentSummaryReplyFactory()), from52); - putRoutableFactory(REPLY_EMPTYBUCKETS, IRoutableFactory::SP(new RoutableFactories52::EmptyBucketsReplyFactory()), from52); - putRoutableFactory(REPLY_GETBUCKETLIST, IRoutableFactory::SP(new RoutableFactories52::GetBucketListReplyFactory()), from52); - putRoutableFactory(REPLY_GETBUCKETSTATE, IRoutableFactory::SP(new RoutableFactories52::GetBucketStateReplyFactory()), from52); - putRoutableFactory(REPLY_GETDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::GetDocumentReplyFactory(*_repo)), from52); - putRoutableFactory(REPLY_MAPVISITOR, IRoutableFactory::SP(new RoutableFactories52::MapVisitorReplyFactory()), from52); - putRoutableFactory(REPLY_PUTDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::PutDocumentReplyFactory()), from52); - putRoutableFactory(REPLY_QUERYRESULT, IRoutableFactory::SP(new RoutableFactories52::QueryResultReplyFactory()), from52); - putRoutableFactory(REPLY_REMOVEDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::RemoveDocumentReplyFactory()), from52); - putRoutableFactory(REPLY_REMOVELOCATION, IRoutableFactory::SP(new RoutableFactories52::RemoveLocationReplyFactory()), from52); - putRoutableFactory(REPLY_SEARCHRESULT, IRoutableFactory::SP(new RoutableFactories52::SearchResultReplyFactory()), from52); - putRoutableFactory(REPLY_STATBUCKET, IRoutableFactory::SP(new RoutableFactories52::StatBucketReplyFactory()), from52); - putRoutableFactory(REPLY_UPDATEDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::UpdateDocumentReplyFactory()), from52); - putRoutableFactory(REPLY_VISITORINFO, IRoutableFactory::SP(new RoutableFactories52::VisitorInfoReplyFactory()), from52); - putRoutableFactory(REPLY_WRONGDISTRIBUTION, IRoutableFactory::SP(new RoutableFactories52::WrongDistributionReplyFactory()), from52); - - // Add 6.x serialization (TODO finalize version) + // Add 6.x serialization putRoutableFactory(MESSAGE_CREATEVISITOR, IRoutableFactory::SP(new RoutableFactories60::CreateVisitorMessageFactory(*_repo)), from6); - putRoutableFactory(MESSAGE_STATBUCKET, IRoutableFactory::SP(new RoutableFactories60::StatBucketMessageFactory()), from6); + putRoutableFactory(MESSAGE_DESTROYVISITOR, IRoutableFactory::SP(new RoutableFactories60::DestroyVisitorMessageFactory()), from6); + putRoutableFactory(MESSAGE_DOCUMENTLIST, IRoutableFactory::SP(new RoutableFactories60::DocumentListMessageFactory(*_repo)), from6); + putRoutableFactory(MESSAGE_DOCUMENTSUMMARY, IRoutableFactory::SP(new RoutableFactories60::DocumentSummaryMessageFactory()), from6); + putRoutableFactory(MESSAGE_EMPTYBUCKETS, IRoutableFactory::SP(new RoutableFactories60::EmptyBucketsMessageFactory()), from6); putRoutableFactory(MESSAGE_GETBUCKETLIST, IRoutableFactory::SP(new RoutableFactories60::GetBucketListMessageFactory()), from6); + putRoutableFactory(MESSAGE_GETBUCKETSTATE, IRoutableFactory::SP(new RoutableFactories60::GetBucketStateMessageFactory()), from6); + putRoutableFactory(MESSAGE_GETDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::GetDocumentMessageFactory()), from6); + putRoutableFactory(MESSAGE_MAPVISITOR, IRoutableFactory::SP(new RoutableFactories60::MapVisitorMessageFactory(*_repo)), from6); + putRoutableFactory(MESSAGE_PUTDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::PutDocumentMessageFactory(*_repo)), from6); + putRoutableFactory(MESSAGE_QUERYRESULT, IRoutableFactory::SP(new RoutableFactories60::QueryResultMessageFactory()), from6); + putRoutableFactory(MESSAGE_REMOVEDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::RemoveDocumentMessageFactory()), from6); + putRoutableFactory(MESSAGE_REMOVELOCATION, IRoutableFactory::SP(new RoutableFactories60::RemoveLocationMessageFactory(*_repo)), from6); + putRoutableFactory(MESSAGE_SEARCHRESULT, IRoutableFactory::SP(new RoutableFactories60::SearchResultMessageFactory()), from6); + putRoutableFactory(MESSAGE_STATBUCKET, IRoutableFactory::SP(new RoutableFactories60::StatBucketMessageFactory()), from6); + putRoutableFactory(MESSAGE_UPDATEDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::UpdateDocumentMessageFactory(*_repo)), from6); + putRoutableFactory(MESSAGE_VISITORINFO, IRoutableFactory::SP(new RoutableFactories60::VisitorInfoMessageFactory()), from6); + putRoutableFactory(REPLY_CREATEVISITOR, IRoutableFactory::SP(new RoutableFactories60::CreateVisitorReplyFactory()), from6); + putRoutableFactory(REPLY_DESTROYVISITOR, IRoutableFactory::SP(new RoutableFactories60::DestroyVisitorReplyFactory()), from6); + putRoutableFactory(REPLY_DOCUMENTIGNORED, IRoutableFactory::SP(new RoutableFactories60::DocumentIgnoredReplyFactory()), from6); + putRoutableFactory(REPLY_DOCUMENTLIST, IRoutableFactory::SP(new RoutableFactories60::DocumentListReplyFactory()), from6); + putRoutableFactory(REPLY_DOCUMENTSUMMARY, IRoutableFactory::SP(new RoutableFactories60::DocumentSummaryReplyFactory()), from6); + putRoutableFactory(REPLY_EMPTYBUCKETS, IRoutableFactory::SP(new RoutableFactories60::EmptyBucketsReplyFactory()), from6); + putRoutableFactory(REPLY_GETBUCKETLIST, IRoutableFactory::SP(new RoutableFactories60::GetBucketListReplyFactory()), from6); + putRoutableFactory(REPLY_GETBUCKETSTATE, IRoutableFactory::SP(new RoutableFactories60::GetBucketStateReplyFactory()), from6); + putRoutableFactory(REPLY_GETDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::GetDocumentReplyFactory(*_repo)), from6); + putRoutableFactory(REPLY_MAPVISITOR, IRoutableFactory::SP(new RoutableFactories60::MapVisitorReplyFactory()), from6); + putRoutableFactory(REPLY_PUTDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::PutDocumentReplyFactory()), from6); + putRoutableFactory(REPLY_QUERYRESULT, IRoutableFactory::SP(new RoutableFactories60::QueryResultReplyFactory()), from6); + putRoutableFactory(REPLY_REMOVEDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::RemoveDocumentReplyFactory()), from6); + putRoutableFactory(REPLY_REMOVELOCATION, IRoutableFactory::SP(new RoutableFactories60::RemoveLocationReplyFactory()), from6); + putRoutableFactory(REPLY_SEARCHRESULT, IRoutableFactory::SP(new RoutableFactories60::SearchResultReplyFactory()), from6); + putRoutableFactory(REPLY_STATBUCKET, IRoutableFactory::SP(new RoutableFactories60::StatBucketReplyFactory()), from6); + putRoutableFactory(REPLY_UPDATEDOCUMENT, IRoutableFactory::SP(new RoutableFactories60::UpdateDocumentReplyFactory()), from6); + putRoutableFactory(REPLY_VISITORINFO, IRoutableFactory::SP(new RoutableFactories60::VisitorInfoReplyFactory()), from6); + putRoutableFactory(REPLY_WRONGDISTRIBUTION, IRoutableFactory::SP(new RoutableFactories60::WrongDistributionReplyFactory()), from6); } DocumentProtocol::~DocumentProtocol() = default; -- cgit v1.2.3