The nova.tests.compute.test_compute Module

Tests for compute service

class BaseTestCase(methodName='runTest')

Bases: nova.test.TestCase

setUp()
tearDown()
class ComputeAPIAggrTestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

This is for unit coverage of aggregate-related methods defined in nova.compute.api.

setUp()
test_add_host_to_aggregate()

Ensure we can add a host to an aggregate.

test_add_host_to_aggregate_multiple()

Ensure we can add multiple hosts to an aggregate.

test_add_host_to_aggregate_raise_not_found()

Ensure ComputeHostNotFound is raised when adding invalid host.

test_add_host_to_aggregate_zones_mismatch()

Ensure InvalidAggregateAction is raised when zones don’t match.

test_create_invalid_availability_zone()

Ensure InvalidAggregateAction is raised with wrong avail_zone.

test_delete_aggregate()

Ensure we can delete an aggregate.

test_delete_non_empty_aggregate()

Ensure InvalidAggregateAction is raised when non empty aggregate.

test_remove_host_from_aggregate_active()

Ensure we can remove a host from an aggregate.

test_remove_host_from_aggregate_raise_not_found()

Ensure ComputeHostNotFound is raised when removing invalid host.

test_update_aggregate_metadata()

Ensure metadata can be updated

class ComputeAPITestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

setUp()
test_add_remove_fixed_ip()
test_add_remove_security_group()
test_attach_volume()

Ensure instance can be soft rebooted

test_attach_volume_invalid()
test_attach_volume_no_device()
test_backup()

Can’t backup an instance which is already being backed up.

test_backup_conflict()

Can’t backup an instance which is already being backed up.

test_console_output()
test_create_instance_associates_security_groups()

Make sure create associates security groups

test_create_instance_defaults_display_name()

Verify that an instance cannot be created without a display_name.

test_create_instance_sets_system_metadata()

Make sure image properties are copied into system metadata.

test_create_instance_with_invalid_security_group_raises()
test_create_just_enough_ram_and_disk()

Test an instance type with just enough ram and disk space

test_create_with_base64_user_data()

Test an instance type with ok much user data.

test_create_with_large_user_data()

Test an instance type with too much user data.

test_create_with_malformed_user_data()

Test an instance type with malformed user data.

test_create_with_no_ram_and_disk_reqs()

Test an instance type with no min_ram or min_disk

test_create_with_too_little_disk()

Test an instance type with too little disk space

test_create_with_too_little_ram()

Test an instance type with too little memory

test_default_hostname_generator()
test_delete()
test_delete_fail()
test_delete_fast_if_host_not_set()
test_delete_handles_host_setting_race_condition()
test_delete_in_resized()
test_delete_soft()
test_delete_soft_fail()
test_delete_with_down_host()
test_destroy_instance_disassociates_security_groups()

Make sure destroying disassociates security groups

test_destroy_security_group_disassociates_instances()

Make sure destroying security groups disassociates instances

test_force_delete()

Ensure instance can be deleted after a soft delete

test_get()

Test get instance

test_get_all_by_flavor()

Test searching instances by image

test_get_all_by_image()

Test searching instances by image

test_get_all_by_metadata()

Test searching instances by metadata

test_get_all_by_multiple_options_at_once()

Test searching by multiple options at once

test_get_all_by_name_regexp()

Test searching instances by name (display_name)

test_get_all_by_state()

Test searching instances by state

test_get_diagnostics()
test_get_instance_faults()

Get an instances latest fault

test_get_lock()
test_get_vnc_console_no_host()
test_get_with_integer_id()

Test get instance with an integer id

test_hard_reboot_of_soft_rebooting_instance()

Ensure instance can be hard rebooted while soft rebooting

test_hostname_create()

Ensure instance hostname is set during creation.

test_inject_file()

Ensure we can write a file to an instance

test_inject_network_info()
test_instance_architecture()

Test the instance architecture

test_instance_metadata()
test_instance_name_template()

Test the instance_name template

test_instance_unknown_architecture()

Test if the architecture is unknown.

test_live_migrate()
test_lock()
test_migrate()
test_pause()

Ensure instance can be paused

test_reboot_hard()

Ensure instance can be hard rebooted

test_reboot_soft()

Ensure instance can be soft rebooted

test_rebuild()
test_repeated_delete_quota()
test_rescue_unrescue()
test_reservation_id_one_instance()

