nova/nova/tests/unit/compute/monitors
Joe Cropper 7fe05a8ca4 Ensure Nova metrics derived from a set of metrics
This patch addresses a problem in which the current Nova metrics can
yield a set of incoherent results. For example, prior to this patch,
it is possible that a collection of metrics sent in a single RPC
notification message can contain values such as the following:

{'cpu.user.percent': A, 'cpu.kernel.percent': B,
 'cpu.idle.percent': C, 'cpu.iowait.percent': D} such that you can
end up with A + B + C + D != 100, which does not make any sense
from an end consumer perspective.

The root cause of this problem stems from the fact that each
individual metric retrieval (i.e., via get_metric(name)) could
result in the driver.get_host_cpu_stats() function being called,
which leads to the incoherent results mentioned above.

To solve this, we only refresh the metric data once per collection
cycle. Additionally, the `Monitor` base class uses get_metrics()
instead of get_metric() and returns a 3-tuple of the form
(metric_name, metric_value, timestamp).

This patch also removes some code from the CPU virt_driver's
_update_data() method that checked whether the last call was
less than 1 second ago, which seemed to try to solve this
coherency issue, but didn't really work all of the time (and hence
how this defect was encountered to begin with). Given we use the
[more appropriate] metric set approach now, this code no longer
serves any purpose.

Unit tests updated to work with the new framework.

Change-Id: Ia23783f2e6b92b3af2e9acf09f95a9eeacd8eb3b
Closes-Bug: 1490837
Co-authored-by: Jay Pipes <jaypipes@gmail.com>
2015-10-04 21:28:13 -05:00
..
cpu Ensure Nova metrics derived from a set of metrics 2015-10-04 21:28:13 -05:00
__init__.py move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
test_monitors.py Allow compute monitors in different namespaces 2015-08-20 15:07:24 -04:00