summaryrefslogtreecommitdiffstats
path: root/documentapi/src/tests
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2018-02-08 14:43:48 +0100
committerGeir Storli <geirst@oath.com>2018-02-13 10:23:09 +0000
commit929f50928b8a3aedaaf04e25de823a660c16a6e6 (patch)
tree51ffa6ebaed790b79f1a627f8163bf6fcbd277b0 /documentapi/src/tests
parent0152a705361a3597374ac0482c7e475d1a68787c (diff)
Route document removes only to the recipient(s) handling the document type (as given in the document id).
For legacy document ids (without document type) we still use all the routes.
Diffstat (limited to 'documentapi/src/tests')
-rw-r--r--documentapi/src/tests/policies/policies_test.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/documentapi/src/tests/policies/policies_test.cpp b/documentapi/src/tests/policies/policies_test.cpp
index 58db3079631..cc598aef786 100644
--- a/documentapi/src/tests/policies/policies_test.cpp
+++ b/documentapi/src/tests/policies/policies_test.cpp
@@ -63,6 +63,8 @@ public:
void testAND();
void testDocumentRouteSelector();
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 testExternSend();
void testExternMultipleSlobroks();
void testLoadBalancer();
@@ -103,6 +105,8 @@ Test::Main() {
testAND(); TEST_FLUSH();
testDocumentRouteSelector(); TEST_FLUSH();
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();
testExternSend(); TEST_FLUSH();
testExternMultipleSlobroks(); TEST_FLUSH();
testLoadBalancer(); TEST_FLUSH();
@@ -673,6 +677,62 @@ Test::testDocumentRouteSelectorIgnore()
}
namespace {
+
+vespalib::string
+createDocumentRouteSelectorConfigWithTwoRoutes()
+{
+ return "[DocumentRouteSelector:raw:"
+ "route[2]\n"
+ "route[0].name \"testdoc-route\"\n"
+ "route[0].selector \"testdoc and testdoc.stringfield != '0'\"\n"
+ "route[0].feed \"\"\n"
+ "route[1].name \"other-route\"\n"
+ "route[1].selector \"other and other.intfield != '0'\"\n"
+ "route[1].feed \"\"\n]";
+}
+
+std::unique_ptr<TestFrame>
+createFrameWithTwoRoutes(DocumentTypeRepo::SP repo)
+{
+ auto result = std::make_unique<TestFrame>(repo);
+ result->setHop(mbus::HopSpec("test", createDocumentRouteSelectorConfigWithTwoRoutes())
+ .addRecipient("testdoc-route").addRecipient("other-route"));
+ return result;
+}
+
+std::unique_ptr<RemoveDocumentMessage>
+makeRemove(vespalib::string docId)
+{
+ return std::make_unique<RemoveDocumentMessage>(DocumentId(docId));
+}
+
+}
+
+void
+Test::remove_document_messages_are_sent_to_the_route_handling_the_given_document_type()
+{
+ auto frame = createFrameWithTwoRoutes(_repo);
+
+ frame->setMessage(makeRemove("id:ns:testdoc::1"));
+ EXPECT_TRUE(frame->testSelect({"testdoc-route"}));
+
+ frame->setMessage(makeRemove("id:ns:other::1"));
+ EXPECT_TRUE(frame->testSelect({"other-route"}));
+}
+
+void
+Test::remove_document_messages_with_legacy_document_ids_are_sent_to_all_routes()
+{
+ auto frame = createFrameWithTwoRoutes(_repo);
+
+ frame->setMessage(makeRemove("userdoc:testdoc:1234:1"));
+ EXPECT_TRUE(frame->testSelect({"testdoc-route", "other-route"}));
+
+ frame->setMessage(makeRemove("userdoc:other:1234:1"));
+ EXPECT_TRUE(frame->testSelect({"testdoc-route", "other-route"}));
+}
+
+namespace {
string getDefaultDistributionConfig(
uint16_t redundancy = 2, uint16_t nodeCount = 10,
storage::lib::Distribution::DiskDistribution distr