@Test
    public void testKiboshFaults() throws Exception {
        MockTime time = new MockTime(0, 0, 0);
        MockScheduler scheduler = new MockScheduler(time);
        Agent agent = createAgent(scheduler);
        AgentClient client = new AgentClient.Builder().
            maxTries(10).target("localhost", agent.port()).build();
        new ExpectedTasks().waitFor(client);

        try (MockKibosh mockKibosh = new MockKibosh()) {
            assertEquals(KiboshControlFile.EMPTY, mockKibosh.read());
            FilesUnreadableFaultSpec fooSpec = new FilesUnreadableFaultSpec(0, 900000,
                Collections.singleton("myAgent"), mockKibosh.tempDir.getPath(), "/foo", 123);
            client.createWorker(new CreateWorkerRequest(0, "foo", fooSpec));
            new ExpectedTasks().
                addTask(new ExpectedTaskBuilder("foo").
                    workerState(new WorkerRunning("foo", fooSpec, 0, new TextNode("Added fault foo"))).
                    build()).
                waitFor(client);
            assertEquals(new KiboshControlFile(Collections.singletonList(
                new KiboshFilesUnreadableFaultSpec("/foo", 123))), mockKibosh.read());
            FilesUnreadableFaultSpec barSpec = new FilesUnreadableFaultSpec(0, 900000,
                Collections.singleton("myAgent"), mockKibosh.tempDir.getPath(), "/bar", 456);
            client.createWorker(new CreateWorkerRequest(1, "bar", barSpec));
            new ExpectedTasks().
                addTask(new ExpectedTaskBuilder("foo").
                    workerState(new WorkerRunning("foo", fooSpec, 0, new TextNode("Added fault foo"))).build()).
                addTask(new ExpectedTaskBuilder("bar").
                    workerState(new WorkerRunning("bar", barSpec, 0, new TextNode("Added fault bar"))).build()).
                waitFor(client);
            assertEquals(new KiboshControlFile(asList(
                new KiboshFilesUnreadableFaultSpec("/foo", 123),
                new KiboshFilesUnreadableFaultSpec("/bar", 456))
            ), mockKibosh.read());
            time.sleep(1);
            client.stopWorker(new StopWorkerRequest(0));
            new ExpectedTasks().
                addTask(new ExpectedTaskBuilder("foo").
                    workerState(new WorkerDone("foo", fooSpec, 0, 1, new TextNode("Removed fault foo"), "")).build()).
                addTask(new ExpectedTaskBuilder("bar").
                    workerState(new WorkerRunning("bar", barSpec, 0, new TextNode("Added fault bar"))).build()).
                waitFor(client);
            assertEquals(new KiboshControlFile(Collections.singletonList(
                new KiboshFilesUnreadableFaultSpec("/bar", 456))), mockKibosh.read());
        }
    }
Modify sleep() to call super.sleep() every second call
in order to avoid the endless loop in the tick() calls to the MockScheduler listener
trogdor/src/test/java/org/apache/kafka/trogdor/agent/AgentTest.java