nova/nova/tests
Joel Coffman cf5645fdee Add key manager implementation with static key
Per feedback received on other patch sets, an example key manager
driver is required to support ephemeral storage encryption and
Cinder volume encryption. The ConfKeyManager class reads its key
from the project's configuration file and provides this key for
*all* requests. As such, this key manager is insecure but allows
the aforementioned encryption features to be used without further
integration effort.

To clarify the above statements, the configuration-based key
manager uses a single, fixed key. When used to encrypt data (e.g.,
by the Cinder volume encryption feature), the encryption provides
limited protection for the confidentiality of data. For example,
data cannot be read from a lost or stolen disk, and a volume's
contents cannot be reconstructed if an attacker intercepts the iSCSI
traffic between the compute and storage host. If the key is ever
compromised, then any data encrypted with the key can be decrypted.

Implements blueprint encrypt-cinder-volumes
SecurityImpact

Change-Id: Ia6f4c69e699e68065c0f767e769cd0a6f5cc623b
2013-09-11 06:43:13 -04:00
..
CA
api Merge "Makes v3 API keypairs extension core" 2013-09-10 16:44:44 +00:00
bundle
cells Port all rpcapi modules to oslo.messaging interface 2013-09-03 21:22:43 +01:00
cert Fix and Gate on H303 (no wildcard imports) 2013-07-30 14:34:31 -07:00
compute Merge "Limit instance fault messages to 255 characters" 2013-09-09 09:02:32 +00:00
conductor Avoid errors on some actions when image not usable 2013-09-06 12:21:35 +02:00
console Stub out get_console_topic() in test_create_console 2013-08-23 14:42:38 +01:00
consoleauth Delete expired instance console auth tokens 2013-08-23 15:39:46 +08:00
db Merge "Fix compute_node_get_all() for Nova Baremetal" 2013-09-10 08:22:57 +00:00
fake_loadables
glance Add identity headers while calling glanceclient 2013-08-01 18:55:21 +00:00
image xenapi: add support for auto_disk_config=disabled 2013-09-03 11:54:01 +00:00
integrated Merge "Makes v3 API keypairs extension core" 2013-09-10 16:44:44 +00:00
keymgr Add key manager implementation with static key 2013-09-11 06:43:13 -04:00
monkey_patch_example
network Merge "Handle port over-quota when allocating network for instance" 2013-09-05 16:13:29 +00:00
objects Merge "Fix PCIDevice ignoring missing DB attributes" 2013-09-09 21:37:44 +00:00
pci Fix PCIDevice ignoring missing DB attributes 2013-09-06 09:55:51 -07:00
scheduler Port to oslo.messaging.Notifier API 2013-09-05 06:26:01 +01:00
servicegroup Remove sleep from service group db and mc tests 2013-07-30 16:31:58 -07:00
ssl_cert
virt Merge "Fix the bootfile_name method call in baremetal" 2013-09-09 21:39:04 +00:00
volume Guest-assisted-snaps libvirt implementation 2013-09-02 16:58:24 -04:00
README.rst
__init__.py Remove the monkey patching of _ into the builtins 2013-07-26 07:31:17 -07:00
cast_as_call.py Add CastAsCall fixture 2013-08-22 15:38:06 +01:00
conf_fixture.py Remove use of fake_rabbit in Nova 2013-08-21 11:35:08 +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 Make fake_instance handle security groups 2013-08-07 08:11:08 -07:00
fake_instance_actions.py Make compute_api use InstanceAction object 2013-08-10 12:00:50 -07:00
fake_ldap.py Remove the monkey patching of _ into the builtins 2013-07-26 07:31:17 -07:00
fake_network.py Remove deprecated legacy network info model in Hypervisor drivers 2013-08-23 10:19:37 +08:00
fake_network_cache_model.py
fake_notifier.py Port to oslo.messaging.Notifier API 2013-09-05 06:26:01 +01:00
fake_policy.py Merge "Makes v3 API keypairs extension core" 2013-09-10 16:44:44 +00:00
fake_processutils.py Fix H501: Do not use locals() for string formatting 2013-08-10 13:53:00 +02:00
fake_utils.py Call scheduler for run_instance from conductor 2013-06-04 13:42:04 -04:00
fake_volume.py Remove the monkey patching of _ into the builtins 2013-07-26 07:31:17 -07:00
fakeguestfs.py fix libguestfs mount order when inspecting 2013-08-10 19:13:59 +08:00
matchers.py Fix and gate on E125 2013-07-04 08:49:45 +02:00
policy_fixture.py
test_availability_zones.py Merge "Fix unicode key of azcache can't be stored to memcache" 2013-09-02 11:31:22 +00:00
test_baserpc.py
test_bdm.py
test_block_device.py Boot from image destination - volume 2013-08-19 18:54:17 +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 Pop extra keys from context in from_dict() 2013-08-22 08:30:12 +01:00
test_crypto.py
test_exception.py Port to oslo.messaging.Notifier API 2013-09-05 06:26:01 +01:00
test_flavors.py Adds Flavor ID validations 2013-08-27 00:47:27 -07: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 Code dedup in class InstanceTypeExtraSpecsTestCase 2013-07-26 10:57:42 +04:00
test_iptables_network.py Fix simultaneous timeout with smart iptables usage 2013-08-08 13:20:40 -07:00
test_ipv6.py
test_linuxscsi.py Fix dangling LUN issue under load with multipath 2013-06-10 14:10:03 -07:00
test_loadables.py
test_manager.py
test_matchers.py
test_metadata.py Remove deprecated legacy network info model in Hypervisor drivers 2013-08-23 10:19:37 +08:00
test_notifications.py Port to oslo.messaging.Notifier API 2013-09-05 06:26:01 +01:00
test_nova_manage.py Merge "Clarify instance_type vs flavor in nova-manage" 2013-07-29 22:07:33 +00:00
test_objectstore.py
test_pipelib.py
test_policy.py
test_quota.py Fixes sync issue for user level resources 2013-08-22 15:13:08 -04:00
test_safeutils.py
test_service.py Don't pass RPC connection to pre_start_hook 2013-08-19 11:49:34 +01:00
test_test.py
test_test_utils.py
test_utils.py Add methods to get image metadata from instance 2013-09-06 12:15:31 +02:00
test_versions.py
test_wsgi.py Port missing bits from httplib2 to requests 2013-06-21 14:54:47 +02:00
utils.py Remove deprecated legacy network info model in Hypervisor drivers 2013-08-23 10:19:37 +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↩︎