From 1467b2e7bf63f0aeef8b7be8405e341712e790af Mon Sep 17 00:00:00 2001 From: Richard North Date: Sun, 22 Jan 2017 07:55:42 +0000 Subject: [PATCH] Relax disk space checking to not abort in cases where `df` output shows no available volumes (see #273). While the cause is not known, and Docker may yet fail, relaxing this constraint at least lets Docker try without aborting prematurely. Use functional operation to compare disk space if not null --- .../main/java/org/testcontainers/DockerClientFactory.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/core/src/main/java/org/testcontainers/DockerClientFactory.java b/core/src/main/java/org/testcontainers/DockerClientFactory.java index 6a12aa0acdb..26facdfbec7 100644 --- a/core/src/main/java/org/testcontainers/DockerClientFactory.java +++ b/core/src/main/java/org/testcontainers/DockerClientFactory.java @@ -151,7 +151,7 @@ private void checkDiskSpace(DockerClient client) { df.usedPercent.map(x -> x + "%").orElse("unknown"), df.availableMB.map(x -> x + " MB available").orElse("unknown available")); - if (df.availableMB.orElseThrow(NotAbleToGetDiskSpaceUsageException::new) < 2048) { + if (df.availableMB.map(it -> it < 2048).orElse(false)) { log.error("Docker environment has less than 2GB free - execution is unlikely to succeed so will be aborted."); throw new NotEnoughDiskSpaceException("Not enough disk space in Docker environment"); } @@ -235,10 +235,4 @@ private static class NotEnoughDiskSpaceException extends RuntimeException { super(message); } } - - private static class NotAbleToGetDiskSpaceUsageException extends RuntimeException { - NotAbleToGetDiskSpaceUsageException() { - super(); - } - } }