diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index 020fe81d491a..968e843f78c7 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -5839,7 +5839,7 @@ class ComputeTestCase(BaseTestCase): self.assertEqual(len(instances), 1) instance_name = instances[0]['name'] - self.compute.driver.test_remove_vm(instance_name) + self.compute.driver._test_remove_vm(instance_name) # Force the compute manager to do its periodic poll ctxt = context.get_admin_context() diff --git a/nova/tests/unit/virt/test_fake.py b/nova/tests/unit/virt/test_fake.py new file mode 100644 index 000000000000..0f34f3752e1c --- /dev/null +++ b/nova/tests/unit/virt/test_fake.py @@ -0,0 +1,26 @@ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from nova import test +from nova.virt import driver +from nova.virt import fake + + +class FakeDriverTest(test.NoDBTestCase): + + def test_public_api_signatures(self): + baseinst = driver.ComputeDriver(None) + inst = fake.FakeDriver(fake.FakeVirtAPI(), True) + self.assertPublicAPISignatures(baseinst, inst) diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 1a9bd9ecf580..c4e3b133811b 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -150,7 +150,7 @@ class FakeDriver(driver.ComputeDriver): fake_instance = FakeInstance(name, state, instance['uuid']) self.instances[name] = fake_instance - def snapshot(self, context, instance, name, update_task_state): + def snapshot(self, context, instance, image_id, update_task_state): if instance['name'] not in self.instances: raise exception.InstanceNotRunning(instance_id=instance['uuid']) update_task_state(task_state=task_states.IMAGE_UPLOADING) @@ -199,10 +199,11 @@ class FakeDriver(driver.ComputeDriver): block_device_info=None): pass - def power_off(self, instance, shutdown_timeout=0, shutdown_attempts=0): + def power_off(self, instance, timeout=0, retry_interval=0): pass - def power_on(self, context, instance, network_info, block_device_info): + def power_on(self, context, instance, network_info, + block_device_info=None): pass def soft_delete(self, instance): @@ -284,7 +285,7 @@ class FakeDriver(driver.ComputeDriver): num_cpu=2, cpu_time_ns=0) - def get_diagnostics(self, instance_name): + def get_diagnostics(self, instance): return {'cpu0_time': 17300000000, 'memory': 524288, 'vda_errors': -1, @@ -302,7 +303,7 @@ class FakeDriver(driver.ComputeDriver): 'vnet1_tx_packets': 662, } - def get_instance_diagnostics(self, instance_name): + def get_instance_diagnostics(self, instance): diags = diagnostics.Diagnostics(state='running', driver='fake', hypervisor_os='fake-os', uptime=46664, config_drive=True) diags.add_cpu(time=17300000000) @@ -341,7 +342,7 @@ class FakeDriver(driver.ComputeDriver): stats['frequency'] = 800 return stats - def block_stats(self, instance_name, disk_id): + def block_stats(self, instance, disk_id): return [0L, 0L, 0L, 0L, None] def get_console_output(self, context, instance): @@ -401,30 +402,30 @@ class FakeDriver(driver.ComputeDriver): host_status['cpu_info'] = '?' return host_status - def ensure_filtering_rules_for_instance(self, instance_ref, network_info): + def ensure_filtering_rules_for_instance(self, instance, network_info): return def get_instance_disk_info(self, instance, block_device_info=None): return - def live_migration(self, context, instance_ref, dest, + def live_migration(self, context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None): - post_method(context, instance_ref, dest, block_migration, + post_method(context, instance, dest, block_migration, migrate_data) return - def check_can_live_migrate_destination_cleanup(self, ctxt, + def check_can_live_migrate_destination_cleanup(self, context, dest_check_data): return - def check_can_live_migrate_destination(self, ctxt, instance_ref, + def check_can_live_migrate_destination(self, context, instance, src_compute_info, dst_compute_info, block_migration=False, disk_over_commit=False): return {} - def check_can_live_migrate_source(self, ctxt, instance_ref, + def check_can_live_migrate_source(self, context, instance, dest_check_data, block_device_info=None): return @@ -436,14 +437,14 @@ class FakeDriver(driver.ComputeDriver): def confirm_migration(self, migration, instance, network_info): return - def pre_live_migration(self, context, instance_ref, block_device_info, - network_info, disk, migrate_data=None): + def pre_live_migration(self, context, instance, block_device_info, + network_info, disk_info, migrate_data=None): return - def unfilter_instance(self, instance_ref, network_info): + def unfilter_instance(self, instance, network_info): return - def test_remove_vm(self, instance_name): + def _test_remove_vm(self, instance_name): """Removes the named VM, as if it crashed. For testing.""" self.instances.pop(instance_name)