@Test
    public void fail_session_with_timeout_if_timeout_has_elapsed() {
        MockComponents mc = createTimeoutMocksAtInitialTime(1_000, 4_000, 20_000, 1);

        replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET); // Super bucket 1 of 2
        mc.clock.setMonotonicTime(24_000, TimeUnit.MILLISECONDS); // 4 second timeout expired

        // Reply task processing shall discover that timeout has expired
        mc.executor.expectAndProcessTasks(1);
        mc.executor.expectNoTasks(); // No further send tasks enqueued
        assertTrue(mc.controlHandler.isDone());
        assertEquals("onProgress : 0 active, 1 pending, 1 finished, 2 total\n" +
                        "onVisitorStatistics : 0 buckets visited, 0 docs returned\n" +
                        "onDone : TIMEOUT - 'Session timeout of 4000 ms expired'\n",
                mc.controlHandler.toString());
    }
Test that there is no race condition between a reply is handed off
to the executor service via a task (thus decrementing the pending count
for the sender) and the session checking for completion early, e.g.
because of an error transitioning it into a failure state.
documentapi/src/test/java/com/yahoo/documentapi/messagebus/MessageBusVisitorSessionTestCase.java