aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/tests
diff options
context:
space:
mode:
authorTor Egge <tegge@oath.com>2018-11-01 13:06:46 +0000
committerTor Egge <Tor.Egge@oath.com>2018-11-01 13:42:34 +0000
commita561a101ecd0373ab6a8df6cd801dba195b86eaa (patch)
treef35a84889bbc248b2a152ba1f7fff76223b8a634 /documentapi/src/tests
parent8b3fa406566b29c620e267546cce22e923e9c7af (diff)
Narrow down routing of Document API GetDocument messages.
Diffstat (limited to 'documentapi/src/tests')
-rw-r--r--documentapi/src/tests/policies/policies_test.cpp34
1 files changed, 34 insertions, 0 deletions
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<RemoveDocumentMessage>(DocumentId(docId));
}
+std::unique_ptr<GetDocumentMessage>
+makeGet(vespalib::string docId)
+{
+ return std::make_unique<GetDocumentMessage>(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,