test_commit

Change-Id: I24e004ad4bdbaf53b71bcd7827e0227528b78b0e
Signed-off-by: Swapna Gorre <swapna.gorre@windriver.com>
This commit is contained in:
Swapna Gorre 2024-04-30 09:55:27 -04:00
parent e2ed8a9c42
commit 5bfd4ecfac
3 changed files with 136 additions and 193 deletions

View File

@ -278,6 +278,13 @@ class DCManagerTestCase(base.BaseTestCase):
self.mock_load_yaml_file = mock_patch_object.start()
self.addCleanup(mock_patch_object.stop)
def _mock_get_local_system(self):
"""Mock dcmanager util's get_local_system"""
mock_patch_object = mock.patch.object(dutils, 'get_local_system')
self.mock_get_local_system = mock_patch_object.start()
self.addCleanup(mock_patch_object.stop)
def _mock_os_remove(self):
"""Mock os' remove"""

View File

@ -350,6 +350,7 @@ class BaseTestSubcloudManager(base.DCManagerTestCase):
self._mock_os_path_isdir()
self._mock_os_path_exists()
self._mock_os_remove()
self._mock_get_local_system()
self.sm = subcloud_manager.SubcloudManager()
self.subcloud = self.create_subcloud_static(self.ctx)
@ -1297,8 +1298,7 @@ class TestSubcloudUpdate(BaseTestSubcloudManager):
mock_peer_dc_client):
system_peer_test = test_system_peer_manager.TestSystemPeerManager
system_peer = system_peer_test.create_system_peer_static(self.ctx)
mock_peer_dc_client.return_value = test_system_peer_manager.\
FakeDcmanagerClient()
mock_peer_dc_client.return_value = mock.MagicMock()
ret = self.sm._unmanage_system_peer_subcloud([system_peer], self.subcloud)
self.assertEqual(ret, False)
@ -3491,14 +3491,12 @@ class TestSubcloudMigrate(BaseTestSubcloudManager):
updated_subcloud.rehome_data)
@mock.patch.object(db_api, 'subcloud_peer_group_update')
@mock.patch.object(cutils, 'get_local_system')
@mock.patch.object(subcloud_manager.SubcloudManager,
'_run_parallel_group_operation')
def test_run_batch_migrate(self, mock_run_parallel_group_operation,
mock_get_local_system,
mock_subcloud_peer_group_update):
self._mock_builtins_open()
mock_get_local_system.return_value = FakeSysinvClient.get_system(self)
self.mock_get_local_system.return_value = FakeSysinvClient.get_system(self)
self.mock_openstack_driver.keystone_client = FakeKeystoneClient()
subcloud_pg = self.create_subcloud_peer_group_static(self.ctx)
db_api.subcloud_peer_group_update(
@ -3528,9 +3526,8 @@ class TestSubcloudMigrate(BaseTestSubcloudManager):
self.mock_log.info.assert_has_calls(Calls)
@mock.patch.object(db_api, 'subcloud_peer_group_update')
@mock.patch.object(cutils, 'get_local_system')
def test_run_batch_migrate_no_secondary_subclouds(
self, mock_get_local_system, mock_subcloud_peer_group_update
self, mock_subcloud_peer_group_update
):
self.mock_sysinv_client().return_value = FakeSysinvClient()
subcloud_pg = self.create_subcloud_peer_group_static(self.ctx)

View File

@ -86,28 +86,11 @@ FAKE_ASSOCIATION_TYPE = 'primary'
FAKE_SITE1_ASSOCIATION_ID = 10
class FakeDCManagerAuditAPI(object):
def __init__(self):
pass
class FakeSystem(object):
def __init__(self, uuid):
self.uuid = uuid
class FakePeerGroup(object):
def __init__(self):
self.id = FAKE_SITE1_PEER_GROUP_ID
class FakeKeystoneClient(object):
def __init__(self):
self.keystone_client = mock.MagicMock()
self.session = mock.MagicMock()
self.endpoint_cache = mock.MagicMock()
class FakeSysinvClient(object):
def __init__(self):
self.system = FakeSystem(FAKE_SITE1_SYSTEM_UUID)
@ -116,32 +99,36 @@ class FakeSysinvClient(object):
return self.system
class FakeDcmanagerClient(object):
def __init__(self):
self.peer_groups = [FakePeerGroup()]
def add_subcloud_peer_group(self, **kwargs):
return self.peer_groups
def get_subcloud_peer_group(self, peer_group_name):
return self.peer_groups
class FakeException(Exception):
pass
class TestSystemPeerManager(base.DCManagerTestCase):
def setUp(self):
super(TestSystemPeerManager, self).setUp()
"""Test class for testing system peer manager"""
# Mock the DCManager Audit API
self.fake_dcmanager_audit_api = FakeDCManagerAuditAPI()
p = mock.patch('dcmanager.audit.rpcapi.ManagerAuditClient')
self.mock_dcmanager_audit_api = p.start()
self.mock_dcmanager_audit_api.return_value = \
self.fake_dcmanager_audit_api
self.addCleanup(p.stop)
def setUp(self):
super().setUp()
self._mock_sysinv_client(system_peer_manager)
self._mock_system_peer_manager_peersitedriver()
self._mock_system_peer_manager_dcmanagerclient()
self._mock_get_local_system()
self.spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
self.mock_keystone_client().keystone_client = mock.MagicMock()
self.mock_sysinv_client.return_value = FakeSysinvClient()
self.mock_dc_client.return_value = mock.MagicMock()
self.mock_get_local_system().return_value = mock.MagicMock()
def _mock_system_peer_manager_dcmanagerclient(self):
"""Mock system_peer_manager's DcmanagerClient"""
mock_patch = mock.patch.object(system_peer_manager, 'DcmanagerClient')
self.mock_dc_client = mock_patch.start()
self.addCleanup(mock_patch.stop)
def _mock_system_peer_manager_peersitedriver(self):
"""Mock system_peer_manager's PeerSiteDriver"""
mock_patch = mock.patch.object(system_peer_manager, 'PeerSiteDriver')
self.mock_keystone_client = mock_patch.start()
self.addCleanup(mock_patch.stop)
@staticmethod
def create_subcloud_with_pg_static(ctxt, peer_group_id,
@ -195,24 +182,22 @@ class TestSystemPeerManager(base.DCManagerTestCase):
return db_api.peer_group_association_create(ctxt, **values)
def test_init(self):
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
self.assertIsNotNone(spm)
self.assertEqual('system_peer_manager', spm.service_name)
self.assertEqual('localhost', spm.host)
self.assertIsNotNone(self.spm)
self.assertEqual('system_peer_manager', self.spm.service_name)
self.assertEqual('localhost', self.spm.host)
@mock.patch.object(system_peer_manager, 'PeerSiteDriver')
@mock.patch.object(system_peer_manager, 'SysinvClient')
@mock.patch.object(system_peer_manager, 'DcmanagerClient')
def test_sync_subclouds(self, mock_dc_client,
mock_sysinv_client,
mock_keystone_client):
mock_keystone_client().keystone_client = FakeKeystoneClient()
mock_sysinv_client.return_value = FakeSysinvClient()
mock_dc_client.return_value = FakeDcmanagerClient()
mock_dc_client().add_subcloud_with_secondary_status = mock.MagicMock()
mock_dc_client().add_subcloud_with_secondary_status.return_value = {
class TestSyncSubclouds(TestSystemPeerManager):
"""Test class for testing sync subclouds"""
def setUp(self):
super().setUp()
def test_sync_subclouds(self):
self.mock_dc_client().add_subcloud_with_secondary_status = mock.MagicMock()
self.mock_dc_client().add_subcloud_with_secondary_status.return_value = {
"region-name": FAKE_SITE1_SUBCLOUD2_REGION_NAME}
mock_dc_client().delete_subcloud = mock.MagicMock()
self.mock_dc_client().delete_subcloud = mock.MagicMock()
peer = self.create_system_peer_static(
self.ctx,
@ -246,28 +231,27 @@ class TestSystemPeerManager(base.DCManagerTestCase):
peer_subcloud1 = FAKE_SITE1_SUBCLOUD1_DATA
peer_subcloud2 = FAKE_SITE1_SUBCLOUD2_DATA
peer_subcloud3 = FAKE_SITE1_SUBCLOUD3_DATA
mock_dc_client().get_subcloud = mock.MagicMock()
mock_dc_client().get_subcloud.side_effect = [
self.mock_dc_client().get_subcloud = mock.MagicMock()
self.mock_dc_client().get_subcloud.side_effect = [
peer_subcloud1, dccommon_exceptions.SubcloudNotFound,
peer_subcloud1, dccommon_exceptions.SubcloudNotFound,
peer_subcloud3]
mock_dc_client().get_subcloud_list_by_peer_group = mock.MagicMock()
mock_dc_client().get_subcloud_list_by_peer_group.return_value = [
self.mock_dc_client().get_subcloud_list_by_peer_group = mock.MagicMock()
self.mock_dc_client().get_subcloud_list_by_peer_group.return_value = [
peer_subcloud1, peer_subcloud2, peer_subcloud3]
mock_dc_client().update_subcloud = mock.MagicMock()
mock_dc_client().update_subcloud.side_effect = [
self.mock_dc_client().update_subcloud = mock.MagicMock()
self.mock_dc_client().update_subcloud.side_effect = [
peer_subcloud1, peer_subcloud1, peer_subcloud2]
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm._sync_subclouds(self.ctx, peer, peer_group.id,
self.spm._sync_subclouds(self.ctx, peer, peer_group.id,
FAKE_SITE1_PEER_GROUP_ID)
mock_dc_client().get_subcloud.assert_has_calls([
self.mock_dc_client().get_subcloud.assert_has_calls([
mock.call(peer_subcloud1.get('name')),
mock.call(peer_subcloud2.get('name')),
mock.call(peer_subcloud3.get('name'))
])
mock_dc_client().update_subcloud.assert_has_calls([
self.mock_dc_client().update_subcloud.assert_has_calls([
mock.call('subcloud1', mock.ANY, mock.ANY, is_region_name=True),
mock.call(FAKE_SITE1_SUBCLOUD1_REGION_NAME, files=None,
data={'peer_group': str(FAKE_SITE1_PEER_GROUP_ID)},
@ -276,34 +260,22 @@ class TestSystemPeerManager(base.DCManagerTestCase):
data={'peer_group': str(FAKE_SITE1_PEER_GROUP_ID)},
is_region_name=True)
])
mock_dc_client().add_subcloud_with_secondary_status. \
self.mock_dc_client().add_subcloud_with_secondary_status. \
assert_called_once()
mock_dc_client().delete_subcloud.assert_called_once_with('subcloud3')
self.mock_dc_client().delete_subcloud.assert_called_once_with('subcloud3')
@mock.patch.object(
system_peer_manager.SystemPeerManager, '_sync_subclouds')
@mock.patch.object(system_peer_manager, 'utils')
@mock.patch.object(system_peer_manager, 'PeerSiteDriver')
@mock.patch.object(system_peer_manager, 'SysinvClient')
@mock.patch.object(system_peer_manager, 'DcmanagerClient')
def test_sync_subcloud_peer_group(self,
mock_dc_client,
mock_sysinv_client,
mock_keystone_client,
mock_utils,
mock_sync_subclouds):
mock_sync_subclouds.return_value = True
mock_keystone_client().keystone_client = FakeKeystoneClient()
mock_sysinv_client.return_value = FakeSysinvClient()
mock_dc_client.return_value = FakeDcmanagerClient()
mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
mock_dc_client().update_subcloud_peer_group = mock.MagicMock()
mock_dc_client().get_system_peer = mock.MagicMock()
mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
self.mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().update_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().get_system_peer = mock.MagicMock()
self.mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
mock.MagicMock()
mock_dc_client().update_peer_group_association_sync_status = \
self.mock_dc_client().update_peer_group_association_sync_status = \
mock.MagicMock()
mock_utils().get_local_system = mock.MagicMock()
peer = self.create_system_peer_static(
self.ctx,
@ -316,37 +288,25 @@ class TestSystemPeerManager(base.DCManagerTestCase):
system_peer_id=peer.id,
peer_group_id=peer_group.id)
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.sync_subcloud_peer_group(self.ctx, association.id, False)
self.spm.sync_subcloud_peer_group(self.ctx, association.id, False)
mock_dc_client().get_subcloud_peer_group.assert_called_once_with(
self.mock_dc_client().get_subcloud_peer_group.assert_called_once_with(
peer_group.peer_group_name)
mock_dc_client().update_subcloud_peer_group.assert_called_once()
self.mock_dc_client().update_subcloud_peer_group.assert_called_once()
@mock.patch.object(
system_peer_manager.SystemPeerManager, '_sync_subclouds')
@mock.patch.object(system_peer_manager, 'utils')
@mock.patch.object(system_peer_manager, 'PeerSiteDriver')
@mock.patch.object(system_peer_manager, 'SysinvClient')
@mock.patch.object(system_peer_manager, 'DcmanagerClient')
def test_sync_subcloud_peer_group_not_exist(self, mock_dc_client,
mock_sysinv_client,
mock_keystone_client,
mock_utils,
def test_sync_subcloud_peer_group_not_exist(self,
mock_sync_subclouds):
mock_sync_subclouds.return_value = True
mock_keystone_client().keystone_client = FakeKeystoneClient()
mock_sysinv_client.return_value = FakeSysinvClient()
mock_dc_client.return_value = FakeDcmanagerClient()
mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
mock_dc_client().add_subcloud_peer_group = mock.MagicMock()
mock_dc_client().update_subcloud_peer_group = mock.MagicMock()
mock_dc_client().get_system_peer = mock.MagicMock()
mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
self.mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().add_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().update_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().get_system_peer = mock.MagicMock()
self.mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
mock.MagicMock()
mock_dc_client().update_peer_group_association_sync_status = \
self.mock_dc_client().update_peer_group_association_sync_status = \
mock.MagicMock()
mock_utils().get_local_system = mock.MagicMock()
peer = self.create_system_peer_static(
self.ctx,
@ -359,15 +319,14 @@ class TestSystemPeerManager(base.DCManagerTestCase):
system_peer_id=peer.id,
peer_group_id=peer_group.id)
mock_dc_client().get_subcloud_peer_group.side_effect = \
self.mock_dc_client().get_subcloud_peer_group.side_effect = \
dccommon_exceptions.SubcloudPeerGroupNotFound
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.sync_subcloud_peer_group(self.ctx, association.id, False)
self.spm.sync_subcloud_peer_group(self.ctx, association.id, False)
mock_dc_client().get_subcloud_peer_group.assert_called_once_with(
self.mock_dc_client().get_subcloud_peer_group.assert_called_once_with(
peer_group.peer_group_name)
mock_dc_client().add_subcloud_peer_group.assert_called_once_with(**{
self.mock_dc_client().add_subcloud_peer_group.assert_called_once_with(**{
'peer-group-name': peer_group.peer_group_name,
'group-priority': association.peer_group_priority,
'group-state': peer_group.group_state,
@ -376,26 +335,21 @@ class TestSystemPeerManager(base.DCManagerTestCase):
'max-subcloud-rehoming': peer_group.max_subcloud_rehoming
})
@mock.patch.object(system_peer_manager, 'utils')
@mock.patch.object(system_peer_manager, 'PeerSiteDriver')
@mock.patch.object(system_peer_manager, 'SysinvClient')
@mock.patch.object(system_peer_manager, 'DcmanagerClient')
def test_delete_peer_group_association(self,
mock_dc_client,
mock_sysinv_client,
mock_keystone_client,
mock_utils):
mock_keystone_client().keystone_client = FakeKeystoneClient()
mock_sysinv_client.return_value = FakeSysinvClient()
mock_dc_client.return_value = FakeDcmanagerClient()
mock_dc_client().delete_subcloud_peer_group = mock.MagicMock()
mock_dc_client().delete_subcloud = mock.MagicMock()
mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
mock_dc_client().get_system_peer = mock.MagicMock()
mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
class TestDeletePeerGroup(TestSystemPeerManager):
"""Test class for testing delete peer group"""
def setUp(self):
super().setUp()
def test_delete_peer_group_association(self):
self.mock_dc_client().delete_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().delete_subcloud = mock.MagicMock()
self.mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().get_system_peer = mock.MagicMock()
self.mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
mock.MagicMock()
mock_dc_client().delete_peer_group_association = mock.MagicMock()
mock_utils().get_local_system = mock.MagicMock()
self.mock_dc_client().delete_peer_group_association = mock.MagicMock()
peer = self.create_system_peer_static(
self.ctx,
@ -419,45 +373,36 @@ class TestSystemPeerManager(base.DCManagerTestCase):
peer_group_id=peer_group.id)
peer_subcloud1 = FAKE_SITE1_SUBCLOUD1_DATA
peer_subcloud2 = FAKE_SITE1_SUBCLOUD2_DATA
mock_dc_client().get_subcloud = mock.MagicMock()
mock_dc_client().get_subcloud.side_effect = [
self.mock_dc_client().get_subcloud = mock.MagicMock()
self.mock_dc_client().get_subcloud.side_effect = [
peer_subcloud1, peer_subcloud2]
mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id.\
self.mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id.\
return_value = {'id': FAKE_SITE1_ASSOCIATION_ID}
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.delete_peer_group_association(self.ctx, association.id)
self.spm.delete_peer_group_association(self.ctx, association.id)
mock_dc_client().delete_subcloud.assert_has_calls([
self.mock_dc_client().delete_subcloud.assert_has_calls([
mock.call(subcloud1.name),
mock.call(subcloud2.name)
])
mock_dc_client().delete_subcloud_peer_group.assert_called_once_with(
self.mock_dc_client().delete_subcloud_peer_group.assert_called_once_with(
peer_group.peer_group_name)
mock_dc_client().delete_peer_group_association.assert_called_once_with(
self.mock_dc_client().delete_peer_group_association.assert_called_once_with(
FAKE_SITE1_ASSOCIATION_ID)
associations = db_api.peer_group_association_get_all(self.ctx)
self.assertEqual(0, len(associations))
@mock.patch.object(system_peer_manager, 'utils')
@mock.patch.object(system_peer_manager, 'PeerSiteDriver')
@mock.patch.object(system_peer_manager, 'SysinvClient')
@mock.patch.object(system_peer_manager, 'DcmanagerClient')
def test_delete_peer_group_association_peer_site_association_not_exsit(
self, mock_dc_client, mock_sysinv_client, mock_keystone_client, mock_utils
self
):
mock_keystone_client().keystone_client = FakeKeystoneClient()
mock_sysinv_client.return_value = FakeSysinvClient()
mock_dc_client.return_value = FakeDcmanagerClient()
mock_dc_client().delete_subcloud_peer_group = mock.MagicMock()
mock_dc_client().delete_subcloud = mock.MagicMock()
mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
mock_dc_client().get_system_peer = mock.MagicMock()
mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
self.mock_dc_client().delete_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().delete_subcloud = mock.MagicMock()
self.mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().get_system_peer = mock.MagicMock()
self.mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id = \
mock.MagicMock()
mock_dc_client().delete_peer_group_association = mock.MagicMock()
mock_utils().get_local_system = mock.MagicMock()
self.mock_dc_client().delete_peer_group_association = mock.MagicMock()
peer = self.create_system_peer_static(
self.ctx,
@ -475,20 +420,19 @@ class TestSystemPeerManager(base.DCManagerTestCase):
system_peer_id=peer.id,
peer_group_id=peer_group.id)
peer_subcloud1 = FAKE_SITE1_SUBCLOUD1_DATA
mock_dc_client().get_subcloud = mock.MagicMock()
mock_dc_client().get_subcloud.side_effect = [
self.mock_dc_client().get_subcloud = mock.MagicMock()
self.mock_dc_client().get_subcloud.side_effect = [
peer_subcloud1, dccommon_exceptions.SubcloudNotFound]
mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id.\
self.mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id.\
side_effect = [dccommon_exceptions.PeerGroupAssociationNotFound]
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.delete_peer_group_association(self.ctx, association.id)
self.spm.delete_peer_group_association(self.ctx, association.id)
mock_dc_client().delete_subcloud.assert_has_calls([
self.mock_dc_client().delete_subcloud.assert_has_calls([
mock.call(subcloud1.name)])
mock_dc_client().delete_subcloud_peer_group.assert_called_once_with(
self.mock_dc_client().delete_subcloud_peer_group.assert_called_once_with(
peer_group.peer_group_name)
mock_dc_client().delete_peer_group_association.assert_not_called()
self.mock_dc_client().delete_peer_group_association.assert_not_called()
associations = db_api.peer_group_association_get_all(self.ctx)
self.assertEqual(0, len(associations))
@ -524,8 +468,7 @@ class TestSystemPeerManager(base.DCManagerTestCase):
mock_dc_client().get_peer_group_association_with_peer_id_and_pg_id.\
return_value = {'id': FAKE_SITE1_ASSOCIATION_ID}
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.update_sync_status(
self.spm.update_sync_status(
self.ctx, peer, consts.ASSOCIATION_SYNC_STATUS_IN_SYNC)
mock_dc_client().get_subcloud_peer_group.assert_called_once_with(
@ -544,6 +487,14 @@ class TestSystemPeerManager(base.DCManagerTestCase):
self.assertEqual(consts.ASSOCIATION_SYNC_STATUS_IN_SYNC,
association_new.sync_status)
class TestUpdatePeerGroup(TestSystemPeerManager):
"""Test class for testing update peer group"""
def setUp(self):
super().setUp()
@mock.patch.object(system_peer_manager.SystemPeerManager,
'update_sync_status')
def test_update_association_sync_status(self, mock_update_sync_status):
@ -559,8 +510,7 @@ class TestSystemPeerManager(base.DCManagerTestCase):
peer_group_id=peer_group.id,
sync_status=consts.ASSOCIATION_SYNC_STATUS_IN_SYNC)
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.update_association_sync_status(
self.spm.update_association_sync_status(
self.ctx, peer_group.id,
consts.ASSOCIATION_SYNC_STATUS_OUT_OF_SYNC)
@ -584,8 +534,7 @@ class TestSystemPeerManager(base.DCManagerTestCase):
peer_group_id=peer_group.id,
sync_status=consts.ASSOCIATION_SYNC_STATUS_UNKNOWN)
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.update_association_sync_status(
self.spm.update_association_sync_status(
self.ctx, peer_group.id,
consts.ASSOCIATION_SYNC_STATUS_OUT_OF_SYNC)
@ -600,19 +549,10 @@ class TestSystemPeerManager(base.DCManagerTestCase):
mock_update_sync_status.assert_not_called()
@mock.patch.object(system_peer_manager, 'PeerSiteDriver')
@mock.patch.object(system_peer_manager, 'SysinvClient')
@mock.patch.object(system_peer_manager, 'DcmanagerClient')
def test_update_subcloud_peer_group(self,
mock_dc_client,
mock_sysinv_client,
mock_keystone_client):
mock_keystone_client().keystone_client = FakeKeystoneClient()
mock_sysinv_client.return_value = FakeSysinvClient()
mock_dc_client.return_value = FakeDcmanagerClient()
mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
mock_dc_client().update_subcloud_peer_group = mock.MagicMock()
mock_dc_client().get_system_peer = mock.MagicMock()
def test_update_subcloud_peer_group(self):
self.mock_dc_client().get_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().update_subcloud_peer_group = mock.MagicMock()
self.mock_dc_client().get_system_peer = mock.MagicMock()
peer = self.create_system_peer_static(
self.ctx,
@ -625,8 +565,7 @@ class TestSystemPeerManager(base.DCManagerTestCase):
system_peer_id=peer.id,
peer_group_id=peer_group.id)
spm = system_peer_manager.SystemPeerManager(mock.MagicMock())
spm.update_subcloud_peer_group(
self.spm.update_subcloud_peer_group(
self.ctx, peer_group.id,
FAKE_SITE1_PEER_GROUP_STATE,
FAKE_SITE1_PEER_GROUP_MAX_SUBCLOUDS_REHOMING,
@ -639,5 +578,5 @@ class TestSystemPeerManager(base.DCManagerTestCase):
'max-subcloud-rehoming':
FAKE_SITE1_PEER_GROUP_MAX_SUBCLOUDS_REHOMING
}
mock_dc_client().update_subcloud_peer_group.assert_called_once_with(
self.mock_dc_client().update_subcloud_peer_group.assert_called_once_with(
FAKE_SITE0_PEER_GROUP_NAME, **peer_group_kwargs)