diff options
author | Geir Storli <geirst@oath.com> | 2018-02-08 14:43:48 +0100 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2018-02-13 10:23:09 +0000 |
commit | 929f50928b8a3aedaaf04e25de823a660c16a6e6 (patch) | |
tree | 51ffa6ebaed790b79f1a627f8163bf6fcbd277b0 /documentapi/src/test | |
parent | 0152a705361a3597374ac0482c7e475d1a68787c (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/test')
-rwxr-xr-x | documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/PolicyTestCase.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/PolicyTestCase.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/PolicyTestCase.java index 45409877285..9db4d1c0d2e 100755 --- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/PolicyTestCase.java +++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/PolicyTestCase.java @@ -357,6 +357,50 @@ public class PolicyTestCase { } @Test + public void remove_document_messages_are_sent_to_the_route_handling_the_given_document_type() { + PolicyTestFrame frame = createFrameWithTwoRoutes(); + + frame.setMessage(createRemove("id:ns:testdoc::1")); + frame.assertSelect(Arrays.asList("testdoc-route")); + + frame.setMessage(createRemove("id:ns:other::1")); + frame.assertSelect(Arrays.asList("other-route")); + } + + @Test + public void remove_document_messages_with_legacy_document_ids_are_sent_to_all_routes() { + PolicyTestFrame frame = createFrameWithTwoRoutes(); + + frame.setMessage(createRemove("userdoc:testdoc:1234:1")); + frame.assertSelect(Arrays.asList("testdoc-route", "other-route")); + + frame.setMessage(createRemove("userdoc:other:1234:1")); + frame.assertSelect(Arrays.asList("testdoc-route", "other-route")); + } + + private PolicyTestFrame createFrameWithTwoRoutes() { + PolicyTestFrame result = new PolicyTestFrame(manager); + result.setHop(new HopSpec("test", createDocumentRouteSelectorConfigWithTwoRoutes()) + .addRecipient("testdoc-route").addRecipient("other-route")); + return result; + } + + private 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]"; + } + + private RemoveDocumentMessage createRemove(String docId) { + return new RemoveDocumentMessage(new DocumentId(docId)); + } + + @Test public void testSubsetService() { PolicyTestFrame frame = new PolicyTestFrame("docproc/cluster.default", manager); frame.setMessage(new PutDocumentMessage(new DocumentPut(new DocumentPut(new Document(manager.getDocumentType("testdoc"), |