nova/nova/tests
Hiroyuki Eguchi 7307dbaf6b Fix disconnecting necessary iSCSI sessions issue
In Icehouse with "iscsi_use_multipath=true", detaching a multipath
iSCSI volume kills all iSCSI volumes visible from the nova compute node.
When we use different targets(IQNs) associated with same portal for
each different multipath device, all of the targets will be deleted
via disconnect_volume().

This patch fixes the behavior of detaching volume:

  1. Extract the targets for the detached multipath device.
  2. Delete/disconnect the targets for the detached multipath device.

Closes-Bug: #1382440

(cherry picked from commit 36aeedfd5e)

Conflicts:
        nova/tests/unit/virt/libvirt/test_volume.py

Change-Id: I38eafdaee03d136282cfde1fd013e322a4256cc4
2014-12-26 09:42:20 +09:00
..
CA
api Merge "Fix live migration api stuck when migrate to old nova node" into stable/juno 2014-12-11 01:57:33 +00:00
bundle
cells Merge "Cells: Update set_admin_password for objects" 2014-09-15 21:54:33 +00:00
cert
cmd do not use unittest.TestCase for tests 2014-09-24 15:34:24 -04:00
compute Merge "Instances with NUMA will be packed onto hosts" into stable/juno 2014-12-04 14:02:47 +00:00
conductor Merge "Fix live migration api stuck when migrate to old nova node" into stable/juno 2014-12-11 01:57:33 +00:00
console console: make websocketproxy handles token from path 2014-09-29 10:24:21 -04:00
consoleauth Fix and gate on H305 and H307 2014-07-15 01:13:26 +00:00
db Use opportunistic approach for migration testing 2014-11-24 22:55:46 -08:00
fake_loadables
image Add unit test for glanceclient ssl options 2014-09-20 12:24:32 -07:00
integrated move integrated api client to requests library 2014-10-04 05:37:37 -04:00
keymgr Cleanup and gate on hacking E711 and E712 rule 2014-07-19 13:07:59 +00:00
monkey_patch_example
network Merge "Refactor test_get_port_vnic_info 2 and 3" 2014-09-25 15:25:11 +00:00
objects Make Instance.save() update numa_topology 2014-11-27 18:20:25 +01:00
pci fix up assertEqual(None...) check to catch more cases 2014-09-15 10:23:40 -04:00
scheduler Add legacy to the possible server group policies 2014-11-27 09:10:38 +01:00
servicegroup
ssl_cert
virt Fix disconnecting necessary iSCSI sessions issue 2014-12-26 09:42:20 +09:00
volume Deprecate cinder_* configuration settings 2014-08-26 04:31:59 -07:00
README.rst
__init__.py docs - Prevent eventlet exception during docs generation 2014-08-01 15:43:03 +00:00
cast_as_call.py
conf_fixture.py Bump FakeDriver's resource numbers 2014-09-12 15:09:11 -07:00
fake_block_device.py Add 'anon' kwarg to FakeDbBlockDeviceDict class 2014-07-04 18:16:38 +02:00
fake_crypto.py
fake_hosts.py
fake_instance.py Fix last of direct use of object modules 2014-07-22 19:37:12 +10:00
fake_ldap.py Use oslo.i18n 2014-07-18 14:28:09 -04:00
fake_network.py Support reserving ips at network create time 2014-08-19 11:21:23 -07:00
fake_network_cache_model.py
fake_notifier.py
fake_policy.py Merge "compute: add get_serial_console rpc and cells api calls" 2014-09-07 12:58:58 +00:00
fake_processutils.py
fake_server_actions.py
fake_utils.py Make spawn_n() stub properly ignore errors in the child thread work 2014-08-04 10:15:37 -07:00
fake_volume.py Deprecate cinder_* configuration settings 2014-08-26 04:31:59 -07:00
image_fixtures.py docs - Fix errors,warnings from document generation 2014-08-08 22:07:31 +00:00
matchers.py Remove usage of self.__dict__ for message var replacement 2014-09-25 07:40:27 -07:00
policy_fixture.py Consistently use jsonutils instead of specific implementation 2014-08-12 15:57:09 +02:00
test_api_validation.py Add API schema for v2.1/v3 user_data extension 2014-09-01 10:00:51 +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
test_block_device.py Allow empty volumes to be created 2014-08-08 19:30:17 -04:00
test_cinder.py Deprecate cinder_* configuration settings 2014-08-26 04:31:59 -07:00
test_configdrive2.py Support image property for config drive 2014-09-03 17:02:00 +00:00
test_context.py
test_crypto.py Fix broken cert revocation 2014-10-09 08:59:06 +02:00
test_exception.py Use oslo.i18n 2014-07-18 14:28:09 -04:00
test_flavors.py Stash numa-related flavor extra_spec items in system_metadata 2014-09-12 21:07:57 -07:00
test_hacking.py mock.assert_called_once() is not a valid method 2014-09-16 16:38:49 -04:00
test_hooks.py
test_instance_types_extra_specs.py maint: various spelling fixes 2014-09-08 11:55:48 +01:00
test_iptables_network.py Replace assertTrue/False with assertIn/NotIn 2014-06-20 13:13:30 +04:00
test_ipv6.py
test_linuxscsi.py Fix live-migration failure in FC multipath case 2014-08-09 00:02:06 +08:00
test_loadables.py
test_matchers.py
test_metadata.py Use response.text for returning unicode EC2 metadata 2014-10-22 12:49:08 -07:00
test_notifications.py Be less confusing about notification states 2014-09-22 11:20:58 -04:00
test_nova_manage.py Use oslo.i18n 2014-07-18 14:28:09 -04:00
test_objectstore.py Fix and gate on H305 and H307 2014-07-15 01:13:26 +00:00
test_pipelib.py
test_policy.py Remove stubs in favor of mock in test_policy 2014-07-19 01:37:58 -07:00
test_quota.py Merge "Fix NoopQuotasDriver.get_settable_quotas()" 2014-09-25 06:05:46 +00:00
test_safeutils.py Fix and Gate on E265 2014-07-24 08:11:00 -04:00
test_service.py Add good path test cases of osapi_compute_workers 2014-09-22 14:20:03 -05:00
test_test.py
test_test_utils.py
test_utils.py Merge "Make compute api use util.check_string_length" 2014-08-08 07:32:44 +00:00
test_versions.py
test_weights.py
test_wsgi.py Merge "Fix and gate on H305 and H307" 2014-07-15 05:00:31 +00:00
utils.py Remove duplicate keys from dictionaries 2014-07-08 07:17:32 -04: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↩︎