From a561a101ecd0373ab6a8df6cd801dba195b86eaa Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Thu, 1 Nov 2018 13:06:46 +0000 Subject: Narrow down routing of Document API GetDocument messages. --- documentapi/src/tests/policies/policies_test.cpp | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'documentapi/src/tests') diff --git a/documentapi/src/tests/policies/policies_test.cpp b/documentapi/src/tests/policies/policies_test.cpp index c01cdfde30c..7c93e186338 100644 --- a/documentapi/src/tests/policies/policies_test.cpp +++ b/documentapi/src/tests/policies/policies_test.cpp @@ -66,6 +66,8 @@ public: void testDocumentRouteSelectorIgnore(); void remove_document_messages_are_sent_to_the_route_handling_the_given_document_type(); void remove_document_messages_with_legacy_document_ids_are_sent_to_all_routes(); + void get_document_messages_are_sent_to_the_route_handling_the_given_document_type(); + void get_document_messages_with_legacy_document_ids_are_sent_to_all_routes(); void testExternSend(); void testExternMultipleSlobroks(); void testLoadBalancer(); @@ -108,6 +110,8 @@ Test::Main() { testDocumentRouteSelectorIgnore(); TEST_FLUSH(); remove_document_messages_are_sent_to_the_route_handling_the_given_document_type(); TEST_FLUSH(); remove_document_messages_with_legacy_document_ids_are_sent_to_all_routes(); TEST_FLUSH(); + get_document_messages_are_sent_to_the_route_handling_the_given_document_type(); TEST_FLUSH(); + get_document_messages_with_legacy_document_ids_are_sent_to_all_routes(); TEST_FLUSH(); testExternSend(); TEST_FLUSH(); testExternMultipleSlobroks(); TEST_FLUSH(); testLoadBalancer(); TEST_FLUSH(); @@ -685,6 +689,12 @@ makeRemove(vespalib::string docId) return std::make_unique(DocumentId(docId)); } +std::unique_ptr +makeGet(vespalib::string docId) +{ + return std::make_unique(DocumentId(docId)); +} + } void @@ -711,6 +721,30 @@ Test::remove_document_messages_with_legacy_document_ids_are_sent_to_all_routes() EXPECT_TRUE(frame->testSelect({"testdoc-route", "other-route"})); } +void +Test::get_document_messages_are_sent_to_the_route_handling_the_given_document_type() +{ + auto frame = createFrameWithTwoRoutes(_repo); + + frame->setMessage(makeGet("id:ns:testdoc::1")); + EXPECT_TRUE(frame->testSelect({"testdoc-route"})); + + frame->setMessage(makeGet("id:ns:other::1")); + EXPECT_TRUE(frame->testSelect({"other-route"})); +} + +void +Test::get_document_messages_with_legacy_document_ids_are_sent_to_all_routes() +{ + auto frame = createFrameWithTwoRoutes(_repo); + + frame->setMessage(makeGet("userdoc:testdoc:1234:1")); + EXPECT_TRUE(frame->testSelect({"testdoc-route", "other-route"})); + + frame->setMessage(makeGet("userdoc:other:1234:1")); + EXPECT_TRUE(frame->testSelect({"testdoc-route", "other-route"})); +} + namespace { string getDefaultDistributionConfig( uint16_t redundancy = 2, uint16_t nodeCount = 10, -- cgit v1.2.3