"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py" between
cinder-15.5.0.tar.gz and cinder-15.6.0.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Train" series (maintained release).

test_storwize_svc.py  (cinder-15.5.0):test_storwize_svc.py  (cinder-15.6.0)
skipping to change at line 31 skipping to change at line 31
import ddt import ddt
import json import json
import mock import mock
import paramiko import paramiko
import random import random
import re import re
import time import time
from oslo_concurrency import processutils from oslo_concurrency import processutils
from oslo_config import cfg from oslo_config import cfg
from oslo_service import loopingcall
from oslo_utils import importutils from oslo_utils import importutils
from oslo_utils import units from oslo_utils import units
import six import six
from cinder import context from cinder import context
from cinder import exception from cinder import exception
from cinder.i18n import _ from cinder.i18n import _
from cinder import objects from cinder import objects
from cinder.objects import fields from cinder.objects import fields
from cinder import ssh_utils from cinder import ssh_utils
skipping to change at line 5529 skipping to change at line 5530
self.driver.delete_volume(clone) self.driver.delete_volume(clone)
self._assert_vol_exists(clone['name'], False) self._assert_vol_exists(clone['name'], False)
@ddt.data((True, None), (True, 5), (False, -1), (False, 100)) @ddt.data((True, None), (True, 5), (False, -1), (False, 100))
@ddt.unpack @ddt.unpack
def test_storwize_svc_get_volume_stats( def test_storwize_svc_get_volume_stats(
self, is_thin_provisioning_enabled, rsize): self, is_thin_provisioning_enabled, rsize):
self._set_flag('reserved_percentage', 25) self._set_flag('reserved_percentage', 25)
self._set_flag('storwize_svc_multihostmap_enabled', True) self._set_flag('storwize_svc_multihostmap_enabled', True)
self._set_flag('storwize_svc_vol_rsize', rsize) self._set_flag('storwize_svc_vol_rsize', rsize)
stats = self.driver.get_volume_stats() stats = self.driver.get_volume_stats(True)
for each_pool in stats['pools']: for each_pool in stats['pools']:
self.assertIn(each_pool['pool_name'], self.assertIn(each_pool['pool_name'],
self._def_flags['storwize_svc_volpool_name']) self._def_flags['storwize_svc_volpool_name'])
self.assertTrue(each_pool['multiattach']) self.assertTrue(each_pool['multiattach'])
self.assertLessEqual(each_pool['free_capacity_gb'], self.assertLessEqual(each_pool['free_capacity_gb'],
each_pool['total_capacity_gb']) each_pool['total_capacity_gb'])
self.assertLessEqual(each_pool['allocated_capacity_gb'], self.assertLessEqual(each_pool['allocated_capacity_gb'],
each_pool['total_capacity_gb']) each_pool['total_capacity_gb'])
self.assertEqual(25, each_pool['reserved_percentage']) self.assertEqual(25, each_pool['reserved_percentage'])
self.assertEqual(is_thin_provisioning_enabled, self.assertEqual(is_thin_provisioning_enabled,
skipping to change at line 8138 skipping to change at line 8139
port_status!inactive port_status!inactive
port_speed!8Gb port_speed!8Gb
''' '''
resp = storwize_svc_common.CLIResponse(raw, with_header=False) resp = storwize_svc_common.CLIResponse(raw, with_header=False)
self.assertEqual(1, len(resp)) self.assertEqual(1, len(resp))
self.assertEqual('1', resp[0]['id']) self.assertEqual('1', resp[0]['id'])
self.assertEqual([('500507680210C744', 'active'), self.assertEqual([('500507680210C744', 'active'),
('500507680240C744', 'inactive')], ('500507680240C744', 'inactive')],
list(resp.select('port_id', 'port_status'))) list(resp.select('port_id', 'port_status')))
@ddt.ddt
class StorwizeHelpersTestCase(test.TestCase): class StorwizeHelpersTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(StorwizeHelpersTestCase, self).setUp() super(StorwizeHelpersTestCase, self).setUp()
self.storwize_svc_common = storwize_svc_common.StorwizeHelpers(None) self.storwize_svc_common = storwize_svc_common.StorwizeHelpers(None)
self.mock_wait_time = mock.patch.object( self.mock_wait_time = mock.patch.object(
storwize_svc_common.StorwizeHelpers, "WAIT_TIME", 0) storwize_svc_common.StorwizeHelpers, "WAIT_TIME", 0)
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'lslicense') @mock.patch.object(storwize_svc_common.StorwizeSSH, 'lslicense')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsguicapabilities') @mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsguicapabilities')
def test_compression_enabled(self, lsguicapabilities, lslicense): def test_compression_enabled(self, lsguicapabilities, lslicense):
skipping to change at line 8302 skipping to change at line 8304
_get_flashcopy_mapping_attributes, _get_flashcopy_mapping_attributes,
stopfcmap): stopfcmap):
vol = 'testvol' vol = 'testvol'
_get_vdisk_fc_mappings.return_value = ['4'] _get_vdisk_fc_mappings.return_value = ['4']
_get_flashcopy_mapping_attributes.return_value = { _get_flashcopy_mapping_attributes.return_value = {
'copy_rate': '50', 'copy_rate': '50',
'progress': '100', 'progress': '100',
'status': 'copying', 'status': 'copying',
'target_vdisk_name': 'testvol'} 'target_vdisk_name': 'testvol'}
self.storwize_svc_common.pretreatment_before_revert(vol) self.storwize_svc_common.pretreatment_before_revert(vol)
stopfcmap.assert_called_once_with('4', split=True) stopfcmap.assert_called_once_with('4')
@ddt.data({'copy_rate': '50', 'progress': '3', 'status': 'copying'},
{'copy_rate': '50', 'progress': '100', 'status': 'copying'},
{'copy_rate': '0', 'progress': '0', 'status': 'copying'},
{'copy_rate': '50', 'progress': '0', 'status': 'copying'},
{'copy_rate': '0', 'progress': '0', 'status': 'idle_or_copied'})
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'chfcmap')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'stopfcmap')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'rmfcmap')
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'_get_flashcopy_mapping_attributes')
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'_get_vdisk_fc_mappings')
def test_check_vdisk_fc_mappings(self,
fc_data,
get_vdisk_fc_mappings,
get_fc_mapping_attributes,
rmfcmap, stopfcmap, chfcmap):
vol = 'testvol'
get_vdisk_fc_mappings.return_value = ['4']
get_fc_mapping_attributes.return_value = {
'copy_rate': fc_data['copy_rate'],
'progress': fc_data['progress'],
'status': fc_data['status'],
'target_vdisk_name': 'tar-testvol',
'rc_controlled': 'no',
'source_vdisk_name': 'testvol'}
if(fc_data['copy_rate'] != '0' and fc_data['progress'] == '100'
and fc_data['status'] == 'copying'):
(self.assertRaises(loopingcall.LoopingCallDone,
self.storwize_svc_common._check_vdisk_fc_mappings, vol, True,
False))
stopfcmap.assert_called_with('4')
self.assertEqual(1, stopfcmap.call_count)
else:
self.storwize_svc_common._check_vdisk_fc_mappings(vol, True,
False)
stopfcmap.assert_not_called()
self.assertEqual(0, stopfcmap.call_count)
get_vdisk_fc_mappings.assert_called()
get_fc_mapping_attributes.assert_called_with('4')
rmfcmap.assert_not_called()
self.assertEqual(1, get_fc_mapping_attributes.call_count)
self.assertEqual(0, rmfcmap.call_count)
if(fc_data['copy_rate'] == '0' and fc_data['progress'] == '0'
and fc_data['status'] in ['copying', 'idle_or_copied']):
chfcmap.assert_called_with('4', copyrate='50', autodel='on')
self.assertEqual(1, chfcmap.call_count)
else:
chfcmap.assert_not_called()
self.assertEqual(0, chfcmap.call_count)
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'chfcmap')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'stopfcmap')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'rmfcmap')
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'_get_flashcopy_mapping_attributes')
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'_get_vdisk_fc_mappings')
def test_check_vdisk_fc_mappings_tarisvol(self,
get_vdisk_fc_mappings,
get_fc_mapping_attributes,
rmfcmap, stopfcmap, chfcmap):
vol = 'tar-testvol'
get_vdisk_fc_mappings.return_value = ['4']
get_fc_mapping_attributes.return_value = {
'copy_rate': '0',
'progress': '0',
'status': 'idle_or_copied',
'target_vdisk_name': 'tar-testvol',
'rc_controlled': 'no',
'source_vdisk_name': 'testvol'}
self.assertRaises(loopingcall.LoopingCallDone,
self.storwize_svc_common._check_vdisk_fc_mappings,
vol, True, False)
get_vdisk_fc_mappings.assert_called()
get_fc_mapping_attributes.assert_called_with('4')
stopfcmap.assert_not_called()
rmfcmap.assert_called_with('4')
chfcmap.assert_not_called()
self.assertEqual(1, get_fc_mapping_attributes.call_count)
self.assertEqual(0, stopfcmap.call_count)
self.assertEqual(1, rmfcmap.call_count)
self.assertEqual(0, chfcmap.call_count)
@ddt.data(([{'cp_rate': '0', 'prgs': '0', 'status': 'idle_or_copied',
'trg_vdisk': 'testvol', 'src_vdisk': 'tar_testvol'},
{'cp_rate': '50', 'prgs': '100', 'status': 'copying',
'trg_vdisk': 'tar_testvol', 'src_vdisk': 'testvol'},
{'cp_rate': '50', 'prgs': '3', 'status': 'copying',
'trg_vdisk': 'tar_testvol', 'src_vdisk': 'testvol'}], 1),
([{'cp_rate': '50', 'prgs': '100', 'status': 'idle_or_copied',
'trg_vdisk': 'testvol', 'src_vdisk': 'tar_testvol'},
{'cp_rate': '50', 'prgs': '100', 'status': 'copying',
'trg_vdisk': 'tar_testvol', 'src_vdisk': 'testvol'},
{'cp_rate': '50', 'prgs': '100', 'status': 'copying',
'trg_vdisk': 'testvol', 'src_vdisk': 'tar_testvol'}], 1),
([{'cp_rate': '50', 'prgs': '100', 'status': 'idle_or_copied',
'trg_vdisk': 'testvol', 'src_vdisk': 'tar_testvol'},
{'cp_rate': '50', 'prgs': '100', 'status': 'copying',
'trg_vdisk': 'tar_testvol', 'src_vdisk': 'testvol'},
{'cp_rate': '50', 'prgs': '100', 'status': 'copying',
'trg_vdisk': 'tar_testvol_1', 'src_vdisk': 'testvol'}], 2),
([{'cp_rate': '0', 'prgs': '0', 'status': 'copying',
'trg_vdisk': 'testvol', 'src_vdisk': 'snap_testvol'},
{'cp_rate': '50', 'prgs': '0', 'status': 'copying',
'trg_vdisk': 'tar_testvol', 'src_vdisk': 'testvol'},
{'cp_rate': '50', 'prgs': '0', 'status': 'copying',
'trg_vdisk': 'tar_testvol_1', 'src_vdisk': 'testvol'}], 0))
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'chfcmap')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'stopfcmap')
@mock.patch.object(storwize_svc_common.StorwizeSSH, 'rmfcmap')
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'_get_flashcopy_mapping_attributes')
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'_get_vdisk_fc_mappings')
@ddt.unpack
def test_check_vdisk_fc_mappings_mul_fcs(self,
fc_data, stopfc_count,
get_vdisk_fc_mappings,
get_fc_mapping_attributes,
rmfcmap, stopfcmap, chfcmap):
vol = 'testvol'
get_vdisk_fc_mappings.return_value = ['4', '5', '7']
get_fc_mapping_attributes.side_effect = [
{
'copy_rate': fc_data[0]['cp_rate'],
'progress': fc_data[0]['prgs'],
'status': fc_data[0]['status'],
'target_vdisk_name': fc_data[0]['trg_vdisk'],
'rc_controlled': 'no',
'source_vdisk_name': fc_data[0]['src_vdisk']},
{
'copy_rate': fc_data[1]['cp_rate'],
'progress': fc_data[1]['prgs'],
'status': fc_data[1]['status'],
'target_vdisk_name': fc_data[1]['trg_vdisk'],
'rc_controlled': 'no',
'source_vdisk_name': fc_data[1]['src_vdisk']},
{
'copy_rate': fc_data[2]['cp_rate'],
'progress': fc_data[2]['prgs'],
'status': fc_data[2]['status'],
'target_vdisk_name': fc_data[2]['trg_vdisk'],
'rc_controlled': 'no',
'source_vdisk_name': fc_data[2]['src_vdisk']}]
self.storwize_svc_common._check_vdisk_fc_mappings(vol, True, True)
get_vdisk_fc_mappings.assert_called()
get_fc_mapping_attributes.assert_called()
rmfcmap.assert_not_called()
chfcmap.assert_not_called()
self.assertEqual(3, get_fc_mapping_attributes.call_count)
self.assertEqual(stopfc_count, stopfcmap.call_count)
self.assertEqual(0, rmfcmap.call_count)
self.assertEqual(0, chfcmap.call_count)
def test_storwize_check_flashcopy_rate_invalid1(self):
with mock.patch.object(storwize_svc_common.StorwizeHelpers,
'get_system_info') as get_system_info:
fake_system_info = {'code_level': (7, 6, 0, 0),
'topology': 'standard',
'system_name': 'storwize-svc-sim',
'system_id': '0123456789ABCDEF'}
get_system_info.return_value = fake_system_info
flashcopy_rate = 120
self.assertRaises(exception.VolumeDriverException,
self.storwize_svc_common.check_flashcopy_rate,
flashcopy_rate)
def test_storwize_check_flashcopy_rate_invalid2(self):
with mock.patch.object(storwize_svc_common.StorwizeHelpers,
'get_system_info') as get_system_info:
fake_system_info = {'code_level': (7, 8, 1, 2),
'topology': 'standard',
'system_name': 'storwize-svc-sim',
'system_id': '0123456789ABCDEF'}
get_system_info.return_value = fake_system_info
flashcopy_rate = 200
self.assertRaises(exception.InvalidInput,
self.storwize_svc_common.check_flashcopy_rate,
flashcopy_rate)
@ddt.data(({'mirror_pool': 'openstack2',
'volume_topology': None,
'peer_pool': None}, True, 1),
({'mirror_pool': 'openstack2',
'volume_topology': None,
'peer_pool': None}, False, 2),
({'mirror_pool': None,
'volume_topology': 'hyperswap',
'peer_pool': 'openstack1'}, True, 1),
({'mirror_pool': None,
'volume_topology': 'hyperswap',
'peer_pool': 'openstack1'}, False, 2))
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'is_data_reduction_pool')
@ddt.unpack
def test_is_volume_type_dr_pools_dr_pool(self, opts, is_drp, call_count,
is_data_reduction_pool):
is_data_reduction_pool.return_value = is_drp
pool = 'openstack'
rep_type = None
rep_target_pool = None
isdrpool = (self.storwize_svc_common.
is_volume_type_dr_pools(pool, opts, rep_type,
rep_target_pool))
self.assertEqual(is_drp, isdrpool)
is_data_reduction_pool.assert_called()
self.assertEqual(call_count, is_data_reduction_pool.call_count)
@ddt.ddt @ddt.ddt
class StorwizeSSHTestCase(test.TestCase): class StorwizeSSHTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(StorwizeSSHTestCase, self).setUp() super(StorwizeSSHTestCase, self).setUp()
self.fake_driver = StorwizeSVCISCSIFakeDriver( self.fake_driver = StorwizeSVCISCSIFakeDriver(
configuration=conf.Configuration(None)) configuration=conf.Configuration(None))
sim = StorwizeSVCManagementSimulator(['openstack']) sim = StorwizeSVCManagementSimulator(['openstack'])
self.fake_driver.set_fake_storage(sim) self.fake_driver.set_fake_storage(sim)
self.storwize_ssh = storwize_svc_common.StorwizeSSH( self.storwize_ssh = storwize_svc_common.StorwizeSSH(
 End of changes. 4 change blocks. 
2 lines changed or deleted 220 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)