nova/nova/tests
Jenkins cb380e8172 Merge "Move vbd plug/unplug into session object" 2014-03-05 08:45:03 +00:00
..
CA
api Merge "Adds get_console_connect_info API" 2014-03-03 20:21:44 +00:00
bundle
cells Add a new compute API method for deleting retired services 2014-02-21 16:50:23 -05:00
cert Remove vi modelines 2014-02-03 14:19:44 +00:00
compute Move all shelve code paths to BDM objects 2014-03-04 15:16:17 +01:00
conductor Deprecate conductor instance_type_get() and remove from VirtAPI 2014-02-28 16:43:46 -08:00
console Remove vi modelines 2014-02-03 14:19:44 +00:00
consoleauth Remove vi modelines 2014-02-03 14:19:44 +00:00
db Merge "Call get_pgsql_connection_info from _test_postgresql_opportunistically" 2014-02-28 15:34:14 +00:00
fake_loadables
glance Remove vi modelines 2014-02-03 14:19:44 +00:00
image Enable flake8 H404 checking 2014-02-27 11:15:55 +04:00
integrated Merge "Adds get_console_connect_info API" 2014-03-03 20:21:44 +00:00
keymgr Remove vi modelines 2014-02-03 14:19:44 +00:00
monkey_patch_example Remove vi modelines 2014-02-03 14:19:44 +00:00
network Merge "Remove and recreate interface if already exists" 2014-03-03 14:08:12 +00:00
objects Merge "Prevent caller from specifying id during Aggregate.create()" 2014-03-03 23:42:56 +00:00
pci Change assertTrue(isinstance()) by optimal assert 2014-02-12 16:19:08 +01:00
scheduler Add a caching scheduler driver 2014-02-26 13:53:07 +00:00
servicegroup Make sure report_interval is less than service_down_time 2013-11-27 13:06:15 +08:00
ssl_cert
virt Merge "Move vbd plug/unplug into session object" 2014-03-05 08:45:03 +00:00
volume Remove vi modelines 2014-02-03 14:19:44 +00:00
README.rst
__init__.py Remove vi modelines 2014-02-03 14:19:44 +00:00
cast_as_call.py Remove vi modelines 2014-02-03 14:19:44 +00:00
conf_fixture.py Merge "Set a sane default for state_path" 2014-02-12 22:04:35 +00:00
fake_block_device.py Add block device mapping objects implementation 2014-01-30 15:28:05 +01:00
fake_crypto.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_hosts.py Make compute_api use Service and ComputeNode objects 2013-08-29 00:18:46 -07:00
fake_instance.py Clean up _make_*_list in object models to use base.obj_make_list 2014-02-26 08:13:43 +08:00
fake_instance_actions.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_ldap.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_network.py Remove db query from deallocate_fixed_ip 2014-02-26 19:11:14 +00:00
fake_network_cache_model.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_notifier.py Serialize the notification payload in json 2014-02-20 11:42:40 +01:00
fake_policy.py Merge "Adds get_console_connect_info API" 2014-03-03 20:21:44 +00:00
fake_processutils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_utils.py Call scheduler for run_instance from conductor 2013-06-04 13:42:04 -04:00
fake_volume.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fakeguestfs.py Merge "Test guestfs without support for close_on_exit" 2014-02-10 19:20:15 +00:00
matchers.py Enable flake8 H404 checking 2014-02-27 11:15:55 +04:00
policy_fixture.py Adds unit test for etc/nova/policy.json data 2014-02-28 07:24:32 +01:00
test_api_validation.py Define common "name" parameter for Nova v3 API 2014-02-05 19:43:07 +09:00
test_availability_zones.py Change assertTrue(isinstance()) by optimal assert 2014-02-12 16:19:08 +01:00
test_baserpc.py
test_bdm.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_block_device.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_cinder.py Use six.moves.urllib.parse instead of urlparse 2014-02-12 18:32:05 +08:00
test_configdrive2.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_context.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_crypto.py
test_exception.py Merge "Sync latest gettextutils from oslo-incubator" 2014-02-10 11:56:23 +00:00
test_flavors.py Merge "Fix upper bound checking for flavor create parameters" 2014-03-03 15:00:36 +00:00
test_hacking.py Replace assertEqual(None, *) with assertIsNone in tests 2014-02-16 17:31:28 +08:00
test_hooks.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_instance_types_extra_specs.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_iptables_network.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_ipv6.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_linuxscsi.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_loadables.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_matchers.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_metadata.py Merge "Refactoring metadata/base" 2014-02-28 09:07:46 +00:00
test_notifications.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_nova_manage.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_objectstore.py Add HEAD api response for test s3 server BucketHandler 2014-02-09 01:16:33 +08:00
test_pipelib.py
test_policy.py Adds unit test for etc/nova/policy.json data 2014-02-28 07:24:32 +01:00
test_quota.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_safeutils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_service.py Merge "Make sure report_interval is less than service_down_time" 2014-02-06 12:59:44 +00:00
test_test.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_test_utils.py Merge "Fix potential fd leak" 2014-02-10 09:18:32 +00:00
test_utils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_versions.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_weights.py Normalize the weights instead of using raw values 2013-12-11 20:24:16 +01:00
test_wsgi.py Allow operators to customize max header size 2014-02-10 09:18:11 +00:00
utils.py Merge "Fix potential fd leak" 2014-02-10 09:18:32 +00:00

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)

Stubbing and Mocking

Whenever possible, tests SHOULD NOT stub and mock out the same function.

If it's unavoidable, tests SHOULD define stubs before mocks since the TestCase cleanup routine will un-mock before un-stubbing. Doing otherwise results in a test that leaks stubbed functions, causing hard-to-debug interference between tests1.

If a mock must take place before a stub, any stubs after the mock call MUST be manually unset using self.cleanUp calls within the test.


  1. https://bugs.launchpad.net/nova/+bug/1180671↩︎