Make compute unit tests inherit from test.NoDBTestCase

This patch changes the `compute` tests-package(where it's possible)
to test.NoDBTestCase saving test case running time.

- nova.tests.unit.compute.test_compute.CheckConfigDriveTestCase
  before : Ran 3 tests in 1.891s
  after : Ran 3 tests in 0.100s

- nova.tests.unit.compute.test_flavors.ExtraSpecTestCase
  before : Ran 3 tests in 1.842s
  after : Ran 3 tests in 0.113s

- nova.tests.unit.compute.test_resources.TestVCPU
  before : Ran 6 tests in 1.897s
  after : Ran 6 tests in 0.116s

- nova.tests.unit.compute.test_resources.BaseTestCase
  before : Ran 9 tests in 1.990s
  after : Ran 9 tests in 0.149s

- nova.tests.unit.compute.test_rpcapi.ComputeRpcAPITestCase
  before : Ran 76 tests in 3.941s
  after : Ran 76 tests in 0.796s

- nova.tests.unit.compute.monitors.test_cpu_monitor.\
      ComputeDriverCPUMonitorTestCase
  before : Ran 2 tests in 3.883s
  after : Ran 2 tests in 0.287s

- nova.tests.unit.compute.monitors.test_monitors.\
      ResourceMonitorBaseTestCase
  before : Ran 2 tests in 4.028s
  after : Ran 2 tests in 0.254s

- nova.tests.unit.compute.monitors.test_monitors.\
      ResourceMonitorsTestCase
  before : Ran 5 tests in 8.937s
  after : Ran 5 tests in 0.402s

Change-Id: I5b71b6360061261daf28037b8f293844cc352c6f
This commit is contained in:
Mike Durnosvistov 2015-02-24 17:54:29 +02:00
parent 223986d7d0
commit d9dca3b76d
6 changed files with 8 additions and 8 deletions

View File

@ -36,7 +36,7 @@ class FakeLibvirt(object):
return [0, 0, 0, 800, 0, 0, 0, 0] return [0, 0, 0, 800, 0, 0, 0, 0]
class ComputeDriverCPUMonitorTestCase(test.TestCase): class ComputeDriverCPUMonitorTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(ComputeDriverCPUMonitorTestCase, self).setUp() super(ComputeDriverCPUMonitorTestCase, self).setUp()

View File

@ -78,7 +78,7 @@ class FakeMonitorClass4(monitors.ResourceMonitorBase):
raise test.TestingException() raise test.TestingException()
class ResourceMonitorBaseTestCase(test.TestCase): class ResourceMonitorBaseTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(ResourceMonitorBaseTestCase, self).setUp() super(ResourceMonitorBaseTestCase, self).setUp()
self.monitor = FakeResourceMonitor(None) self.monitor = FakeResourceMonitor(None)
@ -102,7 +102,7 @@ class ResourceMonitorBaseTestCase(test.TestCase):
self.assertEqual(metrics["foo.metric2"], '99.999') self.assertEqual(metrics["foo.metric2"], '99.999')
class ResourceMonitorsTestCase(test.TestCase): class ResourceMonitorsTestCase(test.NoDBTestCase):
"""Test case for monitors.""" """Test case for monitors."""
def setUp(self): def setUp(self):

View File

@ -11411,7 +11411,7 @@ class ComputeInjectedFilesTestCase(BaseTestCase):
expected, None, True, None, False) expected, None, True, None, False)
class CheckConfigDriveTestCase(test.TestCase): class CheckConfigDriveTestCase(test.NoDBTestCase):
# NOTE(sirp): `TestCase` is far too heavyweight for this test, this should # NOTE(sirp): `TestCase` is far too heavyweight for this test, this should
# probably derive from a `test.FastTestCase` that omits DB and env # probably derive from a `test.FastTestCase` that omits DB and env
# handling # handling

View File

@ -35,7 +35,7 @@ class ExtraSpecTestCase(test.NoDBTestCase):
flavors.validate_extra_spec_keys(key_name_list) flavors.validate_extra_spec_keys(key_name_list)
class CreateFlavorTestCase(test.TestCase): class CreateFlavorTestCase(test.NoDBTestCase):
def test_create_flavor_ram_error(self): def test_create_flavor_ram_error(self):
args = ("ram_test", "9999999999", "1", "10", "1") args = ("ram_test", "9999999999", "1", "10", "1")
try: try:

View File

@ -136,7 +136,7 @@ def fake_flavor_obj(**updates):
return flavor return flavor
class BaseTestCase(test.TestCase): class BaseTestCase(test.NoDBTestCase):
def _initialize_used_res_counter(self): def _initialize_used_res_counter(self):
# Initialize the value for the used resource # Initialize the value for the used resource
@ -285,7 +285,7 @@ class BaseTestCase(test.TestCase):
self.assertIsInstance(ext.obj, vcpu.VCPU) self.assertIsInstance(ext.obj, vcpu.VCPU)
class TestVCPU(test.TestCase): class TestVCPU(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(TestVCPU, self).setUp() super(TestVCPU, self).setUp()

View File

@ -33,7 +33,7 @@ from nova.tests.unit import fake_instance
CONF = cfg.CONF CONF = cfg.CONF
class ComputeRpcAPITestCase(test.TestCase): class ComputeRpcAPITestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(ComputeRpcAPITestCase, self).setUp() super(ComputeRpcAPITestCase, self).setUp()