Skip to content

Commit

Permalink
Add unit tests for controller and port resources
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-v committed Aug 4, 2021
1 parent 1606bc2 commit 1aca6d8
Showing 1 changed file with 229 additions and 0 deletions.
229 changes: 229 additions & 0 deletions delfin/tests/unit/drivers/dell_emc/vmax/test_vmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,235 @@ def test_list_volumes(self, mock_unisphere_version,
self.assertIn('Failed to get list volumes from VMAX',
str(exc.exception))

@mock.patch.object(VMaxRest, 'get_resource')
@mock.patch.object(VMaxRest, 'get_array_detail')
@mock.patch.object(VMaxRest, 'get_uni_version')
@mock.patch.object(VMaxRest, 'get_unisphere_version')
def test_list_controllers(self, mock_unisphere_version,
mock_version,
mock_array, mock_res):
expected = [
{
'name': 'director_1',
'storage_id': '12345',
'native_controller_id': 'DF-1C',
'status': 'offline',
'location': 'slot_10',
'soft_version': None,
'cpu_info': 'number_of_cores_64',
'memory_size': None
}
]
kwargs = VMAX_STORAGE_CONF
mock_version.return_value = ['V9.0.2.7', '90']
mock_unisphere_version.return_value = ['V9.0.2.7', '90']
mock_array.return_value = {'symmetrixId': ['00112233']}
mock_res.side_effect = [
{'directorId': ['DF-1C', 'DF-2C']},
{
'availability': 'ON',
'directorId': 'DF-1C',
'director_number': 1,
'director_slot_number': 10,
'num_of_cores': 64,
'num_of_ports': 2,
'srdf_groups': [
{
'label': 'label_1',
'rdf_group_number': 1
}
]
},
{
'availability': 'ON',
'directorId': 'DF-2C',
'director_number': 2,
'director_slot_number': 10,
'num_of_cores': 64,
'num_of_ports': 2,
'srdf_groups': [
{
'label': 'label_1',
'rdf_group_number': 1
}
]
},
{'directorId': ['DF-1C', 'DF-2C']},
exception.StorageBackendException,
exception.StorageBackendException
]

driver = VMAXStorageDriver(**kwargs)
self.assertEqual(driver.storage_id, "12345")
self.assertEqual(driver.client.array_id, "00112233")

ret = driver.list_controllers(context)
self.assertDictEqual(ret[0], expected[0])

with self.assertRaises(Exception) as exc:
driver.list_controllers(context)

self.assertIn('Controller 00112233 could not be found',
str(exc.exception))

with self.assertRaises(Exception) as exc:
driver.list_controllers(context)

self.assertIn('Controller 00112233 could not be found',
str(exc.exception))

@mock.patch.object(VMaxRest, 'get_resource_kwargs')
@mock.patch.object(VMaxRest, 'get_director_list')
@mock.patch.object(VMaxRest, 'get_array_detail')
@mock.patch.object(VMaxRest, 'get_uni_version')
@mock.patch.object(VMaxRest, 'get_unisphere_version')
def test_list_ports(self, mock_unisphere_version,
mock_version,
mock_array, mock_dirs, mock_res):
expected = [{
'name': 'DF-1C:30',
'storage_id': '12345',
'native_port_id': '30',
'location': 'director_DF-1C',
'connection_status': 'connected',
'health_status': 'normal',
'type': 'other',
'logical_type': None,
'speed': 0,
'max_speed': 10737418240,
'native_parent_id': 'DF-1C',
'wwn': None,
'mac_address': None,
'ipv4': None,
'ipv4_mask': None,
'ipv6': None,
'ipv6_mask': None
}]
kwargs = VMAX_STORAGE_CONF
mock_version.return_value = ['V9.0.2.7', '90']
mock_unisphere_version.return_value = ['V9.0.2.7', '90']
mock_array.return_value = {'symmetrixId': ['00112233']}
mock_dirs.return_value = ['DF-1C']
mock_res.side_effect = [
{
'symmetrixPortKey': [
{
'directorId': 'DF-1C',
'portId': '30'
},
{
'directorId': 'DF-2C',
'portId': '0'
}
]
},
{
'symmetrixPort': {
'aclx': False,
'avoid_reset_broadcast': False,
'common_serial_number': True,
'director_status': 'Offline',
'disable_q_reset_on_ua': False,
'enable_auto_negotiate': False,
'environ_set': False,
'hp_3000_mode': False,
'ip_addresses': [
'192.168.0.51'
],
'iscsi_target': False,
'max_speed': '10',
'negotiate_reset': False,
'num_of_cores': 6,
'num_of_mapped_vols': 0,
'num_of_masking_views': 0,
'num_of_port_groups': 0,
'port_status': 'PendOn',
'scsi_3': False,
'scsi_support1': False,
'siemens': False,
'soft_reset': False,
'spc2_protocol_version': False,
'sunapee': False,
'symmetrixPortKey': {
'directorId': 'DF-1C',
'portId': '30'
},
'type': 'GigE',
'vnx_attached': False,
'volume_set_addressing': False
}
},
{
'symmetrixPort': {
'aclx': False,
'avoid_reset_broadcast': False,
'common_serial_number': True,
'director_status': 'Offline',
'disable_q_reset_on_ua': False,
'enable_auto_negotiate': False,
'environ_set': False,
'hp_3000_mode': False,
'ip_addresses': [
'192.168.0.51'
],
'iscsi_target': False,
'max_speed': '10',
'negotiate_reset': False,
'num_of_cores': 6,
'num_of_mapped_vols': 0,
'num_of_masking_views': 0,
'num_of_port_groups': 0,
'port_status': 'PendOn',
'scsi_3': False,
'scsi_support1': False,
'siemens': False,
'soft_reset': False,
'spc2_protocol_version': False,
'sunapee': False,
'symmetrixPortKey': {
'directorId': 'DF-2C',
'portId': '0'
},
'type': 'GigE',
'vnx_attached': False,
'volume_set_addressing': False
}
},
{
'symmetrixPortKey': [
{
'directorId': 'DF-1C',
'portId': '30'
},
{
'directorId': 'DF-2C',
'portId': '0'
}
]
},
exception.StorageBackendException,
exception.StorageBackendException
]

driver = VMAXStorageDriver(**kwargs)
self.assertEqual(driver.storage_id, "12345")
self.assertEqual(driver.client.array_id, "00112233")

ret = driver.list_ports(context)
self.assertDictEqual(ret[0], expected[0])

with self.assertRaises(Exception) as exc:
driver.list_ports(context)

self.assertIn('Port 00112233 could not be found',
str(exc.exception))

with self.assertRaises(Exception) as exc:
driver.list_ports(context)

self.assertIn('Port 00112233 could not be found',
str(exc.exception))

@mock.patch.object(VMaxRest, 'post_request')
@mock.patch.object(VMaxRest, 'get_vmax_array_details')
@mock.patch.object(VMaxRest, 'get_array_detail')
Expand Down

0 comments on commit 1aca6d8

Please sign in to comment.