Update monitor probe tests for java 9: this stuff is no longer accessible
This commit is contained in:
parent
6ba4d132df
commit
af2df9aef6
|
@ -227,6 +227,7 @@ 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));
|
||||
}
|
||||
|
|
|
@ -54,11 +54,14 @@ public class OsProbeTests extends ESTestCase {
|
|||
}
|
||||
|
||||
assertNotNull(stats.getMem());
|
||||
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)));
|
||||
// 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)));
|
||||
}
|
||||
|
||||
assertNotNull(stats.getSwap());
|
||||
assertNotNull(stats.getSwap().getTotal());
|
||||
|
@ -70,9 +73,12 @@ public class OsProbeTests extends ESTestCase {
|
|||
assertThat(stats.getSwap().getUsed().bytes(), greaterThanOrEqualTo(0L));
|
||||
} else {
|
||||
// On platforms with no swap
|
||||
assertThat(stats.getSwap().getTotal().bytes(), equalTo(0L));
|
||||
assertThat(stats.getSwap().getFree().bytes(), equalTo(0L));
|
||||
assertThat(stats.getSwap().getUsed().bytes(), equalTo(0L));
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,11 @@ public class ProcessProbeTests extends ESTestCase {
|
|||
assertThat(stats.getOpenFileDescriptors(), equalTo(-1L));
|
||||
assertThat(stats.getMaxFileDescriptors(), equalTo(-1L));
|
||||
} else {
|
||||
assertThat(stats.getOpenFileDescriptors(), greaterThan(0L));
|
||||
assertThat(stats.getMaxFileDescriptors(), greaterThan(0L));
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
ProcessStats.Cpu cpu = stats.getCpu();
|
||||
|
@ -62,11 +65,14 @@ 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
|
||||
assertThat(cpu.total, greaterThan(0L));
|
||||
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));
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue