Account for compute.metrics.update in legacy notification whitelist
The compute.metrics.update legacy unversioned notification was missing from the whitelist because the only test for it was mocking out the rpc notifier call, which is what validates the entries in the whitelist. This adds the entry to the whitelist and fixes the test to actually use the notifier code. Change-Id: Ie278ca58c371b8e3bd4861e6c86ebcf30c6778ea Closes-Bug: #1717943
This commit is contained in:
parent
0aeaa2bce8
commit
963bf956ce
|
@ -338,6 +338,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 pci_device
|
|||
from nova.pci import manager as pci_manager
|
||||
from nova.scheduler import utils as sched_utils
|
||||
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
|
||||
|
||||
|
@ -2664,8 +2665,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()
|
||||
|
@ -2688,7 +2691,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 = [
|
||||
{
|
||||
|
@ -2706,8 +2708,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