Fix MonitorMetric obj_make_compatible
The 'obj_make_compatible' method of MonitorMetric object doesn't work properly because conditional expression is not correct. So fix it and add a unit test for it. Change-Id: I9e5e8b975195b8120e6c10398c284d6a2f5efab9 Closes-Bug: #1617859
This commit is contained in:
parent
dee72f44fe
commit
c651572d5a
@ -49,7 +49,7 @@ class MonitorMetric(base.NovaObject):
|
||||
super(MonitorMetric, self).obj_make_compatible(primitive,
|
||||
target_version)
|
||||
target_version = versionutils.convert_version_to_tuple(target_version)
|
||||
if target_version < (1, 1) and 'numa_nodes_values' in primitive:
|
||||
if target_version < (1, 1) and 'numa_membw_values' in primitive:
|
||||
del primitive['numa_membw_values']
|
||||
|
||||
# NOTE(jaypipes): This method exists to convert the object to the
|
||||
|
@ -85,6 +85,18 @@ class _TestMonitorMetricObject(object):
|
||||
exp = spec['value'] * 100
|
||||
self.assertEqual(exp, metric.value)
|
||||
|
||||
def test_obj_make_compatible(self):
|
||||
monitormetric_obj = objects.MonitorMetric(
|
||||
name=fields.MonitorMetricType.NUMA_MEM_BW_CURRENT,
|
||||
numa_membw_values={"0": 10, "1": 43},
|
||||
timestamp=_ts_now.isoformat(),
|
||||
source='nova.virt.libvirt.driver')
|
||||
primitive = monitormetric_obj.obj_to_primitive()
|
||||
self.assertIn('numa_membw_values', primitive['nova_object.data'])
|
||||
monitormetric_obj.obj_make_compatible(primitive['nova_object.data'],
|
||||
'1.0')
|
||||
self.assertNotIn('numa_membw_values', primitive['nova_object.data'])
|
||||
|
||||
|
||||
class TestMonitorMetricObject(test_objects._LocalTest,
|
||||
_TestMonitorMetricObject):
|
||||
|
Loading…
Reference in New Issue
Block a user