Verify building an instance has a reservation_id that matches return value from create

test_reservation_ids_two_instances()

Verify building 2 instances at once results in a reservation_id being returned equal to reservation id set in both instances

test_reset_network()
test_resize_confirm_through_api()
test_resize_invalid_flavor_fails()

Ensure invalid flavors raise

test_resize_request_spec()
test_resize_request_spec_noavoid()
test_resize_revert_through_api()
test_resize_same_flavor_fails()

Ensure invalid flavors raise

test_restore()

Ensure instance can be restored from a soft delete

test_resume()

Ensure instance can be resumed (if suspended)

test_secgroup_refresh()
test_secgroup_refresh_none()
test_secgroup_refresh_once()
test_secrule_refresh()
test_secrule_refresh_none()
test_secrule_refresh_once()
test_set_admin_password()

Ensure instance can have its admin password set

test_snapshot()

Ensure a snapshot of an instance can be created

test_snapshot_conflict()

Can’t snapshot an instance which is already being snapshotted.

test_snapshot_minram_mindisk()

Ensure a snapshots min_ram and min_disk are correct.

A snapshot of an instance should have min_ram and min_disk set to that of the instances original image unless that image had a disk format of vhd.

test_snapshot_minram_mindisk_VHD()

Ensure a snapshots min_ram and min_disk are correct.

A snapshot of a non-shrinkable VHD should have min_ram and min_disk set to that of the original instances flavor.

test_snapshot_minram_mindisk_img_missing_minram()

Ensure a snapshots min_ram and min_disk are correct.

Do not show an attribute that the orig img did not have.

test_snapshot_minram_mindisk_no_image()

Ensure a snapshots min_ram and min_disk are correct.

A snapshots min_ram and min_disk should be set to default if an instances original image cannot be found.

test_soft_reboot_of_rebooting_instance()

Ensure instance can’t be soft rebooted while rebooting

test_start()
test_start_shutdown()
test_stop()
test_suspend()

Ensure instance can be suspended

test_unlock()
test_unpause()

Ensure instance can be unpaused

test_update_block_device_mapping()
test_vnc_console()

Make sure we can a vnc console for an instance.

test_volume_size()
class ComputeAggrTestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

This is for unit coverage of aggregate-related methods defined in nova.compute.manager.

setUp()
test_add_aggregate_host()
test_add_aggregate_host_passes_slave_info_to_driver()
test_remove_aggregate_host()
test_remove_from_aggregate_passes_slave_info_to_driver()
class ComputeHostAPITestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

setUp()
test_get_host_uptime()
test_host_power_action()
test_set_host_enabled()
test_set_host_maintenance()
class ComputePolicyTestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

setUp()
tearDown()
test_actions_are_prefixed()
test_create_attach_network_fail()
test_create_attach_volume_fail()
test_create_fail()
test_get_all_fail()
test_get_fail()
test_get_instance_faults()
test_wrapped_method()
class ComputeReschedulingExceptionTestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

Tests for re-scheduling exception handling logic

setUp()
test_exception_context_cleared()

Test with no rescheduling and an additional exception occurs clearing the original build error’s exception context.

test_exception_with_rescheduling_disabled()

Spawn fails and re-scheduling is disabled.

test_exception_with_rescheduling_enabled()

Spawn fails and re-scheduling is enabled. Original exception should not be re-raised.

class ComputeReschedulingTestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

Tests related to re-scheduling build requests

setUp()
test_reschedule_no_filter_properties()

no filter_properties will disable re-scheduling

test_reschedule_no_request_spec()

no request spec will also disable re-scheduling

test_reschedule_no_retry_info()

no retry info will also disable re-scheduling

test_reschedule_success()
class ComputeTestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

setUp()
tearDown()
test_add_fixed_ip_usage_notification()
test_add_instance_fault()
test_add_instance_fault_no_exc_info()
test_add_instance_fault_user_error()
test_can_terminate_on_error_state()

Make sure that the instance can be terminated in ERROR state

test_check_can_live_migrate_destination_fails_dest_check()

Confirm check_can_live_migrate_destination works on positive path

test_check_can_live_migrate_destination_fails_source()

Confirm check_can_live_migrate_destination works on positive path

test_check_can_live_migrate_destination_works_correctly()

Confirm check_can_live_migrate_destination works on positive path

test_check_can_live_migrate_source_works_correctly()

