Merge "Unit test consistency: DB base and utils prefix"

This commit is contained in:
Jenkins
2017-06-20 15:24:03 +00:00
committed by Gerrit Code Review
19 changed files with 144 additions and 160 deletions

View File

@@ -26,14 +26,14 @@ import pecan
import pecan.testing import pecan.testing
from six.moves.urllib import parse as urlparse from six.moves.urllib import parse as urlparse
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
PATH_PREFIX = '/v1' PATH_PREFIX = '/v1'
cfg.CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token') cfg.CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token')
class BaseApiTest(base.DbTestCase): class BaseApiTest(db_base.DbTestCase):
"""Pecan controller functional testing class. """Pecan controller functional testing class.
Used for functional tests of Pecan controllers where you need to Used for functional tests of Pecan controllers where you need to

View File

@@ -24,7 +24,7 @@ from ironic.api.controllers.v1 import node as node_controller
from ironic.api.controllers.v1 import port as port_controller from ironic.api.controllers.v1 import port as port_controller
from ironic.api.controllers.v1 import portgroup as portgroup_controller from ironic.api.controllers.v1 import portgroup as portgroup_controller
from ironic.drivers import base as drivers_base from ironic.drivers import base as drivers_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
ADMIN_TOKEN = '4562138218392831' ADMIN_TOKEN = '4562138218392831'
MEMBER_TOKEN = '4562138218392832' MEMBER_TOKEN = '4562138218392832'
@@ -91,7 +91,7 @@ def remove_internal(values, internal):
def node_post_data(**kw): def node_post_data(**kw):
node = utils.get_test_node(**kw) node = db_utils.get_test_node(**kw)
# These values are not part of the API object # These values are not part of the API object
node.pop('version') node.pop('version')
node.pop('conductor_affinity') node.pop('conductor_affinity')
@@ -113,7 +113,7 @@ def node_post_data(**kw):
def port_post_data(**kw): def port_post_data(**kw):
port = utils.get_test_port(**kw) port = db_utils.get_test_port(**kw)
# These values are not part of the API object # These values are not part of the API object
port.pop('version') port.pop('version')
port.pop('node_id') port.pop('node_id')
@@ -125,7 +125,7 @@ def port_post_data(**kw):
def chassis_post_data(**kw): def chassis_post_data(**kw):
chassis = utils.get_test_chassis(**kw) chassis = db_utils.get_test_chassis(**kw)
# version is not part of the API object # version is not part of the API object
chassis.pop('version') chassis.pop('version')
internal = chassis_controller.ChassisPatchType.internal_attrs() internal = chassis_controller.ChassisPatchType.internal_attrs()
@@ -136,14 +136,14 @@ def post_get_test_node(**kw):
# NOTE(lucasagomes): When creating a node via API (POST) # NOTE(lucasagomes): When creating a node via API (POST)
# we have to use chassis_uuid # we have to use chassis_uuid
node = node_post_data(**kw) node = node_post_data(**kw)
chassis = utils.get_test_chassis() chassis = db_utils.get_test_chassis()
node['chassis_uuid'] = kw.get('chassis_uuid', chassis['uuid']) node['chassis_uuid'] = kw.get('chassis_uuid', chassis['uuid'])
return node return node
def portgroup_post_data(**kw): def portgroup_post_data(**kw):
"""Return a Portgroup object without internal attributes.""" """Return a Portgroup object without internal attributes."""
portgroup = utils.get_test_portgroup(**kw) portgroup = db_utils.get_test_portgroup(**kw)
# These values are not part of the API object # These values are not part of the API object
portgroup.pop('version') portgroup.pop('version')
@@ -164,6 +164,6 @@ def portgroup_post_data(**kw):
def post_get_test_portgroup(**kw): def post_get_test_portgroup(**kw):
"""Return a Portgroup object with appropriate attributes.""" """Return a Portgroup object with appropriate attributes."""
portgroup = portgroup_post_data(**kw) portgroup = portgroup_post_data(**kw)
node = utils.get_test_node() node = db_utils.get_test_node()
portgroup['node_uuid'] = kw.get('node_uuid', node['uuid']) portgroup['node_uuid'] = kw.get('node_uuid', node['uuid'])
return portgroup return portgroup

View File

@@ -38,7 +38,7 @@ from ironic.objects import fields as obj_fields
from ironic.tests import base from ironic.tests import base
from ironic.tests.unit.api import base as test_api_base from ironic.tests.unit.api import base as test_api_base
from ironic.tests.unit.api import utils as apiutils from ironic.tests.unit.api import utils as apiutils
from ironic.tests.unit.db import utils as dbutils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
@@ -46,8 +46,8 @@ from ironic.tests.unit.objects import utils as obj_utils
# we have to use node_uuid and portgroup_uuid # we have to use node_uuid and portgroup_uuid
def post_get_test_port(**kw): def post_get_test_port(**kw):
port = apiutils.port_post_data(**kw) port = apiutils.port_post_data(**kw)
node = dbutils.get_test_node() node = db_utils.get_test_node()
portgroup = dbutils.get_test_portgroup() portgroup = db_utils.get_test_portgroup()
port['node_uuid'] = kw.get('node_uuid', node['uuid']) port['node_uuid'] = kw.get('node_uuid', node['uuid'])
port['portgroup_uuid'] = kw.get('portgroup_uuid', portgroup['uuid']) port['portgroup_uuid'] = kw.get('portgroup_uuid', portgroup['uuid'])
return port return port

View File

@@ -15,10 +15,10 @@ import mock
from oslo_config import cfg from oslo_config import cfg
from ironic.cmd import conductor from ironic.cmd import conductor
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
class ConductorStartTestCase(base.DbTestCase): class ConductorStartTestCase(db_base.DbTestCase):
@mock.patch.object(conductor, 'LOG', autospec=True) @mock.patch.object(conductor, 'LOG', autospec=True)
def test_warn_about_unsafe_shred_parameters_defaults(self, log_mock): def test_warn_about_unsafe_shred_parameters_defaults(self, log_mock):

View File

@@ -16,10 +16,10 @@
# under the License. # under the License.
from ironic.db import migration from ironic.db import migration
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
class DbSyncTestCase(base.DbTestCase): class DbSyncTestCase(db_base.DbTestCase):
def test_upgrade_and_version(self): def test_upgrade_and_version(self):
migration.upgrade('head') migration.upgrade('head')

View File

