Skip to content

Commit

Permalink
Fix MigrateData object tests for compat routines
Browse files Browse the repository at this point in the history
Several of the tests for obj_make_compatible() in the test_migrate_data
module were making negative contains assertions (which are a bit
dangerous when unchecked) against the wrong level of the primitive.
This fixes those, adds at least one positive assertion to validate the
pattern in each case.

Change-Id: If94428b7ac47e61875e3e3efaf681ed6500b3fea
  • Loading branch information
kk7ds committed Jun 18, 2018
1 parent ca7d23a commit f51ac65
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions nova/tests/unit/objects/test_migrate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,23 @@ def test_obj_make_compatible(self):
supported_perf_events=[],
serial_listen_addr='127.0.0.1',
target_connect_addr='127.0.0.1')
primitive = obj.obj_to_primitive(target_version='1.0')

data = lambda x: x['nova_object.data']

primitive = data(obj.obj_to_primitive())
self.assertIn('serial_listen_addr', primitive)
primitive = data(obj.obj_to_primitive(target_version='1.0'))
self.assertNotIn('target_connect_addr', primitive)
self.assertNotIn('serial_listen_addr=', primitive)
self.assertNotIn('supported_perf_events', primitive)
self.assertNotIn('old_vol_attachment_ids', primitive)
self.assertNotIn('src_supports_native_luks', primitive)
primitive = obj.obj_to_primitive(target_version='1.1')
self.assertNotIn('serial_listen_addr=', primitive)
primitive = obj.obj_to_primitive(target_version='1.2')
primitive = data(obj.obj_to_primitive(target_version='1.1'))
self.assertNotIn('serial_listen_ports', primitive)
primitive = data(obj.obj_to_primitive(target_version='1.2'))
self.assertNotIn('supported_perf_events', primitive)
primitive = obj.obj_to_primitive(target_version='1.3')
primitive = data(obj.obj_to_primitive(target_version='1.3'))
self.assertNotIn('old_vol_attachment_ids', primitive)
primitive = obj.obj_to_primitive(target_version='1.4')
primitive = data(obj.obj_to_primitive(target_version='1.4'))
self.assertNotIn('src_supports_native_luks', primitive)

def test_bdm_obj_make_compatible(self):
Expand Down Expand Up @@ -381,9 +385,14 @@ def test_obj_make_compatible(self):
obj = migrate_data.HyperVLiveMigrateData(
is_shared_instance_path=True,
old_vol_attachment_ids={'yes': 'no'})
primitive = obj.obj_to_primitive(target_version='1.0')

data = lambda x: x['nova_object.data']

primitive = data(obj.obj_to_primitive())
self.assertIn('is_shared_instance_path', primitive)
primitive = data(obj.obj_to_primitive(target_version='1.0'))
self.assertNotIn('is_shared_instance_path', primitive)
primitive = obj.obj_to_primitive(target_version='1.1')
primitive = data(obj.obj_to_primitive(target_version='1.1'))
self.assertNotIn('old_vol_attachment_ids', primitive)

def test_to_legacy_dict(self):
Expand Down Expand Up @@ -450,9 +459,14 @@ def test_migrate_data(self):

def test_obj_make_compatible(self):
obj = self._mk_obj()
primitive = obj.obj_to_primitive(target_version='1.0')

data = lambda x: x['nova_object.data']

primitive = data(obj.obj_to_primitive())
self.assertIn('vea_vlan_mappings', primitive)
primitive = data(obj.obj_to_primitive(target_version='1.0'))
self.assertNotIn('vea_vlan_mappings', primitive)
primitive = obj.obj_to_primitive(target_version='1.1')
primitive = data(obj.obj_to_primitive(target_version='1.1'))
self.assertNotIn('old_vol_attachment_ids', primitive)

def test_to_legacy_dict(self):
Expand Down

0 comments on commit f51ac65

Please sign in to comment.