use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testDestroyAbortsSessionIfNotDone.
@Test
public void testDestroyAbortsSessionIfNotDone() throws Exception {
MockComponents mc = createDefaultMock("id.user==1234");
mc.visitorSession.start();
mc.executor.expectAndProcessTasks(1);
mc.controlHandler.setSynchronousWaitUntilDone(true);
mc.controlHandler.resetMock();
final MessageBusVisitorSession session = mc.visitorSession;
final SharedValue<Exception> exceptionPropagator = new SharedValue<Exception>();
final CyclicBarrier barrier = new CyclicBarrier(2);
// Have to do this multi-threaded for once since destroy is
// synchronous and any code logic bug could otherwise cause the
// test (and thus the build) to hang indefinitely.
// NOTE: even though the MockControlHandler itself is not thread safe,
// the control flow of the test should guarantee there is no concurrent
// access to it.
Thread t = new Thread(() -> {
try {
session.destroy();
if (!session.isDone()) {
throw new IllegalStateException("Session is not marked as done after destroy()");
}
barrier.await(20000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
exceptionPropagator.setValue(e);
}
});
t.start();
try {
waitUntilTrue(20000, () -> session.isDestroying());
// Reply to visitor. Normally, the visitor would be resent, but
// since destroy aborts the session, this won't happen and the
// session will be marked as completed instead.
replyErrorToCreateVisitor(mc.sender, new Error(DocumentProtocol.ERROR_BUCKET_DELETED, "goner"));
// reply
mc.executor.expectAndProcessTasks(1);
mc.executor.expectNoTasks();
barrier.await(20000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
t.interrupt();
throw e;
} finally {
t.join();
}
if (exceptionPropagator.getValue() != null) {
throw new IllegalStateException("Exception thrown in destruction thread", exceptionPropagator.getValue());
}
assertTrue(mc.sender.isDestroyed());
assertTrue(mc.receiver.isDestroyed());
assertEquals("onDone : ABORTED - 'Session explicitly destroyed before completion'\n", mc.controlHandler.toString());
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testSkipBucketOnFatalMessageProcessingError.
@Test
public void testSkipBucketOnFatalMessageProcessingError() {
VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
visitorParameters.skipBucketsOnFatalErrors(true);
MockComponents mc = createDefaultMock(visitorParameters);
mc.controlHandler.resetMock();
mc.dataHandler.resetMock();
mc.dataHandler.setExceptionOnMessage(new IllegalArgumentException("oh no"));
mc.visitorSession.start();
mc.executor.expectAndProcessTasks(1);
mc.receiver.send(new RemoveDocumentMessage(new DocumentId("doc:foo:bar")));
mc.executor.expectAndProcessTasks(1);
assertEquals(1, mc.dataHandler.getMessages().size());
// NOTE: current behavior does _not_ fail the session at the end of
// visiting if the CreateVisitor replies do not also return with failure
// since this is tied to the ProgressToken and its failed buckets list.
// We make the simplifying assumption that failing a visitor _message_
// will subsequently cause its reply to fail back to us, allowing us to
// handle this as a regular skippable bucket.
// TODO: reconsider this?
replyErrorToCreateVisitor(mc.sender, new Error(DocumentProtocol.ERROR_INTERNAL_FAILURE, "The Borkening"));
mc.executor.expectAndProcessTasks(1);
mc.executor.expectNoTasks();
assertTrue(mc.controlHandler.isDone());
// Get UNPARSEABLE rather than APP_FATAL_ERROR if skip buckets is set
assertEquals("RemoveDocumentReply(UNPARSEABLE: Got exception of type java.lang.IllegalArgumentException " + "with message 'oh no' while processing DocumentMessage)\n", mc.receiver.repliesToString());
assertEquals("onVisitorError : INTERNAL_FAILURE: The Borkening\n" + "onDone : FAILURE - 'INTERNAL_FAILURE: The Borkening'\n", mc.controlHandler.toString());
assertEquals("FAILURE: INTERNAL_FAILURE: The Borkening", mc.controlHandler.getResult().toString());
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testSilentlyIgnoreBucketDeletedNotFoundErrors.
@Test
public void testSilentlyIgnoreBucketDeletedNotFoundErrors() {
MockComponents mc = createDefaultMock("id.user==1234");
mc.controlHandler.resetMock();
mc.visitorSession.start();
mc.executor.expectAndProcessTasks(1);
replyErrorToCreateVisitor(mc.sender, new Error(DocumentProtocol.ERROR_BUCKET_NOT_FOUND, "dave's not here, maaan"));
// reply
mc.executor.expectAndProcessTasks(1);
// Should just resend with a 100ms delay
mc.executor.expectAndProcessTasks(1, new long[] { 100 });
// Now hit it with a BUCKET_DELETED error, which is also silent
replyErrorToCreateVisitor(mc.sender, new Error(DocumentProtocol.ERROR_BUCKET_DELETED, "dave's not here either, maaan!"));
// reply
mc.executor.expectAndProcessTasks(1);
// Should also resend with a 100ms delay
mc.executor.expectAndProcessTasks(1, new long[] { 100 });
assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x80000000000004d2)\n" + "BucketId(0x0000000000000000)\n" + "]\n" + "selection='id.user==1234'\n)", replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET));
mc.executor.expectAndProcessTasks(1);
assertTrue(mc.controlHandler.isDone());
assertEquals("onProgress : 0 active, 0 pending, 1 finished, 1 total\n" + "onVisitorStatistics : 0 buckets visited, 0 docs returned\n" + "onDone : SUCCESS - ''\n", mc.controlHandler.toString());
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testWaitUntilVisitorsDoneOnFatalError.
/**
* Do not complete visiting upon fatal error until all replies have
* been received.
*/
@Test
public void testWaitUntilVisitorsDoneOnFatalError() {
MockComponents mc = createDefaultMock();
mc.visitorSession.start();
// clear messages
mc.controlHandler.resetMock();
mc.executor.expectAndProcessTasks(1);
assertEquals(2, mc.sender.getMessageCount());
replyToCreateVisitor(mc.sender, (reply) -> {
reply.addError(new Error(DocumentProtocol.ERROR_INTERNAL_FAILURE, "node fell down a well"));
});
// reply
mc.executor.expectAndProcessTasks(1);
mc.executor.expectNoTasks();
// no resending
assertEquals(1, mc.sender.getMessageCount());
// not done yet
assertFalse(mc.visitorSession.isDone());
replyToCreateVisitor(mc.sender, (reply) -> {
reply.addError(new Error(DocumentProtocol.ERROR_INTERNAL_FAILURE, "node got hit by a falling brick"));
});
// reply
mc.executor.expectAndProcessTasks(1);
mc.executor.expectNoTasks();
// no resending
assertEquals(0, mc.sender.getMessageCount());
assertTrue(mc.visitorSession.isDone());
// should get first received failure message as completion failure message
assertEquals("onVisitorError : INTERNAL_FAILURE: node fell down a well\n" + "onVisitorError : INTERNAL_FAILURE: node got hit by a falling brick\n" + "onDone : FAILURE - 'INTERNAL_FAILURE: node fell down a well'\n", mc.controlHandler.toString());
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testFailVisitingOnFatalError.
@Test
public void testFailVisitingOnFatalError() {
MockComponents mc = createDefaultMock("id.user==1234");
mc.visitorSession.start();
mc.controlHandler.resetMock();
mc.executor.expectAndProcessTasks(1);
replyToCreateVisitor(mc.sender, (reply) -> {
reply.addError(new Error(DocumentProtocol.ERROR_INTERNAL_FAILURE, "node caught fire"));
});
// reply
mc.executor.expectAndProcessTasks(1);
mc.executor.expectNoTasks();
assertEquals(0, mc.sender.getMessageCount());
assertTrue(mc.visitorSession.isDone());
assertEquals("onVisitorError : INTERNAL_FAILURE: node caught fire\n" + "onDone : FAILURE - 'INTERNAL_FAILURE: node caught fire'\n", mc.controlHandler.toString());
}
Aggregations