@Test
public void interruptTaskAccordingToTimeout() {

    InstanceTestTaskDelegator task = new InstanceTestTaskDelegator(instance1);
    scheduler = new DockerTaskScheduler(3, false, Duration.ofMillis(500));
    task.fixture = () -> {
        Stopwatch sw = Stopwatch.start();
        try {
            Thread.sleep(TimeUnit.SECONDS.toMillis(2));
            fail("Not interrupted.");
        } catch (InterruptedException e) {
            assertThat(sw.getDuration().toMillis()).isCloseTo(500, offset(100L));
        }
    };
    scheduler.scheduleInstanceTask(task.task);
    waitUntil(task::isSuccessful);
}