Confirm check_can_live_migrate_source works on positive path

test_cleanup_running_deleted_instances()
test_console_output()

Make sure we can get console output from instance

test_console_output_tail()

Make sure we can get console output from instance

test_create_instance_associates_config_drive()

Make sure create associates a config drive.

test_create_instance_unlimited_disk()
test_create_instance_unlimited_memory()

Default of memory limit=None is unlimited

test_create_instance_with_img_ref_associates_config_drive()

Make sure create associates a config drive.

test_create_instance_with_oversubscribed_cpu()

Test passing of oversubscribed cpu policy from the scheduler.

test_create_instance_with_oversubscribed_disk()

Test passing of oversubscribed disk policy from the scheduler.

test_create_instance_with_oversubscribed_disk_fail()

Test passing of oversubscribed disk policy from the scheduler, but with insufficient disk.

test_create_instance_with_oversubscribed_ram()

Test passing of oversubscribed ram policy from the scheduler.

test_create_instance_with_oversubscribed_ram_fail()

Test passing of oversubscribed ram policy from the scheduler, but with insufficient memory.

test_create_multiple_instances_then_starve()
test_default_access_ip()
test_delete_instance_succedes_on_volume_fail()
test_diagnostics()

Make sure we can get diagnostics for an instance.

test_fail_to_schedule_persists()

check the persistence of the ERROR(scheduling) state

test_finish_resize()

Contrived test to ensure finish_resize doesn’t raise anything

test_finish_resize_handles_error()

Make sure we don’t leave the instance in RESIZE on error

test_finish_resize_instance_notification()

Ensure notifications on instance migrate/resize

test_finish_revert_resize()

Ensure that the flavor is reverted to the original on revert

test_get_by_flavor_id()
test_heal_instance_info_cache()
test_inject_file()

Ensure we can write a file to an instance

test_inject_network_info()

Ensure we can inject network info

test_instance_build_timeout()
test_instance_build_timeout_disabled()
test_instance_build_timeout_mixed_instances()
test_instance_set_to_error_on_uncaught_exception()

Test that instance is set to error state when exception is raised

test_instance_termination_exception_sets_error()

Test that we handle InstanceTerminationFailure which is propagated up from the underlying driver.

test_invalid_vnc_console_type()

Raise useful error if console type is an unrecognised string

test_live_migration_dest_raises_exception()

Confirm exception when pre_live_migration fails.

test_live_migration_works_correctly()

Confirm live_migration() works as expected correctly.

test_lock()

ensure locked instance cannot be changed

test_missing_vnc_console_type()

Raise useful error is console type is None

test_network_is_deallocated_on_spawn_failure()

When a spawn fails the network must be deallocated

test_no_default_access_ip()
test_novnc_vnc_console()

Make sure we can a vnc console for an instance.

test_pause()

Ensure instance can be paused and unpaused

test_poll_unconfirmed_resizes()
test_post_live_migration_working_correctly()

Confirm post_live_migration() works as expected correctly.

test_power_off()

Ensure instance can be powered off

test_power_on()

Ensure instance can be powered on

test_pre_live_migration_instance_has_no_fixed_ip()

Confirm raising exception if instance doesn’t have fixed_ip.

test_pre_live_migration_works_correctly()

Confirm setup_compute_volume is called when volume is mounted.

test_prep_resize_instance_migration_error_on_none_host()

Ensure prep_resize raise a migration error if destination host is not defined

test_prep_resize_instance_migration_error_on_same_host()

Ensure prep_resize raise a migration error if destination is set on the same source host and allow_resize_to_same_host is false

test_reboot_hard()

Ensure instance can be hard rebooted

test_reboot_soft()

Ensure instance can be soft rebooted

test_rebuild()

Ensure instance can be rebuilt

test_rebuild_instance_notification()

Ensure notifications on instance migrate/resize

test_rebuild_launch_time()

Ensure instance can be rebuilt

test_remove_fixed_ip_usage_notification()
test_rescue()

Ensure instance can be rescued and unrescued

test_reset_network()

Ensure we can reset networking on an instance

test_resize_instance()

Ensure instance can be migrated/resized

test_resize_instance_driver_error()

Ensure instance status set to Error on resize error

test_resize_instance_handles_migration_error()

Ensure vm_state is ERROR when error occurs

test_resize_instance_notification()

Ensure notifications on instance migrate/resize

test_resize_same_source_fails()

