@Test
@SuppressWarnings("ConstantConditions")
public void instanceErrorHandlingContainerExternallyTerminated() {

    DefaultDockerCloudClient client = createClient();
    DockerImage image = waitForImage(client);
    DockerInstance instance = client.startNewInstance(image, userData);
    waitForInstanceStatus(instance, InstanceStatus.RUNNING);
    TestDockerClientFacade clientFacade = testCloudSupport.getClientFacade();
    clientFacade.getAgentHolders().get(0).running(false);
    waitUntil(() -> instance.getStatus() == InstanceStatus.ERROR);
    waitUntil(() -> image.getInstances().isEmpty());
    waitUntil(() -> clientFacade.getAgentHolders().isEmpty());
}