From e5013d16f00bae7c76585a597e5d5b70bbfed890 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 18 Jan 2016 13:33:48 -0500 Subject: [PATCH] Fix test for load average on FreeBSD This commit fixes the test for load averages on FreeBSD. On FreeBSD, it is either the case that linprocfs is mounted at /compat/linux/proc in which case the load averages are available, or this is not the case and no load average are available. Previously, the test on FreeBSD was falling back to the catch all case which asserts that the five-minute and fifteen-minute load averages are not available. --- .../java/org/elasticsearch/monitor/os/OsProbeTests.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 83007c5a86c..8dd80231623 100644 --- a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java @@ -66,6 +66,12 @@ public class OsProbeTests extends ESTestCase { assertThat(loadAverage[0], greaterThanOrEqualTo((double) 0)); assertThat(loadAverage[1], greaterThanOrEqualTo((double) 0)); assertThat(loadAverage[2], greaterThanOrEqualTo((double) 0)); + } else if (Constants.FREE_BSD) { + // five- and fifteen-minute load averages not available if linprocfs is not mounted at /compat/linux/proc + assertNotNull(loadAverage); + assertThat(loadAverage[0], greaterThanOrEqualTo((double) 0)); + assertThat(loadAverage[1], anyOf(equalTo((double) -1), greaterThanOrEqualTo((double) 0))); + assertThat(loadAverage[2], anyOf(equalTo((double) -1), greaterThanOrEqualTo((double) 0))); } else { // one minute load average is available, but 10-minute and 15-minute load averages are not // load average can be negative if not available or not computed yet, otherwise it should be >= 0