Fix deprecation warnings caused by invalid UUIDs
This change replaces invalid UUIDs used in unit tests which are causing the deprecation warnings like; FutureWarning: b"'fake_volume_id'" is an invalid UUID. Using UUIDFields with invalid UUIDs is no longer supported, and will be removed in a future release. Please update your code to input valid UUIDs or accept ValueErrors for invalid UUIDs. ... Change-Id: I18b0a7c81efd8fe981bdd7a3c41a7044147a96a0
This commit is contained in:
parent
b49fb59a6b
commit
eba7286a0f
|
@ -111,7 +111,8 @@ class SnapshotManageTest(test.TestCase):
|
|||
|
||||
@mock.patch(
|
||||
'cinder.scheduler.rpcapi.SchedulerAPI.manage_existing_snapshot')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db',
|
||||
return_value=mock.MagicMock(id=fake.SNAPSHOT_ID))
|
||||
@mock.patch('cinder.db.sqlalchemy.api.service_get')
|
||||
def test_manage_snapshot_ok(self, mock_db,
|
||||
mock_create_snapshot, mock_rpcapi):
|
||||
|
@ -152,19 +153,20 @@ class SnapshotManageTest(test.TestCase):
|
|||
|
||||
@mock.patch(
|
||||
'cinder.scheduler.rpcapi.SchedulerAPI.manage_existing_snapshot')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db',
|
||||
return_value=mock.MagicMock(id=fake.SNAPSHOT_ID))
|
||||
@mock.patch('cinder.objects.service.Service.get_by_id')
|
||||
def test_manage_snapshot_ok_with_metadata_null(
|
||||
self, mock_db, mock_create_snapshot, mock_rpcapi):
|
||||
mock_db.return_value = fake_service.fake_service_obj(
|
||||
self._admin_ctxt,
|
||||
binary=constants.VOLUME_BINARY)
|
||||
|
||||
body = {'snapshot': {'volume_id': fake.VOLUME_ID,
|
||||
'ref': {'fake_key': 'fake_ref'},
|
||||
'name': 'test',
|
||||
'description': 'test',
|
||||
'metadata': None}}
|
||||
|
||||
res = self._get_resp_post(body)
|
||||
self.assertEqual(HTTPStatus.ACCEPTED, res.status_int)
|
||||
args = mock_create_snapshot.call_args[0]
|
||||
|
@ -173,12 +175,12 @@ class SnapshotManageTest(test.TestCase):
|
|||
|
||||
@mock.patch(
|
||||
'cinder.scheduler.rpcapi.SchedulerAPI.manage_existing_snapshot')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db',
|
||||
return_value=mock.MagicMock(id=fake.SNAPSHOT_ID))
|
||||
@mock.patch('cinder.db.sqlalchemy.api.service_get')
|
||||
def test_manage_snapshot_ok_ref_as_string(self, mock_db,
|
||||
mock_create_snapshot,
|
||||
mock_rpcapi):
|
||||
|
||||
mock_db.return_value = fake_service.fake_service_obj(
|
||||
self._admin_ctxt,
|
||||
binary=constants.VOLUME_BINARY)
|
||||
|
@ -199,15 +201,18 @@ class SnapshotManageTest(test.TestCase):
|
|||
return_value=True,
|
||||
new_callable=mock.PropertyMock)
|
||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.manage_existing_snapshot')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db',
|
||||
return_value=mock.MagicMock(id=fake.SNAPSHOT_ID))
|
||||
@mock.patch('cinder.db.sqlalchemy.api.service_get')
|
||||
def test_manage_snapshot_disabled(self, mock_db, mock_create_snapshot,
|
||||
mock_rpcapi, mock_is_up):
|
||||
"""Test manage snapshot failure due to disabled service."""
|
||||
mock_db.return_value = fake_service.fake_service_obj(self._admin_ctxt,
|
||||
disabled=True)
|
||||
|
||||
body = {'snapshot': {'volume_id': fake.VOLUME_ID, 'ref': {
|
||||
'fake_key': 'fake_ref'}}}
|
||||
|
||||
res = self._get_resp_post(body)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, res.status_int, res)
|
||||
self.assertEqual(exception.ServiceUnavailable.message,
|
||||
|
@ -219,7 +224,8 @@ class SnapshotManageTest(test.TestCase):
|
|||
@mock.patch('cinder.objects.service.Service.is_up', return_value=False,
|
||||
new_callable=mock.PropertyMock)
|
||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.manage_existing_snapshot')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db',
|
||||
return_value=mock.MagicMock(id=fake.SNAPSHOT_ID))
|
||||
@mock.patch('cinder.db.sqlalchemy.api.service_get')
|
||||
def test_manage_snapshot_is_down(self, mock_db, mock_create_snapshot,
|
||||
mock_rpcapi, mock_is_up):
|
||||
|
@ -375,7 +381,8 @@ class SnapshotManageTest(test.TestCase):
|
|||
|
||||
@mock.patch(
|
||||
'cinder.scheduler.rpcapi.SchedulerAPI.manage_existing_snapshot')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db',
|
||||
return_value=mock.MagicMock(id=fake.SNAPSHOT_ID))
|
||||
@mock.patch('cinder.objects.service.Service.get_by_id')
|
||||
def test_manage_snapshot_with_null_validate(
|
||||
self, mock_db, mock_create_snapshot, mock_rpcapi):
|
||||
|
|
|
@ -774,7 +774,7 @@ def fake_volume_get_obj(self, context, volume_id, **kwargs):
|
|||
volume.status = 'available'
|
||||
|
||||
if volume_id == ENCRYPTED_VOLUME_ID:
|
||||
volume['encryption_key_id'] = 'does_not_matter'
|
||||
volume['encryption_key_id'] = fake.ENCRYPTION_KEY_ID
|
||||
|
||||
volume.volume_type = fake_volume.fake_volume_type_obj(
|
||||
context,
|
||||
|
|
|
@ -68,7 +68,8 @@ class SnapshotManageTest(test.TestCase):
|
|||
|
||||
@mock.patch(
|
||||
'cinder.scheduler.rpcapi.SchedulerAPI.manage_existing_snapshot')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
|
||||
@mock.patch('cinder.volume.api.API.create_snapshot_in_db',
|
||||
return_value=mock.MagicMock(id=fake.SNAPSHOT_ID))
|
||||
@mock.patch('cinder.objects.service.Service.get_by_id')
|
||||
def test_manage_snapshot_route(self, mock_service_get,
|
||||
mock_create_snapshot, mock_rpcapi):
|
||||
|
|
|
@ -1877,7 +1877,7 @@ class QuotaVolumeTypeReservationTestCase(test.TestCase):
|
|||
my_context = FakeContext('MyProject', None)
|
||||
volume = fake_volume.fake_volume_obj(my_context,
|
||||
name= 'my_vol_name',
|
||||
id= 'my_vol_id',
|
||||
id= fake.VOLUME_ID,
|
||||
size= 1,
|
||||
project_id= 'vol_project_id')
|
||||
quota_utils.get_volume_type_reservation(my_context,
|
||||
|
@ -1898,7 +1898,7 @@ class QuotaVolumeTypeReservationTestCase(test.TestCase):
|
|||
my_context = FakeContext('MyProject', None)
|
||||
volume = fake_volume.fake_volume_obj(my_context,
|
||||
name='my_vol_name',
|
||||
id='my_vol_id',
|
||||
id=fake.VOLUME_ID,
|
||||
size=1,
|
||||
project_id='vol_project_id')
|
||||
quota_utils.get_volume_type_reservation(my_context,
|
||||
|
|
|
@ -460,7 +460,7 @@ class TestCommonAdapter(test_base.TestCase):
|
|||
mocked_input):
|
||||
volume = mocked_input['volume']
|
||||
volume.metadata = {'async_migrate': 'True'}
|
||||
volume.snapshot_id = 'snap'
|
||||
volume.snapshot_id = fake_constants.SNAPSHOT_ID
|
||||
vnx_common.force_delete_lun_in_sg = True
|
||||
vnx_common.delete_volume(volume)
|
||||
lun = vnx_common.client.vnx.get_lun()
|
||||
|
|
|
@ -1370,7 +1370,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
'data': {
|
||||
'target_discovered': False,
|
||||
'discard': True,
|
||||
'volume_id': 12,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'target_iqns': ['group_target_name', 'group_target_name'],
|
||||
'target_luns': [0, 0],
|
||||
'target_portals': ['12', '13']}}
|
||||
|
@ -1379,7 +1379,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
self.driver.initialize_connection(
|
||||
{'name': 'test-volume',
|
||||
'provider_location': '12 group_target_name',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
{'initiator': 'test-initiator1'}))
|
||||
|
||||
@mock.patch(NIMBLE_URLLIB2)
|
||||
|
@ -1396,7 +1396,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
'data': {
|
||||
'target_discovered': False,
|
||||
'discard': True,
|
||||
'volume_id': 12,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'target_iqn': '13',
|
||||
'target_lun': 0,
|
||||
'target_portal': '12'}}
|
||||
|
@ -1406,13 +1406,13 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
self.driver.initialize_connection(
|
||||
{'name': 'test-volume',
|
||||
'provider_location': '12 13',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
{'initiator': 'test-initiator1'}))
|
||||
|
||||
self.driver.initialize_connection(
|
||||
{'name': 'test-volume',
|
||||
'provider_location': '12 13',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
{'initiator': 'test-initiator1'})
|
||||
|
||||
# 2 or more calls to initialize connection and add_acl for live
|
||||
|
@ -1421,12 +1421,12 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
mock.call.get_initiator_grp_list(),
|
||||
mock.call.add_acl({'name': 'test-volume',
|
||||
'provider_location': '12 13',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
'test-igrp1'),
|
||||
mock.call.get_initiator_grp_list(),
|
||||
mock.call.add_acl({'name': 'test-volume',
|
||||
'provider_location': '12 13',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
'test-igrp1')]
|
||||
self.mock_client_service.assert_has_calls(expected_calls)
|
||||
|
||||
|
@ -1458,7 +1458,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
self.driver.initialize_connection(
|
||||
{'name': 'test-volume',
|
||||
'provider_location': 'array1',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
{'initiator': 'test-initiator1',
|
||||
'wwpns': ['1000000000000000']}))
|
||||
|
||||
|
@ -1479,7 +1479,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
'target_discovered': False,
|
||||
'discard': True,
|
||||
'target_lun': 0,
|
||||
'volume_id': 12,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'target_iqn': '13',
|
||||
'target_portal': '12'}}
|
||||
self.assertEqual(
|
||||
|
@ -1487,7 +1487,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
self.driver.initialize_connection(
|
||||
{'name': 'test-volume',
|
||||
'provider_location': '12 13',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
{'initiator': 'test-initiator3'}))
|
||||
|
||||
@mock.patch(NIMBLE_URLLIB2)
|
||||
|
@ -1524,7 +1524,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
self.driver.initialize_connection(
|
||||
{'name': 'test-volume',
|
||||
'provider_location': 'array1',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
{'initiator': 'test-initiator3',
|
||||
'wwpns': ['1000000000000000']}))
|
||||
|
||||
|
@ -1548,7 +1548,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, multiattach=False)
|
||||
id=fake.VOLUME_ID, multiattach=False)
|
||||
|
||||
self.driver.terminate_connection(
|
||||
volume,
|
||||
|
@ -1573,7 +1573,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
self.driver.terminate_connection(
|
||||
{'name': 'test-volume',
|
||||
'provider_location': '12 13',
|
||||
'id': 12},
|
||||
'id': fake.VOLUME_ID},
|
||||
None)
|
||||
expected_calls = [mock.call._get_igroupname_for_initiator(
|
||||
'test-initiator1'),
|
||||
|
@ -1598,7 +1598,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=14, multiattach=False)
|
||||
id=fake.VOLUME_ID, multiattach=False)
|
||||
|
||||
self.driver.terminate_connection(
|
||||
volume,
|
||||
|
@ -1628,7 +1628,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, multiattach=False)
|
||||
id=fake.VOLUME_ID, multiattach=False)
|
||||
|
||||
self.assertRaises(
|
||||
exception.VolumeDriverException,
|
||||
|
@ -1652,7 +1652,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, multiattach=False)
|
||||
id=fake.VOLUME_ID, multiattach=False)
|
||||
self.assertRaises(
|
||||
exception.VolumeDriverException,
|
||||
self.driver.terminate_connection,
|
||||
|
@ -1679,7 +1679,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, multiattach=True)
|
||||
id=fake.VOLUME_ID, multiattach=True)
|
||||
volume.volume_attachment.objects = [att_1, att_2]
|
||||
self.driver.terminate_connection(
|
||||
volume,
|
||||
|
@ -1703,7 +1703,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, multiattach=True)
|
||||
id=fake.VOLUME_ID, multiattach=True)
|
||||
volume.volume_attachment.objects = [att_1]
|
||||
self.driver.terminate_connection(
|
||||
volume,
|
||||
|
@ -1737,7 +1737,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, multiattach=True)
|
||||
id=fake.VOLUME_ID, multiattach=True)
|
||||
volume.volume_attachment.objects = [att_1, att_2]
|
||||
self.driver.terminate_connection(
|
||||
volume,
|
||||
|
@ -1764,7 +1764,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='test-volume',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, multiattach=True)
|
||||
id=fake.VOLUME_ID, multiattach=True)
|
||||
volume.volume_attachment.objects = [att_1]
|
||||
self.driver.terminate_connection(
|
||||
volume,
|
||||
|
@ -1887,7 +1887,7 @@ class NimbleDriverConnectionTestCase(NimbleDriverBaseTestCase):
|
|||
ctx, name='testvolume-cg1',
|
||||
host='fakehost@nimble#Openstack',
|
||||
provider_location='12 13',
|
||||
id=12, consistency_group_snapshot_enabled=True)
|
||||
id=fake.VOLUME_ID, consistency_group_snapshot_enabled=True)
|
||||
addvollist = [volume1]
|
||||
remvollist = [volume1]
|
||||
model_update = self.driver.update_group(
|
||||
|
|
|
@ -22,6 +22,7 @@ import requests
|
|||
from six.moves.urllib import parse
|
||||
|
||||
from cinder import exception
|
||||
from cinder.tests.unit import fake_constants as fake
|
||||
from cinder.tests.unit import fake_snapshot
|
||||
from cinder.tests.unit import fake_volume
|
||||
from cinder.tests.unit import test
|
||||
|
@ -796,7 +797,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_create_destroy(self):
|
||||
"""Create/Delete volume."""
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 1}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
self.driver.create_volume(volume)
|
||||
self.driver.delete_volume(volume)
|
||||
|
@ -804,10 +806,14 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_create_destroy_multiple(self):
|
||||
"""Create/Delete multiple volumes."""
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 1}
|
||||
vol2_args = {'display_name': 'test_volume_02', 'size': 2, 'id': 2}
|
||||
vol3_args = {'display_name': 'test_volume_03', 'size': 3, 'id': 3}
|
||||
vol4_args = {'display_name': 'test_volume_04', 'size': 4, 'id': 4}
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
vol2_args = {'display_name': 'test_volume_02', 'size': 2,
|
||||
'id': fake.VOLUME2_ID}
|
||||
vol3_args = {'display_name': 'test_volume_03', 'size': 3,
|
||||
'id': fake.VOLUME3_ID}
|
||||
vol4_args = {'display_name': 'test_volume_04', 'size': 4,
|
||||
'id': fake.VOLUME4_ID}
|
||||
volume1 = fake_volume.fake_volume_obj(None, **vol1_args)
|
||||
volume2 = fake_volume.fake_volume_obj(None, **vol2_args)
|
||||
volume3 = fake_volume.fake_volume_obj(None, **vol3_args)
|
||||
|
@ -824,7 +830,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_destroy_non_existent(self):
|
||||
"""Delete non-existent volume."""
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 1}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
self.driver.delete_volume(volume)
|
||||
|
||||
|
@ -832,7 +839,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
def test_empty_apis(self):
|
||||
"""Test empty func (for coverage only)."""
|
||||
context = None
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 1}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
self.driver.create_export(context, volume)
|
||||
self.driver.ensure_export(context, volume)
|
||||
|
@ -845,7 +853,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_volume_attach_detach(self):
|
||||
"""Test volume attachment and detach."""
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': '123'}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
connector = dict(initiator='test_iqn.1')
|
||||
self.driver.create_volume(volume)
|
||||
|
@ -866,7 +875,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_wrong_attach_params(self):
|
||||
"""Test different wrong attach scenarios."""
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 101}
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume1 = fake_volume.fake_volume_obj(None, **vol1_args)
|
||||
connector1 = dict(initiator='test_iqn.1')
|
||||
self.assertRaises(exception.VolumeDriverException,
|
||||
|
@ -876,7 +886,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_wrong_detach_params(self):
|
||||
"""Test different wrong detachment scenarios."""
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 101}
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume1 = fake_volume.fake_volume_obj(None, **vol1_args)
|
||||
# Volume is not created.
|
||||
self.assertRaises(exception.VolumeDriverException,
|
||||
|
@ -890,8 +901,10 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
self.driver.terminate_connection,
|
||||
volume1, connector1)
|
||||
|
||||
vol2_args = {'display_name': 'test_volume_02', 'size': 1, 'id': 102}
|
||||
vol3_args = {'display_name': 'test_volume_03', 'size': 1, 'id': 103}
|
||||
vol2_args = {'display_name': 'test_volume_02', 'size': 1,
|
||||
'id': fake.VOLUME2_ID}
|
||||
vol3_args = {'display_name': 'test_volume_03', 'size': 1,
|
||||
'id': fake.VOLUME3_ID}
|
||||
volume2 = fake_volume.fake_volume_obj(None, **vol2_args)
|
||||
volume3 = fake_volume.fake_volume_obj(None, **vol3_args)
|
||||
connector2 = dict(initiator='test_iqn.2')
|
||||
|
@ -963,7 +976,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
"""Coverage test for non-good HTTP response."""
|
||||
RUNTIME_VARS['status'] = 400
|
||||
|
||||
vol_args = {'display_name': 'test_volume_03', 'size': 1, 'id': 1}
|
||||
vol_args = {'display_name': 'test_volume_03', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
self.assertRaises(exception.BadHTTPResponseStatus,
|
||||
self.driver.create_volume, volume)
|
||||
|
@ -971,7 +985,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_terminate_connection_force_detach(self):
|
||||
"""Test terminate connection for os-force_detach """
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 101}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
connector = dict(initiator='test_iqn.1')
|
||||
|
||||
|
@ -991,7 +1006,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
def test_delete_without_detach(self):
|
||||
"""Test volume deletion without detach."""
|
||||
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 101}
|
||||
vol1_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume1 = fake_volume.fake_volume_obj(None, **vol1_args)
|
||||
connector1 = dict(initiator='test_iqn.1')
|
||||
connector2 = dict(initiator='test_iqn.2')
|
||||
|
@ -1005,7 +1021,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_no_active_ctrl(self):
|
||||
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 123}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
connector = dict(initiator='test_iqn.1')
|
||||
self.driver.create_volume(volume)
|
||||
|
@ -1018,7 +1035,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_create_destroy_snapshot(self):
|
||||
"""Create/Delete snapshot test."""
|
||||
wrong_vol_args = {'display_name': 'wrong_vol_01', 'size': 1, 'id': 2}
|
||||
wrong_vol_args = {'display_name': 'wrong_vol_01', 'size': 1,
|
||||
'id': fake.VOLUME2_ID}
|
||||
wrong_volume = fake_volume.fake_volume_obj(None, **wrong_vol_args)
|
||||
wrong_snap_args = {'display_name': 'snap_01', 'volume': wrong_volume}
|
||||
wrong_snapshot = fake_snapshot.fake_snapshot_obj(None,
|
||||
|
@ -1028,9 +1046,11 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
wrong_snapshot)
|
||||
|
||||
# Create cinder volume and snapshot
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 1}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
snap_args = {'display_name': 'test_snap_01', 'id': 1, 'volume': volume}
|
||||
snap_args = {'display_name': 'test_snap_01', 'id': fake.SNAPSHOT_ID,
|
||||
'volume': volume}
|
||||
snapshot = fake_snapshot.fake_snapshot_obj(None, **snap_args)
|
||||
self.driver.create_volume(volume)
|
||||
self.driver.create_snapshot(snapshot)
|
||||
|
@ -1040,7 +1060,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
# Deleted should succeed for missing snap
|
||||
fake_snap_args = {'display_name': 'test_snap_02',
|
||||
'id': 2, 'volume': volume}
|
||||
'id': fake.SNAPSHOT2_ID, 'volume': volume}
|
||||
fake_snap = fake_snapshot.fake_snapshot_obj(None, **fake_snap_args)
|
||||
self.driver.delete_snapshot(fake_snap)
|
||||
|
||||
|
@ -1050,8 +1070,10 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_expand_volume(self):
|
||||
"""Expand volume test."""
|
||||
vol_args = {'display_name': 'test_volume_01', 'id': 1, 'size': 10}
|
||||
vol2_args = {'display_name': 'test_volume_02', 'id': 2, 'size': 10}
|
||||
vol_args = {'display_name': 'test_volume_01', 'id': fake.VOLUME_ID,
|
||||
'size': 10}
|
||||
vol2_args = {'display_name': 'test_volume_02', 'id': fake.VOLUME2_ID,
|
||||
'size': 10}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
volume2 = fake_volume.fake_volume_obj(None, **vol2_args)
|
||||
|
||||
|
@ -1070,25 +1092,28 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_create_destroy_clones(self):
|
||||
"""Create/Delete clones test."""
|
||||
vol1_args = {'display_name': 'test_volume_01', 'id': 1, 'size': 1}
|
||||
vol2_args = {'display_name': 'test_volume_02', 'id': 2, 'size': 2}
|
||||
vol3_args = {'display_name': 'test_volume_03', 'id': 3, 'size': 1}
|
||||
vol1_args = {'display_name': 'test_volume_01', 'id': fake.VOLUME_ID,
|
||||
'size': 1}
|
||||
vol2_args = {'display_name': 'test_volume_02', 'id': fake.VOLUME2_ID,
|
||||
'size': 2}
|
||||
vol3_args = {'display_name': 'test_volume_03', 'id': fake.VOLUME3_ID,
|
||||
'size': 1}
|
||||
volume1 = fake_volume.fake_volume_obj(None, **vol1_args)
|
||||
volume2 = fake_volume.fake_volume_obj(None, **vol2_args)
|
||||
volume3 = fake_volume.fake_volume_obj(None, **vol3_args)
|
||||
|
||||
snap_args = {'display_name': 'test_snap_01',
|
||||
'id': 1, 'volume': volume1}
|
||||
'id': fake.SNAPSHOT_ID, 'volume': volume1}
|
||||
snapshot = fake_snapshot.fake_snapshot_obj(None, **snap_args)
|
||||
self.driver.create_volume(volume1)
|
||||
self.driver.create_snapshot(snapshot)
|
||||
|
||||
# Test invalid vol reference
|
||||
wrong_vol_args = {'display_name': 'wrong_volume_01',
|
||||
'id': 4, 'size': 1}
|
||||
'id': fake.VOLUME4_ID, 'size': 1}
|
||||
wrong_volume = fake_volume.fake_volume_obj(None, **wrong_vol_args)
|
||||
wrong_snap_args = {'display_name': 'test_wrong_snap',
|
||||
'id': 2, 'volume': wrong_volume}
|
||||
'id': fake.SNAPSHOT2_ID, 'volume': wrong_volume}
|
||||
wrong_snapshot = fake_snapshot.fake_snapshot_obj(None,
|
||||
**wrong_snap_args)
|
||||
self.assertRaises(exception.SnapshotNotFound,
|
||||
|
@ -1097,7 +1122,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
wrong_snapshot)
|
||||
|
||||
wrong_snap_args = {'display_name': 'test_wrong_snap',
|
||||
'id': 4, 'volume': volume1}
|
||||
'id': fake.SNAPSHOT3_ID, 'volume': volume1}
|
||||
wrong_snapshot = fake_snapshot.fake_snapshot_obj(None,
|
||||
**wrong_snap_args)
|
||||
# Test invalid snap reference
|
||||
|
@ -1157,7 +1182,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_manage_existing_volume(self):
|
||||
vol_args = {'id': 'manage-name',
|
||||
vol_args = {'id': fake.VOLUME_ID,
|
||||
'display_name': 'manage-name',
|
||||
'size': 1}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
|
@ -1185,7 +1210,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_manage_existing_snapshot(self):
|
||||
vol_args = {'display_name': 'fake_name', 'size': 1, 'id': 1}
|
||||
vol_args = {'display_name': 'fake_name', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
self.driver.create_volume(volume)
|
||||
|
||||
|
@ -1195,7 +1221,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
# Check the failure with wrong volume for snapshot
|
||||
wrong_vol_args = {'display_name': 'wrong_volume_01',
|
||||
'size': 1, 'id': 2}
|
||||
'size': 1, 'id': fake.VOLUME2_ID}
|
||||
wrong_volume = fake_volume.fake_volume_obj(None, **wrong_vol_args)
|
||||
wrong_snap_args = {'display_name': 'snap_01', 'volume': wrong_volume}
|
||||
wrong_snapshot = fake_snapshot.fake_snapshot_obj(None,
|
||||
|
@ -1212,7 +1238,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
# Check the failure with wrong identifier for the snapshot
|
||||
snap_args = {'display_name': 'manage_snapname',
|
||||
'id': 'manage_snapname', 'volume': volume}
|
||||
'id': fake.SNAPSHOT_ID, 'volume': volume}
|
||||
snapshot = fake_snapshot.fake_snapshot_obj(None, **snap_args)
|
||||
self.assertRaises(exception.ManageExistingInvalidReference,
|
||||
self.driver.manage_existing_snapshot,
|
||||
|
@ -1236,9 +1262,9 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
'Available', 'NO')
|
||||
|
||||
cinder_vol1_args = {'display_name': 'fake-volume1',
|
||||
'size': 3, 'id': 'fake-volume1'}
|
||||
'size': 3, 'id': fake.VOLUME_ID}
|
||||
cinder_vol2_args = {'display_name': 'fake-volume2',
|
||||
'size': 4, 'id': 'fake-volume2'}
|
||||
'size': 4, 'id': fake.VOLUME2_ID}
|
||||
cinder_vol1 = fake_volume.fake_volume_obj(None, **cinder_vol1_args)
|
||||
cinder_vol2 = fake_volume.fake_volume_obj(None, **cinder_vol2_args)
|
||||
self.driver.create_volume(cinder_vol1)
|
||||
|
@ -1258,7 +1284,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
# Try to manage the volume and delete it
|
||||
vol1_args = {'display_name': 'manage-name1',
|
||||
'size': 1, 'id': 'manage-name1'}
|
||||
'size': 1, 'id': fake.VOLUME3_ID}
|
||||
volume1 = fake_volume.fake_volume_obj(None, **vol1_args)
|
||||
identifier = {'name': 'manage_vol1'}
|
||||
self.driver.manage_existing(volume1, identifier)
|
||||
|
@ -1268,7 +1294,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
# Manage and delete the volume
|
||||
vol2_args = {'display_name': 'manage-name2',
|
||||
'size': 1, 'id': 'manage-name2'}
|
||||
'size': 1, 'id': fake.VOLUME4_ID}
|
||||
volume2 = fake_volume.fake_volume_obj(None, **vol2_args)
|
||||
identifier = {'name': 'manage_vol2'}
|
||||
self.driver.manage_existing(volume2, identifier)
|
||||
|
@ -1279,10 +1305,11 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_get_manageable_snapshots(self):
|
||||
# Create a cinder volume and a snapshot
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1, 'id': 1}
|
||||
vol_args = {'display_name': 'test_volume_01', 'size': 1,
|
||||
'id': fake.VOLUME_ID}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
snap_args = {'display_name': 'test_snap_01',
|
||||
'id': 1, 'volume': volume}
|
||||
'id': fake.SNAPSHOT_ID, 'volume': volume}
|
||||
snapshot = fake_snapshot.fake_snapshot_obj(None, **snap_args)
|
||||
self.driver.create_volume(volume)
|
||||
self.driver.create_snapshot(snapshot)
|
||||
|
@ -1322,7 +1349,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
|
||||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_manage_existing_volume_get_size(self):
|
||||
vol_args = {'display_name': 'fake_name', 'id': 1, 'size': 1}
|
||||
vol_args = {'display_name': 'fake_name', 'id': fake.VOLUME_ID,
|
||||
'size': 1}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
self.driver.create_volume(volume)
|
||||
|
||||
|
@ -1347,17 +1375,18 @@ class ZadaraVPSADriverTestCase(test.TestCase):
|
|||
@mock.patch.object(requests.Session, 'request', FakeRequests)
|
||||
def test_manage_existing_snapshot_get_size(self):
|
||||
# Create a cinder volume and a snapshot
|
||||
vol_args = {'display_name': 'fake_name', 'id': 1, 'size': 1}
|
||||
vol_args = {'display_name': 'fake_name', 'id': fake.VOLUME_ID,
|
||||
'size': 1}
|
||||
volume = fake_volume.fake_volume_obj(None, **vol_args)
|
||||
self.driver.create_volume(volume)
|
||||
snap_args = {'display_name': 'fake_snap',
|
||||
'id': 1, 'volume': volume}
|
||||
'id': fake.SNAPSHOT_ID, 'volume': volume}
|
||||
snapshot = fake_snapshot.fake_snapshot_obj(None, **snap_args)
|
||||
self.driver.create_snapshot(snapshot)
|
||||
|
||||
# Check with the wrong volume of the snapshot
|
||||
wrong_vol_args = {'display_name': 'wrong_volume_01',
|
||||
'size': 1, 'id': 2}
|
||||
'size': 1, 'id': fake.VOLUME2_ID}
|
||||
wrong_volume = fake_volume.fake_volume_obj(None, **wrong_vol_args)
|
||||
wrong_snap_args = {'display_name': 'wrong_snap',
|
||||
'volume': wrong_volume}
|
||||
|
|
|
@ -204,7 +204,8 @@ class CreateVolumeFlowTestCase(test.TestCase):
|
|||
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.ctxt)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
volume_get_by_id.return_value = volume_obj
|
||||
volume_create.return_value = {'id': '123456', 'volume_attachment': []}
|
||||
volume_create.return_value = {'id': fakes.VOLUME_ID,
|
||||
'volume_attachment': []}
|
||||
|
||||
task = create_volume.EntryCreateTask()
|
||||
|
||||
|
@ -253,7 +254,8 @@ class CreateVolumeFlowTestCase(test.TestCase):
|
|||
volume_db = {'bootable': bootable}
|
||||
volume_obj = fake_volume.fake_volume_obj(self.ctxt, **volume_db)
|
||||
volume_get_by_id.return_value = volume_obj
|
||||
volume_create.return_value = {'id': '123456', 'volume_attachment': []}
|
||||
volume_create.return_value = {'id': fakes.VOLUME_ID,
|
||||
'volume_attachment': []}
|
||||
task = create_volume.EntryCreateTask()
|
||||
|
||||
result = task.execute(self.ctxt,
|
||||
|
|
Loading…
Reference in New Issue