nova/nova/tests
Jenkins 43a00e4c04 Merge "Make nova_ipam_lib use Network, FixedIP, and FloatingIP objects" 2014-02-14 21:19:54 +00:00
..
CA
api Merge "Adds migrate server extension for V3 API" 2014-02-13 01:12:40 +00:00
bundle
cells Remove vi modelines 2014-02-03 14:19:44 +00:00
cert Remove vi modelines 2014-02-03 14:19:44 +00:00
compute Convert unrescue_instance to objects 2014-02-14 01:19:31 +11:00
conductor Refactor stats to avoid bad join 2014-02-11 14:11:26 -06: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 Change assertTrue(isinstance()) by optimal assert 2014-02-12 16:19:08 +01:00
fake_loadables Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
glance Remove vi modelines 2014-02-03 14:19:44 +00:00
image Remove @author from copyright statements. 2014-02-12 05:17:10 +11:00
integrated Merge "Adds migrate server extension for V3 API" 2014-02-13 01:12:40 +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 Make nova_ipam_lib use Network, FixedIP, and FloatingIP objects 2014-02-12 06:34:42 -08:00
objects Refactor stats to avoid bad join 2014-02-11 14:11:26 -06:00
pci Change assertTrue(isinstance()) by optimal assert 2014-02-12 16:19:08 +01:00
scheduler Merge "Don't allow compute_node free_disk_gb to be None" 2014-02-13 17:31:22 +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 "Change assertTrue(isinstance()) by optimal assert" 2014-02-13 11:11:04 +00:00
volume Remove vi modelines 2014-02-03 14:19:44 +00:00
README.rst Mox should cleanup before stubs 2013-05-16 18:15:31 +00:00
__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 Update Instance from database after destroy 2013-12-04 13:01:46 -05: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 Merge "Make nova-network use FixedIP object for vif queries and bulk create" 2014-02-11 16:00:16 +00:00
fake_network_cache_model.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_notifier.py Add serializer capability to fake_notifier. 2014-02-04 13:45:29 -06:00
fake_policy.py Merge "Adds migrate server extension for V3 API" 2014-02-13 01:12:40 +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 Remove vi modelines 2014-02-03 14:19:44 +00:00
policy_fixture.py Use oslo-config-2013.1b4 2013-02-19 21:16:32 -08: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 Move get_backdoor_port to base rpc API. 2013-04-24 15:02:56 -04:00
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 Remove vi modelines 2014-02-03 14:19:44 +00: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 Convert to using oslo's execute() method. 2013-05-04 15:17:40 +10:00
test_exception.py Merge "Sync latest gettextutils from oslo-incubator" 2014-02-10 11:56:23 +00:00
test_flavors.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_hacking.py Change assertTrue(isinstance()) by optimal assert 2014-02-12 16:19:08 +01: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 Remove vi modelines 2014-02-03 14:19:44 +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 Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
test_policy.py Remove vi modelines 2014-02-03 14:19:44 +00: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↩︎