diff options
author | Rick Harris <rconradharris@gmail.com> | 2013-05-25 01:01:13 +0000 |
---|---|---|
committer | Rick Harris <rconradharris@gmail.com> | 2013-06-07 02:07:41 +0000 |
commit | f261afdfbed05cef9d534e418ddd8bcb26970cc6 (patch) | |
tree | 274b4f73c7c6ef95192eb71e457bfa1ac9c6cf89 /nova/tests/scheduler/fakes.py | |
parent | 7d423d3c919cd8b3526010981b0037e7579132d1 (diff) | |
download | nova-f261afdfbed05cef9d534e418ddd8bcb26970cc6.tar.gz nova-f261afdfbed05cef9d534e418ddd8bcb26970cc6.tar.xz nova-f261afdfbed05cef9d534e418ddd8bcb26970cc6.zip |
Speeding up scheduler tests
Database access is costly in tests and many tests
don't actually need it. This patch provides a
simple way we can speed up the Nova tests by
providing a new base class, `NoDBTestCase` which
allows us to white-list tests not needing database
access.
The following speedups were observed:
With TestCase: Ran 265 tests in 17.080s
With NoDBTestCase: Ran 265 tests in 9.478s
Further optimizaton could be done by fixing
`test_host_filters` to not hit the database. This
will require some effort though in order to
maintain the quality of test coverage since part
of what's doing is testing the code in the DB
layer.
Change-Id: Ic34c4c39d7f680ac501efb459fdeaa51331ffe1c
Diffstat (limited to 'nova/tests/scheduler/fakes.py')
-rw-r--r-- | nova/tests/scheduler/fakes.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/nova/tests/scheduler/fakes.py b/nova/tests/scheduler/fakes.py index c9157d11c..3dfc7c452 100644 --- a/nova/tests/scheduler/fakes.py +++ b/nova/tests/scheduler/fakes.py @@ -18,7 +18,6 @@ Fakes For Scheduler tests. import mox -from nova.compute import flavors from nova.compute import vm_states from nova import db from nova.scheduler import filter_scheduler @@ -107,14 +106,14 @@ class FakeHostState(host_manager.HostState): class FakeInstance(object): - def __init__(self, context=None, params=None, type_name='m1.tiny'): + def __init__(self, context=None, params=None): """Create a test instance. Returns uuid.""" self.context = context - i = self._create_fake_instance(params, type_name=type_name) + i = self._create_fake_instance(params=params) self.uuid = i['uuid'] - def _create_fake_instance(self, params=None, type_name='m1.tiny'): + def _create_fake_instance(self, params=None): """Create a test instance.""" if not params: params = {} @@ -125,8 +124,7 @@ class FakeInstance(object): inst['reservation_id'] = 'r-fakeres' inst['user_id'] = 'fake' inst['project_id'] = 'fake' - type_id = flavors.get_instance_type_by_name(type_name)['id'] - inst['instance_type_id'] = type_id + inst['instance_type_id'] = 2 inst['ami_launch_index'] = 0 inst.update(params) return db.instance_create(self.context, inst) |