nova/nova/tests
Brad Pokorny 5445833413 Mask node.session.auth.password in volume.py _run_iscsiadm debug logs
The iscsi_command object passed to _run_iscsiadm can contain passwords
that get logged at debug level, so we need to sanitize the message
getting logged.

Adds a test to ensure the logged message is properly sanitized.

Closes-Bug: #1320028

Change-Id: I33f1a5b698368504721b41e56266162a713b3ce6
2014-07-02 22:03:20 +00:00
..
CA
api Merge "Fixes internal server error for add/remove tenant flavor access request" 2014-07-01 06:50:40 +00:00
bundle
cells Fix the rest of direct uses of instance module objects 2014-06-24 00:49:07 -07:00
cert Removed copyright from empty files 2014-02-27 14:27:54 +02:00
compute Merge "Fix error in rescue rpcapi that prevents sending objects" 2014-07-02 19:49:15 +00:00
conductor Merge "Fix the rest of direct uses of instance module objects" 2014-06-27 00:16:57 +00:00
console Removed copyright from empty files 2014-02-27 14:27:54 +02:00
consoleauth Removed copyright from empty files 2014-02-27 14:27:54 +02:00
db Merge "Add new fields to the networks table" 2014-06-21 02:40:42 +00:00
fake_loadables
glance Add deleted_at attribute in glance stub on delete() 2014-03-19 02:18:24 +00:00
image Deprecate glance_* configuration settings 2014-06-18 07:17:30 -07:00
integrated Fix agent_id with string type in API samples files for os-agents v2 2014-06-26 08:46:41 -07:00
keymgr Merge "Removed copyright from empty files" 2014-06-08 01:22:57 +00:00
monkey_patch_example Remove vi modelines 2014-02-03 14:19:44 +00:00
network Merge "Add assert_called check for "brclt addif" test" 2014-07-02 02:28:47 +00:00
objects Merge "Fix the rest of direct uses of instance module objects" 2014-06-27 00:16:57 +00:00
pci Fix the rest of direct uses of instance module objects 2014-06-24 00:49:07 -07:00
scheduler Merge "Fix the rest of direct uses of instance module objects" 2014-06-27 00:16:57 +00:00
servicegroup Removed copyright from empty files 2014-02-27 14:27:54 +02:00
ssl_cert
virt Mask node.session.auth.password in volume.py _run_iscsiadm debug logs 2014-07-02 22:03:20 +00:00
volume Merge "Removed copyright from empty files" 2014-06-08 01:22:57 +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 Rewrite nova policy to use the new changes of common policy 2014-05-29 11:44:05 +08: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 Fix the rest of direct uses of instance module objects 2014-06-24 00:49:07 -07:00
fake_ldap.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_network.py Merge "Adds network fields to object" 2014-06-21 03:55:20 +00: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 Merge "Revert "Allow admin user to get all tenant's floating IPs"" 2014-06-17 09:16:58 +00: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 Merge "Set the volume access mode during volume attach" 2014-05-21 06:25:42 +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 Rewrite nova policy to use the new changes of common policy 2014-05-29 11:44:05 +08:00
test_api_validation.py Add unit tests for ipv4/ipv6 format validation 2014-06-06 10:26:59 +09:00
test_availability_zones.py Merge "Improve performance for checking hosts AZs" 2014-06-20 18:57:10 +00:00
test_baserpc.py
test_bdm.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_block_device.py Add test cases for block_device 2014-06-27 08:11:16 +00:00
test_cinder.py Merge "Add configurable HTTP timeout to cinder API calls" 2014-06-17 20:01:34 +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 Catch ProcessExecutionError in revoke_cert 2014-06-18 11:05:44 +10:00
test_exception.py Merge "Sync latest gettextutils from oslo-incubator" 2014-02-10 11:56:23 +00:00
test_flavors.py Enable flake8 F841 checking 2014-05-28 14:55:08 +01:00
test_hacking.py Removes the use of mutables as default args 2014-06-18 12:59:02 +08:00
test_hooks.py Enhance and test exception safety in hooks 2014-06-17 15:37:36 -04: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 Fix the rest of direct uses of instance module objects 2014-06-24 00:49:07 -07:00
test_notifications.py Add VIF mac address to fixed_ips in notifications 2014-05-21 11:25:13 +10:00
test_nova_manage.py Fix the wrong dest of 'vlan' option and add new 'vlan_start' option 2014-06-12 15:30:37 +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 fix nova test_enforce_http_true unit test 2014-06-09 13:29:13 +08:00
test_quota.py Ensure changes to api.QUOTA_SYNC_FUNCTIONS are restored. 2014-06-12 19:31:28 -04:00
test_safeutils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_service.py Handle service creation race by service workers 2014-06-16 12:18:37 -04: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 Replace nova.utils.cpu_count() with processutils.get_worker_count() 2014-06-25 10:32:32 -07:00
test_versions.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_weights.py Enable flake8 F841 checking 2014-05-28 14:55:08 +01:00
test_wsgi.py Don't follow HTTP_PROXY when talking to localhost test server 2014-06-23 14:23:13 +10:00
utils.py Fix the rest of direct uses of instance module objects 2014-06-24 00:49:07 -07: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↩︎