@@ -34,7 +34,7 @@ from ironic import objects
from ironic.objects import fields from ironic.objects import fields
from ironic.tests import base as tests_base from ironic.tests import base as tests_base
from ironic.tests.unit.conductor import mgr_utils from ironic.tests.unit.conductor import mgr_utils
from ironic.tests.unit.db import base as tests_db_base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
@@ -42,7 +42,7 @@ CONF = cfg.CONF
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class StartStopTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase): class StartStopTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_start_registers_conductor(self): def test_start_registers_conductor(self):
self.assertRaises(exception.ConductorNotFound, self.assertRaises(exception.ConductorNotFound,
objects.Conductor.get_by_hostname, objects.Conductor.get_by_hostname,
@@ -273,8 +273,7 @@ class StartStopTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase):
self._start_service() self._start_service()
class CheckInterfacesTestCase(mgr_utils.ServiceSetUpMixin, class CheckInterfacesTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
def test__check_enabled_interfaces_success(self): def test__check_enabled_interfaces_success(self):
base_manager._check_enabled_interfaces() base_manager._check_enabled_interfaces()
@@ -290,7 +289,7 @@ class CheckInterfacesTestCase(mgr_utils.ServiceSetUpMixin,
base_manager._check_enabled_interfaces() base_manager._check_enabled_interfaces()
class KeepAliveTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase): class KeepAliveTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test__conductor_service_record_keepalive(self): def test__conductor_service_record_keepalive(self):
self._start_service() self._start_service()
# avoid wasting time at the event.wait() # avoid wasting time at the event.wait()
@@ -345,7 +344,7 @@ class ManagerSpawnWorkerTestCase(tests_base.TestCase):
autospec=True) autospec=True)
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class RegisterInterfacesTestCase(mgr_utils.ServiceSetUpMixin, class RegisterInterfacesTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def setUp(self): def setUp(self):
super(RegisterInterfacesTestCase, self).setUp() super(RegisterInterfacesTestCase, self).setUp()
self._start_service() self._start_service()
@@ -417,8 +416,7 @@ class RegisterInterfacesTestCase(mgr_utils.ServiceSetUpMixin,
self.assertFalse(reg_mock.called) self.assertFalse(reg_mock.called)
class StartConsolesTestCase(mgr_utils.ServiceSetUpMixin, class StartConsolesTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch.object(notification_utils, 'emit_console_notification') @mock.patch.object(notification_utils, 'emit_console_notification')
def test__start_consoles(self, mock_notify): def test__start_consoles(self, mock_notify):
obj_utils.create_test_node(self.context, obj_utils.create_test_node(self.context,

View File

@@ -49,8 +49,8 @@ from ironic.objects import base as obj_base
from ironic.objects import fields as obj_fields from ironic.objects import fields as obj_fields
from ironic.tests import base as tests_base from ironic.tests import base as tests_base
from ironic.tests.unit.conductor import mgr_utils from ironic.tests.unit.conductor import mgr_utils
from ironic.tests.unit.db import base as tests_db_base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
CONF = cfg.CONF CONF = cfg.CONF
@@ -58,7 +58,7 @@ CONF = cfg.CONF
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class ChangeNodePowerStateTestCase(mgr_utils.ServiceSetUpMixin, class ChangeNodePowerStateTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test_change_node_power_state_power_on(self): def test_change_node_power_state_power_on(self):
# Test change_node_power_state including integration with # Test change_node_power_state including integration with
@@ -442,8 +442,7 @@ class ChangeNodePowerStateTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class CreateNodeTestCase(mgr_utils.ServiceSetUpMixin, class CreateNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
def test_create_node(self): def test_create_node(self):
node = obj_utils.get_test_node(self.context, driver='fake', node = obj_utils.get_test_node(self.context, driver='fake',
extra={'test': 'one'}) extra={'test': 'one'})
@@ -474,8 +473,7 @@ class CreateNodeTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class UpdateNodeTestCase(mgr_utils.ServiceSetUpMixin, class UpdateNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
def test_update_node(self): def test_update_node(self):
node = obj_utils.create_test_node(self.context, driver='fake', node = obj_utils.create_test_node(self.context, driver='fake',
extra={'test': 'one'}) extra={'test': 'one'})
@@ -619,8 +617,7 @@ class UpdateNodeTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class VendorPassthruTestCase(mgr_utils.ServiceSetUpMixin, class VendorPassthruTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch.object(task_manager.TaskManager, 'upgrade_lock') @mock.patch.object(task_manager.TaskManager, 'upgrade_lock')
@mock.patch.object(task_manager.TaskManager, 'spawn_after') @mock.patch.object(task_manager.TaskManager, 'spawn_after')
@@ -1070,7 +1067,7 @@ class VendorPassthruTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
@mock.patch.object(images, 'is_whole_disk_image') @mock.patch.object(images, 'is_whole_disk_image')
class ServiceDoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin, class ServiceDoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test_do_node_deploy_invalid_state(self, mock_iwdi): def test_do_node_deploy_invalid_state(self, mock_iwdi):
mock_iwdi.return_value = False mock_iwdi.return_value = False
self._start_service() self._start_service()
@@ -1340,7 +1337,7 @@ class ServiceDoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DoNodeDeployTearDownTestCase(mgr_utils.ServiceSetUpMixin, class DoNodeDeployTearDownTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.deploy') @mock.patch('ironic.drivers.modules.fake.FakeDeploy.deploy')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare') @mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare')
def test__do_node_deploy_driver_raises_prepare_error(self, mock_prepare, def test__do_node_deploy_driver_raises_prepare_error(self, mock_prepare,
@@ -1807,8 +1804,7 @@ class DoNodeDeployTearDownTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin, class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
def setUp(self): def setUp(self):
super(DoNodeCleanTestCase, self).setUp() super(DoNodeCleanTestCase, self).setUp()
self.config(automated_clean=True, group='conductor') self.config(automated_clean=True, group='conductor')
@@ -2663,8 +2659,7 @@ class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DoNodeVerifyTestCase(mgr_utils.ServiceSetUpMixin, class DoNodeVerifyTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch('ironic.objects.node.NodeCorrectedPowerStateNotification') @mock.patch('ironic.objects.node.NodeCorrectedPowerStateNotification')
@mock.patch('ironic.drivers.modules.fake.FakePower.get_power_state') @mock.patch('ironic.drivers.modules.fake.FakePower.get_power_state')
@mock.patch('ironic.drivers.modules.fake.FakePower.validate') @mock.patch('ironic.drivers.modules.fake.FakePower.validate')
@@ -2763,10 +2758,10 @@ class DoNodeVerifyTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class MiscTestCase(mgr_utils.ServiceSetUpMixin, mgr_utils.CommonMixIn, class MiscTestCase(mgr_utils.ServiceSetUpMixin, mgr_utils.CommonMixIn,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test__mapped_to_this_conductor(self): def test__mapped_to_this_conductor(self):
self._start_service() self._start_service()
n = utils.get_test_node() n = db_utils.get_test_node()
self.assertTrue(self.service._mapped_to_this_conductor(n['uuid'], self.assertTrue(self.service._mapped_to_this_conductor(n['uuid'],
'fake')) 'fake'))
self.assertFalse(self.service._mapped_to_this_conductor(n['uuid'], self.assertFalse(self.service._mapped_to_this_conductor(n['uuid'],
@@ -2855,7 +2850,7 @@ class MiscTestCase(mgr_utils.ServiceSetUpMixin, mgr_utils.CommonMixIn,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class ConsoleTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase): class ConsoleTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def test_set_console_mode_worker_pool_full(self): def test_set_console_mode_worker_pool_full(self):
node = obj_utils.create_test_node(self.context, driver='fake') node = obj_utils.create_test_node(self.context, driver='fake')
self._start_service() self._start_service()
@@ -3035,8 +3030,7 @@ class ConsoleTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase):
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DestroyNodeTestCase(mgr_utils.ServiceSetUpMixin, class DestroyNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
def test_destroy_node(self): def test_destroy_node(self):
self._start_service() self._start_service()
@@ -3157,8 +3151,7 @@ class DestroyNodeTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class CreatePortTestCase(mgr_utils.ServiceSetUpMixin, class CreatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch.object(conductor_utils, 'validate_port_physnet') @mock.patch.object(conductor_utils, 'validate_port_physnet')
def test_create_port(self, mock_validate): def test_create_port(self, mock_validate):
@@ -3229,8 +3222,7 @@ class CreatePortTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class UpdatePortTestCase(mgr_utils.ServiceSetUpMixin, class UpdatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch.object(conductor_utils, 'validate_port_physnet') @mock.patch.object(conductor_utils, 'validate_port_physnet')
@mock.patch.object(n_flat.FlatNetwork, 'port_changed', autospec=True) @mock.patch.object(n_flat.FlatNetwork, 'port_changed', autospec=True)
@@ -3752,7 +3744,7 @@ class UpdatePortTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True) @mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
class VifTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase): class VifTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
def setUp(self): def setUp(self):
super(VifTestCase, self).setUp() super(VifTestCase, self).setUp()
@@ -3859,8 +3851,7 @@ class VifTestCase(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase):
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch.object(n_flat.FlatNetwork, 'portgroup_changed', autospec=True) @mock.patch.object(n_flat.FlatNetwork, 'portgroup_changed', autospec=True)
@mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True) @mock.patch.object(n_flat.FlatNetwork, 'validate', autospec=True)
def test_update_portgroup(self, mock_val, mock_pc): def test_update_portgroup(self, mock_val, mock_pc):
@@ -4012,7 +4003,7 @@ class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class RaidTestCases(mgr_utils.ServiceSetUpMixin, tests_db_base.DbTestCase): class RaidTestCases(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
driver_name = 'fake' driver_name = 'fake'
raid_interface = None raid_interface = None
@@ -4118,7 +4109,7 @@ class RaidHardwareTypeTestCases(RaidTestCases):
@mock.patch.object(conductor_utils, 'node_power_action') @mock.patch.object(conductor_utils, 'node_power_action')
class ManagerDoSyncPowerStateTestCase(tests_db_base.DbTestCase): class ManagerDoSyncPowerStateTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ManagerDoSyncPowerStateTestCase, self).setUp() super(ManagerDoSyncPowerStateTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic') self.service = manager.ConductorManager('hostname', 'test-topic')
@@ -4402,7 +4393,7 @@ class ManagerDoSyncPowerStateTestCase(tests_db_base.DbTestCase):
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor') @mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list') @mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerSyncPowerStatesTestCase(mgr_utils.CommonMixIn, class ManagerSyncPowerStatesTestCase(mgr_utils.CommonMixIn,
tests_db_base.DbTestCase): db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ManagerSyncPowerStatesTestCase, self).setUp() super(ManagerSyncPowerStatesTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic') self.service = manager.ConductorManager('hostname', 'test-topic')
@@ -4632,7 +4623,7 @@ class ManagerSyncPowerStatesTestCase(mgr_utils.CommonMixIn,
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor') @mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list') @mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerCheckDeployTimeoutsTestCase(mgr_utils.CommonMixIn, class ManagerCheckDeployTimeoutsTestCase(mgr_utils.CommonMixIn,
tests_db_base.DbTestCase): db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ManagerCheckDeployTimeoutsTestCase, self).setUp() super(ManagerCheckDeployTimeoutsTestCase, self).setUp()
self.config(deploy_callback_timeout=300, group='conductor') self.config(deploy_callback_timeout=300, group='conductor')
@@ -4867,8 +4858,7 @@ class ManagerCheckDeployTimeoutsTestCase(mgr_utils.CommonMixIn,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class ManagerTestProperties(mgr_utils.ServiceSetUpMixin, class ManagerTestProperties(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ManagerTestProperties, self).setUp() super(ManagerTestProperties, self).setUp()
@@ -4980,7 +4970,7 @@ class ManagerTestProperties(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin, class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def _check_hardware_type_properties(self, hardware_type, expected): def _check_hardware_type_properties(self, hardware_type, expected):
self.config(enabled_hardware_types=[hardware_type]) self.config(enabled_hardware_types=[hardware_type])
@@ -4999,8 +4989,7 @@ class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin,
@mock.patch.object(task_manager, 'acquire') @mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor') @mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list') @mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerSyncLocalStateTestCase(mgr_utils.CommonMixIn, class ManagerSyncLocalStateTestCase(mgr_utils.CommonMixIn, db_base.DbTestCase):
tests_db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ManagerSyncLocalStateTestCase, self).setUp() super(ManagerSyncLocalStateTestCase, self).setUp()
@@ -5200,8 +5189,7 @@ class StoreConfigDriveTestCase(tests_base.TestCase):
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class NodeInspectHardware(mgr_utils.ServiceSetUpMixin, class NodeInspectHardware(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeInspect.inspect_hardware') @mock.patch('ironic.drivers.modules.fake.FakeInspect.inspect_hardware')
def test_inspect_hardware_ok(self, mock_inspect): def test_inspect_hardware_ok(self, mock_inspect):
@@ -5355,7 +5343,7 @@ class NodeInspectHardware(mgr_utils.ServiceSetUpMixin,
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor') @mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list') @mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerCheckInspectTimeoutsTestCase(mgr_utils.CommonMixIn, class ManagerCheckInspectTimeoutsTestCase(mgr_utils.CommonMixIn,
tests_db_base.DbTestCase): db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ManagerCheckInspectTimeoutsTestCase, self).setUp() super(ManagerCheckInspectTimeoutsTestCase, self).setUp()
self.config(inspect_timeout=300, group='conductor') self.config(inspect_timeout=300, group='conductor')
@@ -5576,8 +5564,7 @@ class ManagerCheckInspectTimeoutsTestCase(mgr_utils.CommonMixIn,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DestroyPortTestCase(mgr_utils.ServiceSetUpMixin, class DestroyPortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
def test_destroy_port(self): def test_destroy_port(self):
node = obj_utils.create_test_node(self.context, driver='fake') node = obj_utils.create_test_node(self.context, driver='fake')
@@ -5600,7 +5587,7 @@ class DestroyPortTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DestroyPortgroupTestCase(mgr_utils.ServiceSetUpMixin, class DestroyPortgroupTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test_destroy_portgroup(self): def test_destroy_portgroup(self):
node = obj_utils.create_test_node(self.context, driver='fake') node = obj_utils.create_test_node(self.context, driver='fake')
portgroup = obj_utils.create_test_portgroup(self.context, portgroup = obj_utils.create_test_portgroup(self.context,
@@ -5625,7 +5612,7 @@ class DestroyPortgroupTestCase(mgr_utils.ServiceSetUpMixin,
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor') @mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_offline_conductors') @mock.patch.object(dbapi.IMPL, 'get_offline_conductors')
class ManagerCheckDeployingStatusTestCase(mgr_utils.ServiceSetUpMixin, class ManagerCheckDeployingStatusTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ManagerCheckDeployingStatusTestCase, self).setUp() super(ManagerCheckDeployingStatusTestCase, self).setUp()
self._start_service() self._start_service()
@@ -5715,7 +5702,7 @@ class ManagerCheckDeployingStatusTestCase(mgr_utils.ServiceSetUpMixin,
err_handler=conductor_utils.provisioning_error_handler) err_handler=conductor_utils.provisioning_error_handler)
class TestIndirectionApiConductor(tests_db_base.DbTestCase): class TestIndirectionApiConductor(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(TestIndirectionApiConductor, self).setUp() super(TestIndirectionApiConductor, self).setUp()
@@ -5818,8 +5805,7 @@ class TestIndirectionApiConductor(tests_db_base.DbTestCase):
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DoNodeTakeOverTestCase(mgr_utils.ServiceSetUpMixin, class DoNodeTakeOverTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
tests_db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console') @mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console')
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.take_over') @mock.patch('ironic.drivers.modules.fake.FakeDeploy.take_over')
@@ -5893,9 +5879,7 @@ class DoNodeTakeOverTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DoNodeAdoptionTestCase( class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakePower.validate') @mock.patch('ironic.drivers.modules.fake.FakePower.validate')
@mock.patch('ironic.drivers.modules.fake.FakeBoot.validate') @mock.patch('ironic.drivers.modules.fake.FakeBoot.validate')
@@ -6055,7 +6039,7 @@ class DoNodeAdoptionTestCase(
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DestroyVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin, class DestroyVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test_destroy_volume_connector(self): def test_destroy_volume_connector(self):
node = obj_utils.create_test_node(self.context, driver='fake') node = obj_utils.create_test_node(self.context, driver='fake')
@@ -6083,7 +6067,7 @@ class DestroyVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class UpdateVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin, class UpdateVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test_update_volume_connector(self): def test_update_volume_connector(self):
node = obj_utils.create_test_node(self.context, driver='fake') node = obj_utils.create_test_node(self.context, driver='fake')
@@ -6147,7 +6131,7 @@ class UpdateVolumeConnectorTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class DestroyVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin, class DestroyVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test_destroy_volume_target(self): def test_destroy_volume_target(self):
node = obj_utils.create_test_node(self.context, driver='fake') node = obj_utils.create_test_node(self.context, driver='fake')
@@ -6198,7 +6182,7 @@ class DestroyVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin,
@mgr_utils.mock_record_keepalive @mgr_utils.mock_record_keepalive
class UpdateVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin, class UpdateVolumeTargetTestCase(mgr_utils.ServiceSetUpMixin,
tests_db_base.DbTestCase): db_base.DbTestCase):
def test_update_volume_target(self): def test_update_volume_target(self):
node = obj_utils.create_test_node(self.context, driver='fake') node = obj_utils.create_test_node(self.context, driver='fake')

View File

@@ -26,11 +26,11 @@ from ironic.objects import fields
from ironic.objects import node as node_objects from ironic.objects import node as node_objects
from ironic.objects import notification from ironic.objects import notification
from ironic.tests import base as tests_base from ironic.tests import base as tests_base
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
class TestNotificationUtils(base.DbTestCase): class TestNotificationUtils(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(TestNotificationUtils, self).setUp() super(TestNotificationUtils, self).setUp()
self.config(notification_level='debug') self.config(notification_level='debug')

View File

@@ -33,8 +33,8 @@ from ironic.conductor import manager as conductor_manager
from ironic.conductor import rpcapi as conductor_rpcapi from ironic.conductor import rpcapi as conductor_rpcapi
from ironic import objects from ironic import objects
from ironic.tests import base as tests_base from ironic.tests import base as tests_base
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils as dbutils from ironic.tests.unit.db import utils as db_utils
CONF = cfg.CONF CONF = cfg.CONF
@@ -62,14 +62,14 @@ class ConductorRPCAPITestCase(tests_base.TestCase):
self.assertEqual('3', mock_get_client.call_args[1]['version_cap']) self.assertEqual('3', mock_get_client.call_args[1]['version_cap'])
class RPCAPITestCase(base.DbTestCase): class RPCAPITestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(RPCAPITestCase, self).setUp() super(RPCAPITestCase, self).setUp()
self.fake_node = dbutils.get_test_node(driver='fake-driver') self.fake_node = db_utils.get_test_node(driver='fake-driver')
self.fake_node_obj = objects.Node._from_db_object( self.fake_node_obj = objects.Node._from_db_object(
self.context, objects.Node(), self.fake_node) self.context, objects.Node(), self.fake_node)
self.fake_portgroup = dbutils.get_test_portgroup() self.fake_portgroup = db_utils.get_test_portgroup()
def test_serialized_instance_has_uuid(self): def test_serialized_instance_has_uuid(self):
self.assertIn('uuid', self.fake_node) self.assertIn('uuid', self.fake_node)
@@ -266,14 +266,14 @@ class RPCAPITestCase(base.DbTestCase):
enabled=True) enabled=True)
def test_create_port(self): def test_create_port(self):
fake_port = dbutils.get_test_port() fake_port = db_utils.get_test_port()
self._test_rpcapi('create_port', self._test_rpcapi('create_port',
'call', 'call',
version='1.41', version='1.41',
port_obj=fake_port) port_obj=fake_port)
def test_update_port(self): def test_update_port(self):
fake_port = dbutils.get_test_port() fake_port = db_utils.get_test_port()
self._test_rpcapi('update_port', self._test_rpcapi('update_port',
'call', 'call',
version='1.13', version='1.13',
@@ -431,14 +431,14 @@ class RPCAPITestCase(base.DbTestCase):
version='1.34') version='1.34')
def test_destroy_volume_connector(self): def test_destroy_volume_connector(self):
fake_volume_connector = dbutils.get_test_volume_connector() fake_volume_connector = db_utils.get_test_volume_connector()
self._test_rpcapi('destroy_volume_connector', self._test_rpcapi('destroy_volume_connector',
'call', 'call',
version='1.35', version='1.35',
connector=fake_volume_connector) connector=fake_volume_connector)
def test_update_volume_connector(self): def test_update_volume_connector(self):
fake_volume_connector = dbutils.get_test_volume_connector() fake_volume_connector = db_utils.get_test_volume_connector()
self._test_rpcapi('update_volume_connector', self._test_rpcapi('update_volume_connector',
'call', 'call',
version='1.35', version='1.35',
@@ -451,14 +451,14 @@ class RPCAPITestCase(base.DbTestCase):
node_obj=self.fake_node) node_obj=self.fake_node)
def test_destroy_volume_target(self): def test_destroy_volume_target(self):
fake_volume_target = dbutils.get_test_volume_target() fake_volume_target = db_utils.get_test_volume_target()
self._test_rpcapi('destroy_volume_target', self._test_rpcapi('destroy_volume_target',
'call', 'call',
version='1.37', version='1.37',
target=fake_volume_target) target=fake_volume_target)
def test_update_volume_target(self): def test_update_volume_target(self):
fake_volume_target = dbutils.get_test_volume_target() fake_volume_target = db_utils.get_test_volume_target()
self._test_rpcapi('update_volume_target', self._test_rpcapi('update_volume_target',
'call', 'call',
version='1.37', version='1.37',

View File

@@ -30,7 +30,7 @@ from ironic.conductor import task_manager
from ironic import objects from ironic import objects
from ironic.objects import fields from ironic.objects import fields
from ironic.tests import base as tests_base from ironic.tests import base as tests_base
from ironic.tests.unit.db import base as tests_db_base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
@@ -42,7 +42,7 @@ from ironic.tests.unit.objects import utils as obj_utils
@mock.patch.object(objects.Portgroup, 'list_by_node_id') @mock.patch.object(objects.Portgroup, 'list_by_node_id')
@mock.patch.object(objects.VolumeConnector, 'list_by_node_id') @mock.patch.object(objects.VolumeConnector, 'list_by_node_id')
@mock.patch.object(objects.VolumeTarget, 'list_by_node_id') @mock.patch.object(objects.VolumeTarget, 'list_by_node_id')
class TaskManagerTestCase(tests_db_base.DbTestCase): class TaskManagerTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(TaskManagerTestCase, self).setUp() super(TaskManagerTestCase, self).setUp()
self.host = 'test-host' self.host = 'test-host'

View File

@@ -24,19 +24,19 @@ from ironic import objects
from ironic.objects import fields as obj_fields from ironic.objects import fields as obj_fields
from ironic.tests import base as tests_base from ironic.tests import base as tests_base
from ironic.tests.unit.conductor import mgr_utils from ironic.tests.unit.conductor import mgr_utils
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
CONF = cfg.CONF CONF = cfg.CONF
class NodeSetBootDeviceTestCase(base.DbTestCase): class NodeSetBootDeviceTestCase(db_base.DbTestCase):
def test_node_set_boot_device_non_existent_device(self): def test_node_set_boot_device_non_existent_device(self):
mgr_utils.mock_the_extension_manager(driver="fake_ipmitool") mgr_utils.mock_the_extension_manager(driver="fake_ipmitool")
self.driver = driver_factory.get_driver("fake_ipmitool") self.driver = driver_factory.get_driver("fake_ipmitool")
ipmi_info = utils.get_test_ipmi_info() ipmi_info = db_utils.get_test_ipmi_info()
node = obj_utils.create_test_node(self.context, node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid(), uuid=uuidutils.generate_uuid(),
driver='fake_ipmitool', driver='fake_ipmitool',
@@ -50,7 +50,7 @@ class NodeSetBootDeviceTestCase(base.DbTestCase):
def test_node_set_boot_device_valid(self): def test_node_set_boot_device_valid(self):
mgr_utils.mock_the_extension_manager(driver="fake_ipmitool") mgr_utils.mock_the_extension_manager(driver="fake_ipmitool")
self.driver = driver_factory.get_driver("fake_ipmitool") self.driver = driver_factory.get_driver("fake_ipmitool")
ipmi_info = utils.get_test_ipmi_info() ipmi_info = db_utils.get_test_ipmi_info()
node = obj_utils.create_test_node(self.context, node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid(), uuid=uuidutils.generate_uuid(),
driver='fake_ipmitool', driver='fake_ipmitool',
@@ -68,7 +68,7 @@ class NodeSetBootDeviceTestCase(base.DbTestCase):
def test_node_set_boot_device_adopting(self): def test_node_set_boot_device_adopting(self):
mgr_utils.mock_the_extension_manager(driver="fake_ipmitool") mgr_utils.mock_the_extension_manager(driver="fake_ipmitool")
self.driver = driver_factory.get_driver("fake_ipmitool") self.driver = driver_factory.get_driver("fake_ipmitool")
ipmi_info = utils.get_test_ipmi_info() ipmi_info = db_utils.get_test_ipmi_info()
node = obj_utils.create_test_node(self.context, node = obj_utils.create_test_node(self.context,
uuid=uuidutils.generate_uuid(), uuid=uuidutils.generate_uuid(),
driver='fake_ipmitool', driver='fake_ipmitool',
@@ -83,7 +83,7 @@ class NodeSetBootDeviceTestCase(base.DbTestCase):
self.assertFalse(mock_sbd.called) self.assertFalse(mock_sbd.called)
class NodePowerActionTestCase(base.DbTestCase): class NodePowerActionTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(NodePowerActionTestCase, self).setUp() super(NodePowerActionTestCase, self).setUp()
mgr_utils.mock_the_extension_manager() mgr_utils.mock_the_extension_manager()
@@ -559,7 +559,7 @@ class NodePowerActionTestCase(base.DbTestCase):
self.assertIsNone(node['last_error']) self.assertIsNone(node['last_error'])
class NodeSoftPowerActionTestCase(base.DbTestCase): class NodeSoftPowerActionTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(NodeSoftPowerActionTestCase, self).setUp() super(NodeSoftPowerActionTestCase, self).setUp()
@@ -715,7 +715,7 @@ class CleanupAfterTimeoutTestCase(tests_base.TestCase):
self.assertIn('Deploy timed out', self.node.last_error) self.assertIn('Deploy timed out', self.node.last_error)
class NodeCleaningStepsTestCase(base.DbTestCase): class NodeCleaningStepsTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(NodeCleaningStepsTestCase, self).setUp() super(NodeCleaningStepsTestCase, self).setUp()
mgr_utils.mock_the_extension_manager() mgr_utils.mock_the_extension_manager()
@@ -1077,7 +1077,7 @@ class ErrorHandlersTestCase(tests_base.TestCase):
self.assertFalse(log_mock.warning.called) self.assertFalse(log_mock.warning.called)
class ValidatePortPhysnetTestCase(base.DbTestCase): class ValidatePortPhysnetTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(ValidatePortPhysnetTestCase, self).setUp() super(ValidatePortPhysnetTestCase, self).setUp()
@@ -1187,11 +1187,11 @@ class ValidatePortPhysnetTestCase(base.DbTestCase):
# Prepare the port on which we are performing the operation. # Prepare the port on which we are performing the operation.
if operation == 'create': if operation == 'create':
# NOTE(mgoddard): We use utils here rather than obj_utils as it # NOTE(mgoddard): We use db_utils here rather than obj_utils as it
# allows us to create a Port without a physical_network field, more # allows us to create a Port without a physical_network field, more
# closely matching what happens during creation of a port when a # closely matching what happens during creation of a port when a
# physical_network is not specified. # physical_network is not specified.
port = utils.get_test_port( port = db_utils.get_test_port(
node_id=self.node.id, portgroup_id=portgroup.id, node_id=self.node.id, portgroup_id=portgroup.id,
address=next(macs), uuid=uuidutils.generate_uuid(), address=next(macs), uuid=uuidutils.generate_uuid(),
physical_network=new_physnet) physical_network=new_physnet)

View File

@@ -25,7 +25,7 @@ from ironic.conductor import task_manager
from ironic.drivers.modules.drac import common as drac_common from ironic.drivers.modules.drac import common as drac_common
from ironic.drivers.modules.drac import power as drac_power from ironic.drivers.modules.drac import power as drac_power
from ironic.tests.unit.conductor import mgr_utils from ironic.tests.unit.conductor import mgr_utils
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils as db_utils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
@@ -34,7 +34,7 @@ INFO_DICT = db_utils.get_test_drac_info()
@mock.patch.object(drac_common, 'get_drac_client', spec_set=True, @mock.patch.object(drac_common, 'get_drac_client', spec_set=True,
autospec=True) autospec=True)
class DracPowerTestCase(base.DbTestCase): class DracPowerTestCase(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(DracPowerTestCase, self).setUp() super(DracPowerTestCase, self).setUp()

View File

@@ -21,16 +21,16 @@ from testtools import matchers
from ironic.common import exception from ironic.common import exception
from ironic import objects from ironic import objects
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
class TestChassisObject(base.DbTestCase, obj_utils.SchemasTestMixIn): class TestChassisObject(db_base.DbTestCase, obj_utils.SchemasTestMixIn):
def setUp(self): def setUp(self):
super(TestChassisObject, self).setUp() super(TestChassisObject, self).setUp()
self.fake_chassis = utils.get_test_chassis() self.fake_chassis = db_utils.get_test_chassis()
def test_get_by_id(self): def test_get_by_id(self):
chassis_id = self.fake_chassis['id'] chassis_id = self.fake_chassis['id']
@@ -62,7 +62,7 @@ class TestChassisObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
chassis = objects.Chassis(self.context, **self.fake_chassis) chassis = objects.Chassis(self.context, **self.fake_chassis)
with mock.patch.object(self.dbapi, 'create_chassis', with mock.patch.object(self.dbapi, 'create_chassis',
autospec=True) as mock_create_chassis: autospec=True) as mock_create_chassis:
mock_create_chassis.return_value = utils.get_test_chassis() mock_create_chassis.return_value = db_utils.get_test_chassis()
chassis.create() chassis.create()
@@ -79,7 +79,8 @@ class TestChassisObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
with mock.patch.object(self.dbapi, 'update_chassis', with mock.patch.object(self.dbapi, 'update_chassis',
autospec=True) as mock_update_chassis: autospec=True) as mock_update_chassis:
mock_update_chassis.return_value = ( mock_update_chassis.return_value = (
utils.get_test_chassis(extra=extra, updated_at=test_time)) db_utils.get_test_chassis(extra=extra,
updated_at=test_time))
c = objects.Chassis.get_by_uuid(self.context, uuid) c = objects.Chassis.get_by_uuid(self.context, uuid)
c.extra = extra c.extra = extra
c.save() c.save()
@@ -114,7 +115,7 @@ class TestChassisObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
# This test will avoid update_chassis() regressions in future. # This test will avoid update_chassis() regressions in future.
def test_save_after_refresh(self): def test_save_after_refresh(self):
# Ensure that it's possible to do object.save() after object.refresh() # Ensure that it's possible to do object.save() after object.refresh()
db_chassis = utils.create_test_chassis() db_chassis = db_utils.create_test_chassis()
c = objects.Chassis.get_by_uuid(self.context, db_chassis.uuid) c = objects.Chassis.get_by_uuid(self.context, db_chassis.uuid)
c_copy = objects.Chassis.get_by_uuid(self.context, db_chassis.uuid) c_copy = objects.Chassis.get_by_uuid(self.context, db_chassis.uuid)
c.description = 'b240' c.description = 'b240'

View File

@@ -21,16 +21,16 @@ from oslo_utils import timeutils
from ironic import objects from ironic import objects
from ironic.objects import fields from ironic.objects import fields
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
class TestConductorObject(base.DbTestCase): class TestConductorObject(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(TestConductorObject, self).setUp() super(TestConductorObject, self).setUp()
self.fake_conductor = ( self.fake_conductor = (
utils.get_test_conductor(updated_at=timeutils.utcnow())) db_utils.get_test_conductor(updated_at=timeutils.utcnow()))
def test_load(self): def test_load(self):
host = self.fake_conductor['hostname'] host = self.fake_conductor['hostname']

View File

@@ -21,17 +21,17 @@ from testtools import matchers
from ironic.common import context from ironic.common import context
from ironic.common import exception from ironic.common import exception
from ironic import objects from ironic import objects
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
class TestNodeObject(base.DbTestCase, obj_utils.SchemasTestMixIn): class TestNodeObject(db_base.DbTestCase, obj_utils.SchemasTestMixIn):
def setUp(self): def setUp(self):
super(TestNodeObject, self).setUp() super(TestNodeObject, self).setUp()
self.ctxt = context.get_admin_context() self.ctxt = context.get_admin_context()
self.fake_node = utils.get_test_node() self.fake_node = db_utils.get_test_node()
self.node = obj_utils.get_test_node(self.ctxt, **self.fake_node) self.node = obj_utils.get_test_node(self.ctxt, **self.fake_node)
def test_get_by_id(self): def test_get_by_id(self):
@@ -79,7 +79,7 @@ class TestNodeObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
mock_get_node.return_value = self.fake_node mock_get_node.return_value = self.fake_node
with mock.patch.object(self.dbapi, 'update_node', with mock.patch.object(self.dbapi, 'update_node',
autospec=True) as mock_update_node: autospec=True) as mock_update_node:
mock_update_node.return_value = utils.get_test_node( mock_update_node.return_value = db_utils.get_test_node(
properties={"fake": "property"}, driver='fake-driver', properties={"fake": "property"}, driver='fake-driver',
driver_internal_info={}, updated_at=test_time) driver_internal_info={}, updated_at=test_time)
n = objects.Node.get(self.context, uuid) n = objects.Node.get(self.context, uuid)
@@ -110,7 +110,7 @@ class TestNodeObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
with mock.patch.object(self.dbapi, 'update_node', with mock.patch.object(self.dbapi, 'update_node',
autospec=True) as mock_update_node: autospec=True) as mock_update_node:
mock_update_node.return_value = ( mock_update_node.return_value = (
utils.get_test_node(extra=extra, updated_at=test_time)) db_utils.get_test_node(extra=extra, updated_at=test_time))
n = objects.Node.get(self.context, uuid) n = objects.Node.get(self.context, uuid)
self.assertEqual({"private_state": "secret value"}, self.assertEqual({"private_state": "secret value"},
n.driver_internal_info) n.driver_internal_info)
@@ -148,7 +148,7 @@ class TestNodeObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
def test_save_after_refresh(self): def test_save_after_refresh(self):
# Ensure that it's possible to do object.save() after object.refresh() # Ensure that it's possible to do object.save() after object.refresh()
db_node = utils.create_test_node() db_node = db_utils.create_test_node()
n = objects.Node.get_by_uuid(self.context, db_node.uuid) n = objects.Node.get_by_uuid(self.context, db_node.uuid)
n_copy = objects.Node.get_by_uuid(self.context, db_node.uuid) n_copy = objects.Node.get_by_uuid(self.context, db_node.uuid)
n.name = 'b240' n.name = 'b240'
@@ -218,7 +218,7 @@ class TestNodeObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
node = objects.Node(self.context, **self.fake_node) node = objects.Node(self.context, **self.fake_node)
with mock.patch.object(self.dbapi, 'create_node', with mock.patch.object(self.dbapi, 'create_node',
autospec=True) as mock_create_node: autospec=True) as mock_create_node:
mock_create_node.return_value = utils.get_test_node() mock_create_node.return_value = db_utils.get_test_node()
node.create() node.create()

View File

@@ -20,16 +20,16 @@ from testtools import matchers
from ironic.common import exception from ironic.common import exception
from ironic import objects from ironic import objects
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
class TestPortObject(base.DbTestCase, obj_utils.SchemasTestMixIn): class TestPortObject(db_base.DbTestCase, obj_utils.SchemasTestMixIn):
def setUp(self): def setUp(self):
super(TestPortObject, self).setUp() super(TestPortObject, self).setUp()
self.fake_port = utils.get_test_port() self.fake_port = db_utils.get_test_port()
def test_get_by_id(self): def test_get_by_id(self):
port_id = self.fake_port['id'] port_id = self.fake_port['id']
@@ -72,7 +72,7 @@ class TestPortObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
port = objects.Port(self.context, **self.fake_port) port = objects.Port(self.context, **self.fake_port)
with mock.patch.object(self.dbapi, 'create_port', with mock.patch.object(self.dbapi, 'create_port',
autospec=True) as mock_create_port: autospec=True) as mock_create_port:
mock_create_port.return_value = utils.get_test_port() mock_create_port.return_value = db_utils.get_test_port()
port.create() port.create()
@@ -89,7 +89,8 @@ class TestPortObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
with mock.patch.object(self.dbapi, 'update_port', with mock.patch.object(self.dbapi, 'update_port',
autospec=True) as mock_update_port: autospec=True) as mock_update_port:
mock_update_port.return_value = ( mock_update_port.return_value = (
utils.get_test_port(address=address, updated_at=test_time)) db_utils.get_test_port(address=address,
updated_at=test_time))
p = objects.Port.get_by_uuid(self.context, uuid) p = objects.Port.get_by_uuid(self.context, uuid)
p.address = address p.address = address
p.save() p.save()
@@ -105,7 +106,7 @@ class TestPortObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
def test_refresh(self): def test_refresh(self):
uuid = self.fake_port['uuid'] uuid = self.fake_port['uuid']
returns = [self.fake_port, returns = [self.fake_port,
utils.get_test_port(address="c3:54:00:cf:2d:40")] db_utils.get_test_port(address="c3:54:00:cf:2d:40")]
expected = [mock.call(uuid), mock.call(uuid)] expected = [mock.call(uuid), mock.call(uuid)]
with mock.patch.object(self.dbapi, 'get_port_by_uuid', with mock.patch.object(self.dbapi, 'get_port_by_uuid',
side_effect=returns, side_effect=returns,
@@ -121,8 +122,8 @@ class TestPortObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
def test_save_after_refresh(self): def test_save_after_refresh(self):
# Ensure that it's possible to do object.save() after object.refresh() # Ensure that it's possible to do object.save() after object.refresh()
address = "b2:54:00:cf:2d:40" address = "b2:54:00:cf:2d:40"
db_node = utils.create_test_node() db_node = db_utils.create_test_node()
db_port = utils.create_test_port(node_id=db_node.id) db_port = db_utils.create_test_port(node_id=db_node.id)
p = objects.Port.get_by_uuid(self.context, db_port.uuid) p = objects.Port.get_by_uuid(self.context, db_port.uuid)
p_copy = objects.Port.get_by_uuid(self.context, db_port.uuid) p_copy = objects.Port.get_by_uuid(self.context, db_port.uuid)
p.address = address p.address = address

View File

@@ -17,16 +17,16 @@ from testtools import matchers
from ironic.common import exception from ironic.common import exception
from ironic import objects from ironic import objects
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.objects import utils as obj_utils from ironic.tests.unit.objects import utils as obj_utils
class TestPortgroupObject(base.DbTestCase, obj_utils.SchemasTestMixIn): class TestPortgroupObject(db_base.DbTestCase, obj_utils.SchemasTestMixIn):
def setUp(self): def setUp(self):
super(TestPortgroupObject, self).setUp() super(TestPortgroupObject, self).setUp()
self.fake_portgroup = utils.get_test_portgroup() self.fake_portgroup = db_utils.get_test_portgroup()
def test_get_by_id(self): def test_get_by_id(self):
portgroup_id = self.fake_portgroup['id'] portgroup_id = self.fake_portgroup['id']
@@ -81,7 +81,7 @@ class TestPortgroupObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
portgroup = objects.Portgroup(self.context, **self.fake_portgroup) portgroup = objects.Portgroup(self.context, **self.fake_portgroup)
with mock.patch.object(self.dbapi, 'create_portgroup', with mock.patch.object(self.dbapi, 'create_portgroup',
autospec=True) as mock_create_portgroup: autospec=True) as mock_create_portgroup:
mock_create_portgroup.return_value = utils.get_test_portgroup() mock_create_portgroup.return_value = db_utils.get_test_portgroup()
portgroup.create() portgroup.create()
@@ -98,8 +98,8 @@ class TestPortgroupObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
with mock.patch.object(self.dbapi, 'update_portgroup', with mock.patch.object(self.dbapi, 'update_portgroup',
autospec=True) as mock_update_portgroup: autospec=True) as mock_update_portgroup:
mock_update_portgroup.return_value = ( mock_update_portgroup.return_value = (
utils.get_test_portgroup(address=address, db_utils.get_test_portgroup(address=address,
updated_at=test_time)) updated_at=test_time))
p = objects.Portgroup.get_by_uuid(self.context, uuid) p = objects.Portgroup.get_by_uuid(self.context, uuid)
p.address = address p.address = address
p.save() p.save()
@@ -115,7 +115,7 @@ class TestPortgroupObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
def test_refresh(self): def test_refresh(self):
uuid = self.fake_portgroup['uuid'] uuid = self.fake_portgroup['uuid']
returns = [self.fake_portgroup, returns = [self.fake_portgroup,
utils.get_test_portgroup(address="c3:54:00:cf:2d:40")] db_utils.get_test_portgroup(address="c3:54:00:cf:2d:40")]
expected = [mock.call(uuid), mock.call(uuid)] expected = [mock.call(uuid), mock.call(uuid)]
with mock.patch.object(self.dbapi, 'get_portgroup_by_uuid', with mock.patch.object(self.dbapi, 'get_portgroup_by_uuid',
side_effect=returns, side_effect=returns,
@@ -131,8 +131,8 @@ class TestPortgroupObject(base.DbTestCase, obj_utils.SchemasTestMixIn):
def test_save_after_refresh(self): def test_save_after_refresh(self):
# Ensure that it's possible to do object.save() after object.refresh() # Ensure that it's possible to do object.save() after object.refresh()
address = "b2:54:00:cf:2d:40" address = "b2:54:00:cf:2d:40"
db_node = utils.create_test_node() db_node = db_utils.create_test_node()
db_portgroup = utils.create_test_portgroup(node_id=db_node.id) db_portgroup = db_utils.create_test_portgroup(node_id=db_node.id)
p = objects.Portgroup.get_by_uuid(self.context, db_portgroup.uuid) p = objects.Portgroup.get_by_uuid(self.context, db_portgroup.uuid)
p_copy = objects.Portgroup.get_by_uuid(self.context, db_portgroup.uuid) p_copy = objects.Portgroup.get_by_uuid(self.context, db_portgroup.uuid)
p.address = address p.address = address

View File

@@ -19,15 +19,15 @@ from testtools.matchers import HasLength
from ironic.common import exception from ironic.common import exception
from ironic import objects from ironic import objects
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
class TestVolumeConnectorObject(base.DbTestCase): class TestVolumeConnectorObject(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(TestVolumeConnectorObject, self).setUp() super(TestVolumeConnectorObject, self).setUp()
self.volume_connector_dict = utils.get_test_volume_connector() self.volume_connector_dict = db_utils.get_test_volume_connector()
@mock.patch('ironic.objects.VolumeConnector.get_by_uuid') @mock.patch('ironic.objects.VolumeConnector.get_by_uuid')
@mock.patch('ironic.objects.VolumeConnector.get_by_id') @mock.patch('ironic.objects.VolumeConnector.get_by_id')
@@ -145,8 +145,8 @@ class TestVolumeConnectorObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'update_volume_connector', with mock.patch.object(self.dbapi, 'update_volume_connector',
autospec=True) as mock_update_connector: autospec=True) as mock_update_connector:
mock_update_connector.return_value = ( mock_update_connector.return_value = (
utils.get_test_volume_connector(connector_id=connector_id, db_utils.get_test_volume_connector(
updated_at=test_time)) connector_id=connector_id, updated_at=test_time))
c = objects.VolumeConnector.get_by_uuid(self.context, uuid) c = objects.VolumeConnector.get_by_uuid(self.context, uuid)
c.connector_id = connector_id c.connector_id = connector_id
c.save() c.save()
@@ -164,7 +164,7 @@ class TestVolumeConnectorObject(base.DbTestCase):
uuid = self.volume_connector_dict['uuid'] uuid = self.volume_connector_dict['uuid']
old_connector_id = self.volume_connector_dict['connector_id'] old_connector_id = self.volume_connector_dict['connector_id']
returns = [self.volume_connector_dict, returns = [self.volume_connector_dict,
utils.get_test_volume_connector( db_utils.get_test_volume_connector(
connector_id="new_connector_id")] connector_id="new_connector_id")]
expected = [mock.call(uuid), mock.call(uuid)] expected = [mock.call(uuid), mock.call(uuid)]
with mock.patch.object(self.dbapi, 'get_volume_connector_by_uuid', with mock.patch.object(self.dbapi, 'get_volume_connector_by_uuid',
@@ -181,7 +181,7 @@ class TestVolumeConnectorObject(base.DbTestCase):
def test_save_after_refresh(self): def test_save_after_refresh(self):
# Ensure that it's possible to do object.save() after object.refresh() # Ensure that it's possible to do object.save() after object.refresh()
db_volume_connector = utils.create_test_volume_connector() db_volume_connector = db_utils.create_test_volume_connector()
vc = objects.VolumeConnector.get_by_uuid(self.context, vc = objects.VolumeConnector.get_by_uuid(self.context,
db_volume_connector.uuid) db_volume_connector.uuid)

View File

@@ -19,15 +19,15 @@ from testtools.matchers import HasLength
from ironic.common import exception from ironic.common import exception
from ironic import objects from ironic import objects
from ironic.tests.unit.db import base from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.db import utils from ironic.tests.unit.db import utils as db_utils
class TestVolumeTargetObject(base.DbTestCase): class TestVolumeTargetObject(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(TestVolumeTargetObject, self).setUp() super(TestVolumeTargetObject, self).setUp()
self.volume_target_dict = utils.get_test_volume_target() self.volume_target_dict = db_utils.get_test_volume_target()
@mock.patch('ironic.objects.VolumeTarget.get_by_uuid') @mock.patch('ironic.objects.VolumeTarget.get_by_uuid')
@mock.patch('ironic.objects.VolumeTarget.get_by_id') @mock.patch('ironic.objects.VolumeTarget.get_by_id')
@@ -157,8 +157,8 @@ class TestVolumeTargetObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'update_volume_target', with mock.patch.object(self.dbapi, 'update_volume_target',
autospec=True) as mock_update_target: autospec=True) as mock_update_target:
mock_update_target.return_value = ( mock_update_target.return_value = (
utils.get_test_volume_target(boot_index=boot_index, db_utils.get_test_volume_target(boot_index=boot_index,
updated_at=test_time)) updated_at=test_time))
target = objects.VolumeTarget.get_by_uuid(self.context, uuid) target = objects.VolumeTarget.get_by_uuid(self.context, uuid)
target.boot_index = boot_index target.boot_index = boot_index
target.save() target.save()
@@ -176,7 +176,7 @@ class TestVolumeTargetObject(base.DbTestCase):
uuid = self.volume_target_dict['uuid'] uuid = self.volume_target_dict['uuid']
old_boot_index = self.volume_target_dict['boot_index'] old_boot_index = self.volume_target_dict['boot_index']
returns = [self.volume_target_dict, returns = [self.volume_target_dict,
utils.get_test_volume_target(boot_index=100)] db_utils.get_test_volume_target(boot_index=100)]
expected = [mock.call(uuid), mock.call(uuid)] expected = [mock.call(uuid), mock.call(uuid)]
with mock.patch.object(self.dbapi, 'get_volume_target_by_uuid', with mock.patch.object(self.dbapi, 'get_volume_target_by_uuid',
side_effect=returns, side_effect=returns,
@@ -192,7 +192,7 @@ class TestVolumeTargetObject(base.DbTestCase):
def test_save_after_refresh(self): def test_save_after_refresh(self):
# Ensure that it's possible to do object.save() after object.refresh() # Ensure that it's possible to do object.save() after object.refresh()
db_volume_target = utils.create_test_volume_target() db_volume_target = db_utils.create_test_volume_target()
vt = objects.VolumeTarget.get_by_uuid(self.context, vt = objects.VolumeTarget.get_by_uuid(self.context,
db_volume_target.uuid) db_volume_target.uuid)