Ensure instance fails to migrate when source and destination are the same host

test_run_instance_dealloc_network_instance_not_found()

spawn network deallocate test.

Make sure that when an instance is not found during spawn that the network is deallocated

test_run_instance_existing()

Ensure failure when running an instance that already exists

test_run_instance_setup_block_device_mapping_fail()

block device mapping failure test.

Make sure that when there is a block device mapping problem, the instance goes to ERROR state, keeping the task state

test_run_instance_spawn_fail()

spawn failure test.

Make sure that when there is a spawning problem, the instance goes to ERROR state, keeping the task state

test_run_instance_usage_notification()

Ensure run instance generates appropriate usage notification

test_run_kill_vm()

Detect when a vm is terminated behind the scenes

test_run_terminate()

Make sure it is possible to run and terminate instance

test_run_terminate_timestamps()

Make sure timestamps are set for launched and destroyed

test_run_terminate_with_vol_attached()

Make sure it is possible to run and terminate instance with volume attached

test_running_deleted_instances()
test_set_admin_password()

Ensure instance can have its admin password set

test_set_admin_password_bad_state()

Test setting password while instance is rebuilding.

test_set_admin_password_driver_not_authorized()

Ensure expected exception is raised if set_admin_password not authorized.

test_set_admin_password_driver_not_implemented()

Ensure expected exception is raised if set_admin_password not implemented by driver.

test_snapshot()

Ensure instance can be snapshotted

test_snapshot_fails()

Ensure task_state is set to None if snapshot fails

test_start()

Ensure instance can be started

test_state_revert()

ensure that task_state is reverted after a failed operation

test_stop()

Ensure instance can be stopped

test_suspend()

ensure instance can be suspended and resumed

test_suspend_error()

Ensure vm_state is ERROR when suspend error occurs

test_terminate_failure_leaves_task_state()

Ensure that a failure in terminate_instance does not result in the task state being reverted from DELETING (see LP 1046236).

test_terminate_no_network()
test_terminate_usage_notification()

Ensure terminate_instance generates correct usage notification

test_wrap_instance_fault()
test_wrap_instance_fault_no_instance()
test_xvpvnc_vnc_console()

Make sure we can a vnc console for an instance.

class DisabledInstanceTypesTestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

Some instance-types are marked ‘disabled’ which means that they will not show up in customer-facing listings. We do, however, want those instance-types to be availble for emergency migrations and for rebuilding of existing instances.

One legitimate use of the ‘disabled’ field would be when phasing out a particular instance-type. We still want customers to be able to use an instance that of the old type, and we want Ops to be able perform migrations against it, but we don’t want customers building new slices with ths phased-out instance-type.

setUp()
test_can_build_instance_from_visible_instance_type()
test_can_migrate_to_disabled_instance_type()

We don’t want to require a customers instance-type to change when ops is migrating a failed server.

test_can_migrate_to_visible_instance_type()
test_can_rebuild_instance_from_disabled_instance_type()

A rebuild or a restore should only change the ‘image’, not the ‘instance_type’. Therefore, should be allowed even when the slice is on disabled type already.

test_can_rebuild_instance_from_visible_instance_type()
test_can_resize_to_visible_instance_type()
test_cannot_build_instance_from_disabled_instance_type()
test_cannot_resize_to_disabled_instance_type()
class FakeSchedulerAPI

Bases: object

live_migration(ctxt, block_migration, disk_over_commit, instance, dest)
run_instance(ctxt, request_spec, admin_password, injected_files, requested_networks, is_first_time, filter_properties)
class KeypairAPITestCase(methodName='runTest')

Bases: nova.tests.compute.test_compute.BaseTestCase

setUp()
test_create_keypair()
test_create_keypair_already_exists()
test_create_keypair_invalid_chars()
test_create_keypair_name_too_long()
test_create_keypair_quota_limit()
test_get_keypair()
test_import_keypair()
test_import_keypair_bad_public_key()
test_import_keypair_invalid_chars()
test_import_keypair_name_too_long()
test_import_keypair_quota_limit()
exception ThatsNoOrdinaryRabbitException

Bases: exceptions.Exception

fake_rpc_method(context, topic, msg, do_cast=True)
nop_report_driver_status(self)

Previous topic

The nova.tests.compute.fake_resource_tracker Module

Next topic

The nova.tests.compute.test_compute_utils Module

This Page