nova/nova/tests
Vishvananda Ishaya b6a080bbda Fixes DOS issue in instance list ip filter
Converts the ip filtering to filter the list locally based
on the network info cache instead of making an extremely expensive
call over to nova network where it attempts to retrieve a list
of every instance in the system.

Change-Id: I455f6ab4acdecacc5152b11a183027f933dc4475
Closes-bug: #1358583
(cherry picked from commit 24c8cc53fd6a62fcad1287b2cdcf32d2ff0991d9)
2014-10-28 14:55:44 +00:00
..
CA
api Fix XML UnicodeEncode serialization error 2014-10-17 09:07:01 -07:00
bundle
cells Fix CellStateManagerFile init to failure 2014-10-06 08:55:10 +01:00
cert Remove vi modelines 2014-02-03 14:19:44 +00:00
compute Fixes DOS issue in instance list ip filter 2014-10-28 14:55:44 +00:00
conductor InvalidCPUInfo exception added to except block 2014-04-22 13:55:37 -04:00
console Remove vi modelines 2014-02-03 14:19:44 +00:00
consoleauth Remove vi modelines 2014-02-03 14:19:44 +00:00
db postgresql: use postgres db instead of template1 2014-10-15 09:50:19 -07:00
fake_loadables
glance Add deleted_at attribute in glance stub on delete() 2014-03-19 02:18:24 +00:00
image Catch missing Glance image attrs with None 2014-08-22 19:31:42 -07:00
integrated remove test_multiprocess_api 2014-09-25 10:36:42 +02:00
keymgr Remove vi modelines 2014-02-03 14:19:44 +00:00
monkey_patch_example Remove vi modelines 2014-02-03 14:19:44 +00:00
network share neutron admin auth tokens 2014-10-15 13:33:10 +00:00
objects Fix FloatingIP.save() passing FixedIP object to sqlalchemy 2014-08-07 23:48:15 -04:00
pci Change assertTrue(isinstance()) by optimal assert 2014-02-12 16:19:08 +01:00
scheduler Scheduler: enable scheduler hint to pass the group name 2014-07-07 09:45:27 -04:00
servicegroup Make sure report_interval is less than service_down_time 2013-11-27 13:06:15 +08:00
ssl_cert
virt Merge "VMWare: Fix VM leak when deletion of VM during resizing" into stable/icehouse 2014-10-14 10:52:09 +00:00
volume Merge "Fix instance cross AZ check when attaching volumes" into stable/icehouse 2014-10-16 09:28:40 +00:00
README.rst
__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 Use debug level logging in unit tests, but don't save them. 2014-05-01 13:34:17 -07: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 Clean up _make_*_list in object models to use base.obj_make_list 2014-02-26 08:13:43 +08:00
fake_instance_actions.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_ldap.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_network.py Remove unused method from fake_network.py 2014-03-18 16:17:21 -07: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 Revert "Remove broken quota-classes API" 2014-06-10 13:13:25 -07:00
fake_processutils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_utils.py
fake_volume.py Set the volume access mode during volume attach 2014-06-05 17:01:58 -04:00
fakeguestfs.py Merge "Test guestfs without support for close_on_exit" 2014-02-10 19:20:15 +00:00
matchers.py Enable flake8 H404 checking 2014-02-27 11:15:55 +04:00
policy_fixture.py Adds unit test for etc/nova/policy.json data 2014-02-28 07:24:32 +01:00
test_api_validation.py Fix expected error details from jsonschema 2014-08-21 11:13:07 +12:00
test_availability_zones.py Change assertTrue(isinstance()) by optimal assert 2014-02-12 16:19:08 +01:00
test_baserpc.py
test_bdm.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_block_device.py Fix BDM legacy usage with objects 2014-03-06 13:17:27 -08:00
test_cinder.py Use six.moves.urllib.parse instead of urlparse 2014-02-12 18:32:05 +08: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
test_exception.py Merge "Sync latest gettextutils from oslo-incubator" 2014-02-10 11:56:23 +00:00
test_flavors.py Sync the latest DB code from oslo-incubator 2014-03-03 16:45:22 -05:00
test_hacking.py Replace assertEqual(None, *) with assertIsNone in tests 2014-02-16 17:31:28 +08:00
test_hooks.py Remove vi modelines 2014-02-03 14:19:44 +00: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 Fix live-migration failure in FC multipath case 2014-09-24 15:39:50 +08:00
test_loadables.py
test_matchers.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_metadata.py Remove metadata's network-api dependence on the database 2014-04-22 15:47:31 -07:00
test_notifications.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_nova_manage.py Fix the wrong dest of 'vlan' option and add new 'vlan_start' option 2014-06-30 01:16:56 +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 Adds unit test for etc/nova/policy.json data 2014-02-28 07:24:32 +01:00
test_quota.py Use one query instead of two for quota_usages 2014-05-06 16:23:52 -07: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-07-21 16:14:42 +01:00
test_test.py Use debug level logging in unit tests, but don't save them. 2014-05-01 13:34:17 -07:00
test_test_utils.py Merge "Fix potential fd leak" 2014-02-10 09:18:32 +00:00
test_utils.py Avoid possible timing attack in metadata api 2014-07-23 12:45:06 +10:00
test_versions.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_weights.py Normalize the weights instead of using raw values 2013-12-11 20:24:16 +01:00
test_wsgi.py Nova api service doesn't handle SIGHUP properly 2014-10-21 08:07:17 +00:00
utils.py Add get_hosts to InstanceGroup object 2014-03-06 20:57:14 +00: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↩︎