diff --git a/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java b/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java index 0e8a7379c01..03f262f883b 100644 --- a/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java +++ b/core/src/main/java/org/elasticsearch/monitor/os/OsStats.java @@ -227,7 +227,6 @@ public class OsStats implements Streamable, ToXContent { } } - // TODO: if values are -1, this should return -1 to show its unsupported? private static short calculatePercentage(long used, long max) { return max <= 0 ? 0 : (short) (Math.round((100d * used) / max)); } diff --git a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java index 94bae66702b..6b8818a4931 100644 --- a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java @@ -54,14 +54,11 @@ public class OsProbeTests extends ESTestCase { } assertNotNull(stats.getMem()); - // TODO: once java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ) - if (!Constants.JRE_IS_MINIMUM_JAVA9) { - assertThat(stats.getMem().getTotal().bytes(), greaterThan(0L)); - assertThat(stats.getMem().getFree().bytes(), greaterThan(0L)); - assertThat(stats.getMem().getFreePercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100))); - assertThat(stats.getMem().getUsed().bytes(), greaterThan(0L)); - assertThat(stats.getMem().getUsedPercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100))); - } + assertThat(stats.getMem().getTotal().bytes(), greaterThan(0L)); + assertThat(stats.getMem().getFree().bytes(), greaterThan(0L)); + assertThat(stats.getMem().getFreePercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100))); + assertThat(stats.getMem().getUsed().bytes(), greaterThan(0L)); + assertThat(stats.getMem().getUsedPercent(), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100))); assertNotNull(stats.getSwap()); assertNotNull(stats.getSwap().getTotal()); @@ -73,12 +70,9 @@ public class OsProbeTests extends ESTestCase { assertThat(stats.getSwap().getUsed().bytes(), greaterThanOrEqualTo(0L)); } else { // On platforms with no swap - // TODO: one java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ) - if (!Constants.JRE_IS_MINIMUM_JAVA9) { - assertThat(stats.getSwap().getTotal().bytes(), equalTo(0L)); - assertThat(stats.getSwap().getFree().bytes(), equalTo(0L)); - assertThat(stats.getSwap().getUsed().bytes(), equalTo(0L)); - } + assertThat(stats.getSwap().getTotal().bytes(), equalTo(0L)); + assertThat(stats.getSwap().getFree().bytes(), equalTo(0L)); + assertThat(stats.getSwap().getUsed().bytes(), equalTo(0L)); } } } diff --git a/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java index 21bfcb287ac..18b5f7a7e19 100644 --- a/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/process/ProcessProbeTests.java @@ -51,11 +51,8 @@ public class ProcessProbeTests extends ESTestCase { assertThat(stats.getOpenFileDescriptors(), equalTo(-1L)); assertThat(stats.getMaxFileDescriptors(), equalTo(-1L)); } else { - // TODO: once java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ) - if (!Constants.JRE_IS_MINIMUM_JAVA9) { - assertThat(stats.getOpenFileDescriptors(), greaterThan(0L)); - assertThat(stats.getMaxFileDescriptors(), greaterThan(0L)); - } + assertThat(stats.getOpenFileDescriptors(), greaterThan(0L)); + assertThat(stats.getMaxFileDescriptors(), greaterThan(0L)); } ProcessStats.Cpu cpu = stats.getCpu(); @@ -65,14 +62,11 @@ public class ProcessProbeTests extends ESTestCase { assertThat(cpu.getPercent(), anyOf(lessThan((short) 0), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100)))); // CPU time can return -1 if the the platform does not support this operation, let's see which platforms fail - if (!Constants.JRE_IS_MINIMUM_JAVA9) { - // TODO: once java 9 is sorted out make these hard checks (currently 9-ea and 9-ea-jigsaw will differ) - assertThat(cpu.total, greaterThan(0L)); + assertThat(cpu.total, greaterThan(0L)); - ProcessStats.Mem mem = stats.getMem(); - assertNotNull(mem); - // Commited total virtual memory can return -1 if not supported, let's see which platforms fail - assertThat(mem.totalVirtual, greaterThan(0L)); - } + ProcessStats.Mem mem = stats.getMem(); + assertNotNull(mem); + // Commited total virtual memory can return -1 if not supported, let's see which platforms fail + assertThat(mem.totalVirtual, greaterThan(0L)); } }