@Test
    public void visitor_command_timeout_set_to_min_of_message_timeout_and_remaining_session_timeout() {
        MockComponents mc = createTimeoutMocksAtInitialTime(6_000, 10_000, 10_000, 1);

        // Superbucket 1 of 2
        assertEquals("CreateVisitorMessage(buckets=[\n" +
                        "BucketId(0x0400000000000000)\n" +
                        "BucketId(0x0000000000000000)\n" +
                        "]\n" +
                        "time remaining=6000\n)",
                replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET));

        mc.clock.setMonotonicTime(15, TimeUnit.SECONDS); // 5 seconds elapsed from baseline
        mc.executor.expectAndProcessTasks(1); // reply
        mc.executor.expectAndProcessTasks(1); // send create visitors
        // Superbucket 2 of 2
        assertEquals("CreateVisitorMessage(buckets=[\n" +
                        "BucketId(0x0400000000000001)\n" +
                        "BucketId(0x0000000000000000)\n" +
                        "]\n" +
                        "time remaining=5000\n)", // No timeout greater than 5s can be used, or session will have timed out
                replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET));
    }
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