Allow negative Load average in test, see #2664

* According to documentation it can be negative for some OS
This commit is contained in:
Patrik Nordwall 2012-11-05 17:11:07 +01:00
parent 8eec825f18
commit edc9fd733d
2 changed files with 3 additions and 2 deletions

View file

@ -463,7 +463,7 @@ private[cluster] class MetricsCollector private (private val sigar: Option[AnyRe
/**
* (SIGAR / JMX) Returns the OS-specific average system load on the CPUs in the system, for the past 1 minute.
* On some systems the JMX OS system load average may not be available, in which case a -1 is returned.
* On some systems the JMX OS system load average may not be available, in which case a negative value is returned.
* Hyperic SIGAR provides more precise values, thus, if the library is on the classpath, it is the default.
*/
def systemLoadAverage: Metric = Metric("system-load-average", Some(BigDecimal(Try(

View file

@ -78,11 +78,12 @@ class MetricsCollectorSpec extends AkkaSpec(MetricsEnabledSpec.config) with Impl
val metrics = sample.metrics.collect { case m if m.isDefined (m.name, m.value.get) }
val used = metrics collectFirst { case ("heap-memory-used", b) b }
val committed = metrics collectFirst { case ("heap-memory-committed", b) b }
metrics foreach {
case ("total-cores", b) b.intValue must be > (0)
case ("network-max-rx", b) b.longValue must be > (0L)
case ("network-max-tx", b) b.longValue must be > (0L)
case ("system-load-average", b) b.doubleValue must be >= (0.0)
case ("system-load-average", b) // not possible to assert b, allowed to be negative or positive
case ("processors", b) b.intValue must be >= (0)
case ("heap-memory-used", b) b.longValue must be >= (0L)
case ("heap-memory-committed", b) b.longValue must be > (0L)