Merge "Account for compute.metrics.update in legacy notification whitelist" into stable/newton
This commit is contained in:
commit
b60b79c1fd
|
@ -300,6 +300,7 @@ class LegacyValidatingNotifier(object):
|
|||
'compute.instance.volume.attach',
|
||||
'compute.instance.volume.detach',
|
||||
'compute.libvirt.error',
|
||||
'compute.metrics.update',
|
||||
'compute_task.build_instances',
|
||||
'compute_task.migrate_server',
|
||||
'compute_task.rebuild_server',
|
||||
|
|
|
@ -33,6 +33,7 @@ from nova.objects import base as obj_base
|
|||
from nova.objects import pci_device
|
||||
from nova.pci import manager as pci_manager
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_notifier
|
||||
from nova.tests.unit.objects import test_pci_device as fake_pci_device
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
|
@ -2232,8 +2233,10 @@ class ComputeMonitorTestCase(BaseTestCase):
|
|||
u'Cannot get the metrics from %(mon)s; error: %(exc)s', mock.ANY)
|
||||
self.assertEqual(0, len(metrics))
|
||||
|
||||
@mock.patch('nova.rpc.get_notifier')
|
||||
def test_get_host_metrics(self, rpc_mock):
|
||||
def test_get_host_metrics(self):
|
||||
fake_notifier.stub_notifier(self)
|
||||
self.addCleanup(fake_notifier.reset)
|
||||
|
||||
class FakeCPUMonitor(monitor_base.MonitorBase):
|
||||
|
||||
NOW_TS = timeutils.utcnow()
|
||||
|
@ -2256,7 +2259,6 @@ class ComputeMonitorTestCase(BaseTestCase):
|
|||
self.rt.monitors = [FakeCPUMonitor(None)]
|
||||
|
||||
metrics = self.rt._get_host_metrics(self.context, _NODENAME)
|
||||
rpc_mock.assert_called_once_with(service='compute', host=_NODENAME)
|
||||
|
||||
expected_metrics = [
|
||||
{
|
||||
|
@ -2274,8 +2276,18 @@ class ComputeMonitorTestCase(BaseTestCase):
|
|||
'nodename': _NODENAME,
|
||||
}
|
||||
|
||||
rpc_mock.return_value.info.assert_called_once_with(
|
||||
self.context, 'compute.metrics.update', payload)
|
||||
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
|
||||
msg = fake_notifier.NOTIFICATIONS[0]
|
||||
self.assertEqual('compute.metrics.update', msg.event_type)
|
||||
for p_key in payload:
|
||||
if p_key == 'metrics':
|
||||
self.assertIn(p_key, msg.payload)
|
||||
self.assertEqual(1, len(msg.payload['metrics']))
|
||||
# make sure the expected metrics match the actual metrics
|
||||
self.assertDictEqual(expected_metrics[0],
|
||||
msg.payload['metrics'][0])
|
||||
else:
|
||||
self.assertEqual(payload[p_key], msg.payload[p_key])
|
||||
|
||||
self.assertEqual(metrics, expected_metrics)
|
||||
|
||||
|
|
Loading…
Reference in New Issue