nova/nova/tests/unit
Sean Mooney 8c72241726 support pci numa affinity policies in flavor and image
This addresses bug #1795920 by adding support for
defining a pci numa affinity policy via the flavor
extra specs or image metadata properties enabling
the policies to be applied to neutron sriov port
including hardware offloaded ovs.

Closes-Bug: #1795920
Related-Bug: #1805891
Implements: blueprint vm-scoped-sriov-numa-affinity
Change-Id: Ibd62b24c2bd2dd208d0f804378d4e4f2bbfdaed6
2019-12-11 14:39:12 +00:00
..
api support pci numa affinity policies in flavor and image 2019-12-11 14:39:12 +00:00
cmd Remove nova-manage network, floating commands 2019-11-23 13:05:32 +00:00
compute Block rebuild when NUMA topology changed 2019-12-05 23:20:52 +00:00
conductor Merge "Sanity check instance mapping during scheduling" 2019-11-28 23:25:35 +00:00
conf
console Mask the token used to allow access to consoles 2019-11-27 16:24:35 +00:00
db Merge "test cleanup: Use oslotest's Timeout fixture" 2019-11-22 23:17:23 +00:00
fake_loadables
image Improve error log when snapshot fails 2019-11-06 22:54:05 +00:00
keymgr
network Cache security group driver 2019-12-03 10:54:29 -05:00
notifications support pci numa affinity policies in flavor and image 2019-12-11 14:39:12 +00:00
objects support pci numa affinity policies in flavor and image 2019-12-11 14:39:12 +00:00
pci support pci numa affinity policies in flavor and image 2019-12-11 14:39:12 +00:00
policies Introduce scope_types in os-services 2019-11-25 17:44:15 +00:00
privsep libvirt: Remove 'enable_hairpin' 2019-11-29 17:20:02 +00:00
scheduler Reusable RequestGroup.add_{resource|trait} 2019-12-02 07:28:00 -06:00
servicegroup Fix deprecation warning for threadgroup.add_timer 2019-02-07 09:37:00 -05:00
ssl_cert
virt support pci numa affinity policies in flavor and image 2019-12-11 14:39:12 +00:00
volume Fix exception translation when creating volume 2019-10-10 02:38:33 +00:00
README.rst
__init__.py
cast_as_call.py
conf_fixture.py Stop using NoAuthMiddleware in tests 2019-10-14 11:43:52 -05:00
fake_block_device.py
fake_build_request.py
fake_console_auth_token.py
fake_crypto.py
fake_diagnostics.py
fake_flavor.py
fake_hosts.py
fake_instance.py Claim resources in resource tracker 2019-09-13 08:50:35 +00:00
fake_ldap.py
fake_network.py
fake_network_cache_model.py
fake_notifier.py
fake_pci_device_pools.py
fake_policy.py Remove 'os-consoles' API 2019-11-22 16:09:36 +00:00
fake_processutils.py
fake_request_spec.py Fix resetting non-persistent fields when saving obj 2019-02-26 09:26:52 +09:00
fake_requests.py
fake_server_actions.py
fake_volume.py
fake_xvp_console_proxy.py
image_fixtures.py
matchers.py fix bug with XML matcher handling missing children 2019-03-01 18:19:01 +00:00
policy_fixture.py Suppress policy deprecated warnings in tests 2019-11-26 19:05:57 +00:00
test_api_validation.py Remove '/os-cells' REST APIs 2019-04-16 18:26:13 +01:00
test_availability_zones.py Always pass HostAPI to get_availability_zones 2019-04-26 15:30:48 -04:00
test_baserpc.py
test_block_device.py
test_cache.py
test_cinder.py
test_conf.py test cleanup: Make base TestCase subclass oslotest 2019-11-22 22:38:22 +00:00
test_configdrive2.py
test_context.py Revert "Log CellTimeout traceback in scatter_gather_cells" 2019-10-22 17:12:28 -04:00
test_crypto.py We no longer need rootwrap. 2019-02-27 05:06:31 +00:00
test_exception.py
test_fake_notifier.py
test_fixtures.py Merge "test cleanup: Use oslotest's CaptureOutput fixture" 2019-11-22 23:17:28 +00:00
test_flavors.py Remove deprecated 'default_flavor' config option 2019-04-30 13:01:40 +00:00
test_hacking.py Add a hacking rule for useless assertions 2019-08-21 14:42:53 +09:00
test_hooks.py
test_identity.py
test_instance_types_extra_specs.py
test_iptables_network.py hacking: Resolve W605 (invalid escape sequence) 2019-06-24 14:24:06 -05:00
test_ipv6.py
test_json_ref.py Tests: autospecs all the mock.patch usages 2019-08-19 09:43:10 -05:00
test_loadables.py
test_matchers.py fix bug with XML matcher handling missing children 2019-03-01 18:19:01 +00:00
test_metadata.py Tests: autospecs all the mock.patch usages 2019-08-19 09:43:10 -05:00
test_notifications.py Remove deprecated 'default_flavor' config option 2019-04-30 13:01:40 +00:00
test_notifier.py
test_policy.py Merge "Add new default rules and mapping in policy base class" 2019-12-03 02:53:16 +00:00
test_profiler.py Remove 'nova-console' service, 'console' RPC API 2019-11-22 16:09:38 +00:00
test_quota.py nova-net: Remove 'networks' quota 2019-11-22 16:49:31 +00:00
test_rpc.py test_rpc: Stop f****** with global state 2019-04-26 12:21:16 +01:00
test_safeutils.py
test_service.py
test_service_auth.py
test_test.py Move selective patching of open() to nova.test for reuse 2019-05-25 02:49:40 +00:00
test_test_utils.py
test_utils.py Remove workaround for bug #1709118 2019-10-07 16:33:20 +00:00
test_versions.py Move selective patching of open() to nova.test for reuse 2019-05-25 02:49:40 +00:00
test_weights.py
test_wsgi.py
utils.py Fix ItemMatcher to avoid false positives 2019-10-21 10:17:11 +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 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↩︎