diff options
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 31 | ||||
| -rw-r--r-- | nova/tests/fake_network_cache_model.py | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index ce688eb90..c36496f79 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3964,6 +3964,37 @@ class ComputeTestCase(BaseTestCase): self.compute._init_instance(self.context, instance) + def test_init_instance_update_nw_info_cache(self): + cached_nw_info = fake_network_cache_model.new_vif() + cached_nw_info = network_model.NetworkInfo([cached_nw_info]) + old_cached_nw_info = copy.deepcopy(cached_nw_info) + # Folsom has no 'type' in network cache info. + del old_cached_nw_info[0]['type'] + fake_info_cache = {'network_info': old_cached_nw_info.json()} + instance = { + 'uuid': 'a-foo-uuid', + 'vm_state': vm_states.ACTIVE, + 'task_state': None, + 'power_state': power_state.RUNNING, + 'info_cache': fake_info_cache, + } + + self.mox.StubOutWithMock(self.compute, '_get_power_state') + self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info') + self.mox.StubOutWithMock(self.compute.driver, 'plug_vifs') + + self.compute._get_power_state(mox.IgnoreArg(), + instance).AndReturn(power_state.RUNNING) + # Call network API to get instance network info, and force + # an update to instance's info_cache. + self.compute._get_instance_nw_info(self.context, + instance).AndReturn(cached_nw_info) + self.compute.driver.plug_vifs(instance, cached_nw_info.legacy()) + + self.mox.ReplayAll() + + self.compute._init_instance(self.context, instance) + def test_get_instances_on_driver(self): fake_context = context.get_admin_context() diff --git a/nova/tests/fake_network_cache_model.py b/nova/tests/fake_network_cache_model.py index 3aa3bf586..2c1d0ad25 100644 --- a/nova/tests/fake_network_cache_model.py +++ b/nova/tests/fake_network_cache_model.py @@ -65,6 +65,7 @@ def new_vif(vif_dict=None): vif = dict( id=1, address='aa:aa:aa:aa:aa:aa', + type='bridge', network=new_network()) vif_dict = vif_dict or {} vif.update(vif_dict) |
