nova/nova/tests
Leandro I. Costantino 050ce0e589 Enforce FlavorExtraSpecs Key format.
When creating a key name with characters like '/' that are not
being encoded or cannot be handled as expected by routes when
matching the url, then it's not possible to remove them anymore.
The new format apply the restriction: "[\w\.\- :]+$"

This change will fix the bug without API change.

Change-Id: I64bc098c4bde33c40fa149191a751ea3eb19f932
Closes-Bug: #1256119
2014-02-03 11:57:32 -05:00
..
CA
api Enforce FlavorExtraSpecs Key format. 2014-02-03 11:57:32 -05:00
bundle
cells Port to oslo.messaging 2014-02-01 09:53:24 +00:00
cert Port to oslo.messaging 2014-02-01 09:53:24 +00:00
compute Merge "Port to oslo.messaging" 2014-02-02 11:08:37 +00:00
conductor Port to oslo.messaging 2014-02-01 09:53:24 +00:00
console Port to oslo.messaging 2014-02-01 09:53:24 +00:00
consoleauth Port to oslo.messaging 2014-02-01 09:53:24 +00:00
db Make fixed_ip_get_by_address() take columns_to_join 2014-01-30 09:27:33 -08:00
fake_loadables
glance Added 'page_size' param to image list 2013-09-24 09:53:00 +05:30
image Comply with new hacking 0.8 release 2013-12-02 10:58:45 +09:00
integrated Merge "Removes XML namespace definitions from V3 API plugins" 2014-02-01 23:02:27 +00:00
keymgr Replace assertEquals with assertEqual - tests/etc 2013-11-12 14:51:29 +08:00
monkey_patch_example
network Merge "Port to oslo.messaging" 2014-02-02 11:08:37 +00:00
objects Merge "Port to oslo.messaging" 2014-02-02 11:08:37 +00:00
pci Check for None when cleaning PCI dev usage 2013-10-13 20:31:18 -07:00
scheduler Port to oslo.messaging 2014-02-01 09:53:24 +00:00
servicegroup Utilizes assertIn - tests/etc 2013-10-21 10:01:20 +08:00
ssl_cert
virt Merge "libvirt: Configuration element for sVirt support" 2014-02-02 22:06:52 +00:00
volume Convert TestCases to NoDBTestCase 2013-09-21 20:46:04 +10:00
README.rst
__init__.py
cast_as_call.py Port to oslo.messaging 2014-02-01 09:53:24 +00:00
conf_fixture.py Port to oslo.messaging 2014-02-01 09:53:24 +00:00
fake_block_device.py Add block device mapping objects implementation 2014-01-30 15:28:05 +01:00
fake_crypto.py
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
fake_ldap.py
fake_network.py Make nova-network use Network object for remaining "get" queries 2014-01-30 09:27:33 -08:00
fake_network_cache_model.py
fake_notifier.py Port to oslo.messaging 2014-02-01 09:53:24 +00:00
fake_policy.py Adds suspend server extension for V3 API 2014-01-31 15:10:41 +10:30
fake_processutils.py Nova-all: Replace basestring by six for python3 compatability 2013-10-28 16:55:05 +08:00
fake_utils.py
fake_volume.py
fakeguestfs.py Disable libguestfs' default atexit handlers. 2013-12-30 11:39:16 +11:00
matchers.py
policy_fixture.py
test_api_validation.py Define common API parameter types 2014-01-12 19:00:03 +09:00
test_availability_zones.py Fixing availability-zone not take effect error 2013-12-26 17:50:26 +08:00
test_baserpc.py
test_bdm.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_block_device.py Make snapshot_volume_backed use new-world objects 2014-01-30 15:28:05 +01:00
test_cinder.py Replace assertEquals with assertEqual - tests/etc 2013-11-12 14:51:29 +08:00
test_configdrive2.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_context.py Merge "Fixes RequestContext initialization failure." 2013-11-25 12:24:45 +00:00
test_crypto.py
test_exception.py Replace assertEquals with assertEqual - tests/etc 2013-11-12 14:51:29 +08:00
test_flavors.py Merge "Enable non-ascii characters in flavor names" 2013-11-26 01:33:23 +00:00
test_hooks.py support stevedore >= 0.14 2014-01-27 16:35:11 -05:00
test_instance_types_extra_specs.py Replace assertEquals with assertEqual - tests/etc 2013-11-12 14:51:29 +08:00
test_iptables_network.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_ipv6.py Replace assertEquals with assertEqual - tests/etc 2013-11-12 14:51:29 +08:00
test_linuxscsi.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_loadables.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_matchers.py Change the duplicate class name TestDictMatches in test_matches.py 2013-09-11 13:57:04 +08:00
test_metadata.py Prevent spoofing instance_id from neutron to nova 2013-12-11 12:36:20 -08:00
test_notifications.py Replace assertEquals with assertEqual - tests/etc 2013-11-12 14:51:29 +08:00
test_nova_manage.py Make nova-network use Network object for remaining "get" queries 2014-01-30 09:27:33 -08:00
test_objectstore.py Replace assertEquals with assertEqual - tests/etc 2013-11-12 14:51:29 +08:00
test_pipelib.py
test_policy.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_quota.py Port to oslo.messaging 2014-02-01 09:53:24 +00:00
test_safeutils.py Utilizes assertIsNone and assertIsNotNone - tests/etc 2013-10-31 06:06:02 +09:00
test_service.py Port to oslo.messaging 2014-02-01 09:53:24 +00:00
test_test.py Port to oslo.messaging 2014-02-01 09:53:24 +00:00
test_test_utils.py Claim IPv6 is unsupported if no interface with IPv6 configured 2013-10-28 16:31:33 +01:00
test_utils.py Use (# of CPUs) workers by default 2014-01-26 21:29:15 -05:00
test_versions.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_weights.py Normalize the weights instead of using raw values 2013-12-11 20:24:16 +01:00
test_wsgi.py Ensure api_paste_conf is an absolute path 2013-12-10 13:42:05 +01:00
utils.py Rename instance_type to flavor in test_utils and nova.tests.utils 2013-12-10 13:08:14 -08: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↩︎