nova/nova/tests
Jenkins 2a5fd1257a Merge "VMware: spawn refactor - phase 1 - fetch_image" 2014-05-18 12:24:36 +00:00
..
CA
api Merge "Raise more information on V2 API volumes when resource not found" 2014-05-17 22:53:32 +00:00
bundle
cells Make cells use Fault obj for create 2014-05-02 12:17:16 -07:00
cert Remove vi modelines 2014-02-03 14:19:44 +00:00
compute Merge "Add UNSHELVING and RESCUING into IoOPSFilter consideration state" 2014-05-17 23:12:06 +00:00
conductor Deprecate action_event_*() from conductor 2014-05-08 15:19:00 +02: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 Remove quota_class db API calls 2014-05-16 07:54:55 -07:00
fake_loadables
glance Add deleted_at attribute in glance stub on delete() 2014-03-19 02:18:24 +00:00
image Fix calls to mock.assert_not_called() 2014-05-04 19:05:44 -07:00
integrated Add specific regexp for timestamps in v2 xml 2014-05-11 16:28:50 -04:00
keymgr Rename NotAuthorized exception to Forbidden 2014-04-25 12:37:07 -07:00
monkey_patch_example Remove vi modelines 2014-02-03 14:19:44 +00:00
network Merge "Add lock on API layer delete floating IP" 2014-05-13 06:52:18 +00:00
objects Convert address to str in fixed_ip_obj.associate 2014-05-14 13:29:42 -04:00
pci Remove PciDeviceList usage in pci manager 2014-03-20 14:14:58 -07:00
scheduler Merge "Add UNSHELVING and RESCUING into IoOPSFilter consideration state" 2014-05-17 23:12:06 +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 "VMware: spawn refactor - phase 1 - fetch_image" 2014-05-18 12:24:36 +00:00
volume Merge "Fix instance cross AZ check when attaching volumes" 2014-05-17 23:12:32 +00:00
README.rst Fixed many typos. 2014-04-25 21:47:41 -07: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 Set default auth_strategy to keystone 2014-04-23 17:36:13 -07: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
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_ldap.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_network.py Remove unused method from fake_network.py 2014-03-18 16:17:21 -07:00
fake_network_cache_model.py Correct network_model tests and __eq__ operator 2014-03-06 16:52:40 -08:00
fake_notifier.py Serialize the notification payload in json 2014-02-20 11:42:40 +01:00
fake_policy.py Rename instance_actions v3 to server_actions 2014-04-01 14:59:31 +02:00
fake_processutils.py Don't translate debug level logs in nova.spice, storage, tests and vnc 2014-05-01 03:57:19 -07:00
fake_server_actions.py Remove conductor usage from compute.utils.EventReporter 2014-05-08 15:18:53 +02:00
fake_utils.py
fake_volume.py ec2: use BlockDeviceMappingList object 2014-04-14 15:13:02 +00:00
fakeguestfs.py Check image exists before calling inject_data 2014-04-08 20:23:49 +03: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 Fix BDM legacy usage with objects 2014-03-06 13:17:27 -08: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 Sync the latest DB code from oslo-incubator 2014-03-03 16:45:22 -05:00
test_hacking.py Fix wrong method name for test_hacking 2014-05-12 17:41:21 +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
test_matchers.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_metadata.py Remove metadata's network-api dependence on the database 2014-04-21 06:32:57 -07:00
test_notifications.py Fixed many typos. 2014-04-25 21:47:41 -07:00
test_nova_manage.py Remove utils.reset_is_neutron() to avoid races 2014-04-17 23:09:32 +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 quota_class params from rest of nova.quota 2014-05-16 07:54:29 -07:00
test_safeutils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_service.py Wait till message handling is done on service stop 2014-03-21 12:18:10 +01:00
test_test.py Use debug level logging in unit tests, but don't save them. 2014-04-09 17:10:10 -07:00
test_test_utils.py Merge "Fix potential fd leak" 2014-02-10 09:18:32 +00:00
test_utils.py Remove utils.reset_is_neutron() to avoid races 2014-04-17 23:09:32 +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 Add x-openstack-request-id to nova v3 responses 2014-04-28 21:03:38 +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 overridden.

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↩︎