3e451f1bac
Currently for undefined os-types it will use the default mkfs command, but use the meta 'os_type' in the name of the ephemeral file (e.g. ephemeral_20_abcdef). Which can result in a lot of files (DoS?) This change will only use 'os_type' in the ephemeral filename if there is a specific mkfs command defined, otherwise it will use 'default' (e.g. ephemeral_20_default) Modifed the tests to test for: os_type='' os_type=None os_type='test' - with no mkfs command specified os_type='test' - with a mkfs command specified Closes-Bug: 1253980 Backport of Original Change-Id: Ie4c10f99ce690c5e4ef181624bd688c38923855c to stable/grizzly Change-Id: Ia040910e90861a2987eff345ad1c01863655b124 |
||
---|---|---|
.. | ||
CA | ||
api | ||
baremetal | ||
bundle | ||
cells | ||
cert | ||
compute | ||
conductor | ||
console | ||
consoleauth | ||
db | ||
fake_loadables | ||
glance | ||
hyperv | ||
image | ||
integrated | ||
monkey_patch_example | ||
network | ||
scheduler | ||
servicegroup | ||
ssl_cert | ||
virt | ||
vmwareapi | ||
volume | ||
xenapi | ||
README.rst | ||
__init__.py | ||
conf_fixture.py | ||
fake_crypto.py | ||
fake_hosts.py | ||
fake_imagebackend.py | ||
fake_instance_actions.py | ||
fake_ldap.py | ||
fake_libvirt_utils.py | ||
fake_network.py | ||
fake_network_cache_model.py | ||
fake_policy.py | ||
fake_utils.py | ||
fake_volume.py | ||
fakeguestfs.py | ||
fakelibvirt.py | ||
matchers.py | ||
policy_fixture.py | ||
test_api.py | ||
test_availability_zones.py | ||
test_baremetal_migrations.conf | ||
test_bdm.py | ||
test_block_device.py | ||
test_cinder.py | ||
test_configdrive2.py | ||
test_context.py | ||
test_crypto.py | ||
test_db_api.py | ||
test_driver.py | ||
test_exception.py | ||
test_fakelibvirt.py | ||
test_filters.py | ||
test_hooks.py | ||
test_hypervapi.py | ||
test_image_utils.py | ||
test_imagebackend.py | ||
test_imagecache.py | ||
test_instance_types.py | ||
test_instance_types_extra_specs.py | ||
test_iptables_network.py | ||
test_ipv6.py | ||
test_libvirt.py | ||
test_libvirt_blockinfo.py | ||
test_libvirt_config.py | ||
test_libvirt_utils.py | ||
test_libvirt_vif.py | ||
test_libvirt_volume.py | ||
test_linuxscsi.py | ||
test_loadables.py | ||
test_matchers.py | ||
test_metadata.py | ||
test_migration_utils.py | ||
test_migrations.conf | ||
test_migrations.py | ||
test_misc.py | ||
test_notifications.py | ||
test_nova_manage.py | ||
test_objectstore.py | ||
test_periodic_tasks.py | ||
test_pipelib.py | ||
test_plugin_api_extensions.py | ||
test_policy.py | ||
test_powervm.py | ||
test_quota.py | ||
test_safeutils.py | ||
test_service.py | ||
test_test.py | ||
test_test_utils.py | ||
test_utils.py | ||
test_versions.py | ||
test_virt.py | ||
test_virt_disk.py | ||
test_virt_disk_vfs_guestfs.py | ||
test_virt_disk_vfs_localfs.py | ||
test_virt_drivers.py | ||
test_vmmode.py | ||
test_vmwareapi.py | ||
test_vmwareapi_vif.py | ||
test_vmwareapi_vm_util.py | ||
test_vmwareapi_vmops.py | ||
test_wsgi.py | ||
test_xenapi.py | ||
utils.py |
README.rst
OpenStack Nova Testing Infrastructure
This README file attempts to provide current and prospective contributors with everything they need to know in order to start creating unit tests for nova.
Note: the content for the rest of this file will be added as the work items in the following blueprint are completed: https://blueprints.launchpad.net/nova/+spec/consolidate-testing-infrastructure
Test Types: Unit vs. Functional vs. Integration
TBD
Writing Unit Tests
TBD
Using Fakes
TBD
test.TestCase
The TestCase class from nova.test (generally imported as test) will automatically manage self.stubs using the stubout module and self.mox using the mox module during the setUp step. They will automatically verify and clean up during the tearDown step.
If using test.TestCase, calling the super class setUp is required and calling the super class tearDown is required to be last if tearDown is overriden.
Writing Functional Tests
TBD
Writing Integration Tests
TBD
Tests and Exceptions
A properly written test asserts that particular behavior occurs. This can be a success condition or a failure condition, including an exception. When asserting that a particular exception is raised, the most specific exception possible should be used.
In particular, testing for Exception being raised is almost always a mistake since it will match (almost) every exception, even those unrelated to the exception intended to be tested.
This applies to catching exceptions manually with a try/except block, or using assertRaises().
Example:
self.assertRaises(exception.InstanceNotFound, db.instance_get_by_uuid,
elevated, instance_uuid)
If a stubbed function/method needs a generic exception for testing purposes, test.TestingException is available.
Example:
def stubbed_method(self):
raise test.TestingException()
self.stubs.Set(cls, 'inner_method', stubbed_method)
obj = cls()
self.assertRaises(test.TestingException, obj.outer_method)