nova/nova/tests
Joe Gordon efe1957237 Fix and gate on E125
E125 continuation line does not distinguish itself from next logical
line.

E125 makes code more readable, and fixing all the existing issues allows
us to gate on this, making this one less thing reviewers have to check
for.

Fix was made using https://github.com/hhatto/autopep8

Change-Id: Ie569fd74fb84d220ceb87e37b1b1f39143bba80f
2013-07-04 08:49:45 +02:00
..
CA
api Fix and gate on E125 2013-07-04 08:49:45 +02:00
bundle
cells Merge "Add object (de)serialization support to cells" 2013-07-04 02:27:16 +00:00
cert Move get_backdoor_port to base rpc API. 2013-04-24 15:02:56 -04:00
compute Fix and gate on E125 2013-07-04 08:49:45 +02:00
conductor update xen/vmware virt drivers not to hit db directly 2013-07-02 21:03:36 +00:00
console Remove unused launch_time from instance 2013-05-31 20:21:17 +00:00
consoleauth Merge "Move get_backdoor_port to base rpc API." 2013-04-25 18:54:05 +00:00
db Make instance_update() string-convert IP addresses 2013-07-03 12:05:47 -07:00
fake_loadables Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
glance delete deleted image 500 bug 2013-03-05 09:03:32 -06:00
image Use Python 3.x compatible octal literals 2013-06-12 22:12:22 +02:00
integrated Fix and gate on E125 2013-07-04 08:49:45 +02:00
monkey_patch_example Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
network Fix and gate on E125 2013-07-04 08:49:45 +02:00
objects Add fill_faults() batch operation to InstanceList 2013-07-03 15:55:30 -07:00
scheduler Refactors select_destinations to return HostState objects 2013-07-03 14:54:34 -03:00
servicegroup Remove trivial cases of unused variables (3) 2013-06-27 17:34:17 +00:00
ssl_cert Adds SSL support for API server. 2013-01-23 08:49:16 -05:00
virt Fix and gate on E125 2013-07-04 08:49:45 +02:00
volume Refactor nova.volume.cinder.API to reduce roundtrips with Cinder 2013-05-14 09:55:23 +01:00
README.rst Mox should cleanup before stubs 2013-05-16 18:15:31 +00:00
__init__.py Fix and gate on E125 2013-07-04 08:49:45 +02:00
conf_fixture.py Make nova.virt.fake.FakeDriver useable in integration testing 2013-03-21 19:11:43 +00:00
fake_crypto.py
fake_hosts.py Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
fake_instance.py Add deleted flag to NovaObject base 2013-06-07 11:37:38 -07:00
fake_instance_actions.py Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
fake_ldap.py Fix and enable H403 tests 2013-06-12 22:07:23 +02:00
fake_network.py Make fake_network tolerant of objects 2013-06-26 08:03:14 -07:00
fake_network_cache_model.py Update instance network info cache to include vif_type. 2013-03-21 22:27:28 +08:00
fake_policy.py Merge "Port hypervisor API into v3 part2" 2013-07-03 07:51:17 +00:00
fake_processutils.py Convert to using newly imported processutils. 2013-05-08 05:55:27 +10:00
fake_utils.py Call scheduler for run_instance from conductor 2013-06-04 13:42:04 -04:00
fake_volume.py Merge "Refactor nova.volume.cinder.API to reduce roundtrips with Cinder" 2013-05-15 19:50:20 +00:00
fakeguestfs.py Use Python 3.x compatible octal literals 2013-06-12 22:12:22 +02:00
matchers.py Fix and gate on E125 2013-07-04 08:49:45 +02:00
policy_fixture.py Use oslo-config-2013.1b4 2013-02-19 21:16:32 -08:00
test_availability_zones.py Remove trivial cases of unused variables (3) 2013-06-27 17:34:17 +00:00
test_baserpc.py Move get_backdoor_port to base rpc API. 2013-04-24 15:02:56 -04:00
test_bdm.py Removed print stmts in test cases 2013-01-29 12:55:14 -05:00
test_block_device.py BDM class and transformation functions 2013-06-08 10:35:32 +02:00
test_cinder.py Remove trivial cases of unused variables (3) 2013-06-27 17:34:17 +00:00
test_configdrive2.py Replace functions in utils with oslo.fileutils 2013-06-11 13:28:29 +09:00
test_context.py Fix RequestContext crashes w/ no service catalog 2013-03-18 18:06:52 -04:00
test_crypto.py Convert to using oslo's execute() method. 2013-05-04 15:17:40 +10:00
test_exception.py Moving `test_misc` tests to better locations 2013-06-05 21:19:13 +00:00
test_flavors.py Remove trivial cases of unused variables (3) 2013-06-27 17:34:17 +00:00
test_hooks.py Added functionality for nova hooks pass functions 2013-07-02 12:56:45 -05:00
test_instance_types_extra_specs.py Remove restoring soft deleted entries part 1 2013-01-18 21:31:03 +04:00
test_iptables_network.py clear up method parameters for _modify_rules 2013-03-08 09:32:31 +01:00
test_ipv6.py Remove unnecessary LOG initialisation 2013-04-10 13:26:12 +00:00
test_linuxscsi.py Fix dangling LUN issue under load with multipath 2013-06-10 14:10:03 -07:00
test_loadables.py Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
test_manager.py Make it easier to add namespaced rpc APIs. 2013-05-21 18:09:01 -04:00
test_matchers.py
test_metadata.py Fix and gate on E125 2013-07-04 08:49:45 +02:00
test_notifications.py Add old display name to update notification 2013-06-17 09:03:31 +08:00
test_nova_manage.py Allow listing fixed_ips for a given compute host. 2013-04-15 03:39:44 +10:00
test_objectstore.py Use oslo-config-2013.1b4 2013-02-19 21:16:32 -08:00
test_pipelib.py Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
test_policy.py
test_quota.py Fix and gate on E125 2013-07-04 08:49:45 +02:00
test_safeutils.py Remove parameters containing passwords from Notifications. 2013-03-05 16:27:29 -04:00
test_service.py Skip ipv6 tests on system without ipv6 support 2013-06-07 00:16:27 +08:00
test_test.py Use oslo-config-2013.1b4 2013-02-19 21:16:32 -08:00
test_test_utils.py Update OpenStack LLC to Foundation 2013-02-26 19:15:29 -05:00
test_utils.py Better default for my_ip if 8.8.8.8 is unreachable 2013-06-26 15:10:39 -04:00
test_versions.py Use oslo-config-2013.1b4 2013-02-19 21:16:32 -08:00
test_wsgi.py Port missing bits from httplib2 to requests 2013-06-21 14:54:47 +02:00
utils.py Fix trivial mismatch of license header 2013-06-25 19:01:57 +02: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↩︎