Tests: Make tests less random
Remove a bunch of uuid.uuid4() calls from tests, and use static UUIDs instead. We generally use static UUIDs to make test runs reproducible and to make it easier to track odd failures that repeat in the gate. Readability of tests is also improved by using meaningful names like VOLUME_ID or SNAPSHOT_ID rather than just uuid4(). So, do more of that. Some care has to be taken in test classes that create lots of volumes, such as BackupBaseDriverTestCase, because random UUIDs were previously allowing volumes used by different tests to not collide with each other. More static IDs have been added to account for this. Change-Id: I372d27367b730f4606bc0ea84a9b322d45d1cbbe
This commit is contained in:
parent
4689d3272e
commit
b83c446e52
|
@ -14,13 +14,11 @@
|
|||
|
||||
import datetime
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging as messaging
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
from six.moves import http_client
|
||||
import webob
|
||||
|
||||
|
@ -58,7 +56,6 @@ class VolumeActionsTest(test.TestCase):
|
|||
super(VolumeActionsTest, self).setUp()
|
||||
self.context = context.RequestContext(fake.USER_ID, fake.PROJECT_ID,
|
||||
is_admin=False)
|
||||
self.UUID = six.text_type(uuid.uuid4())
|
||||
self.controller = volume_actions.VolumeActionsController()
|
||||
self.api_patchers = {}
|
||||
for _meth in self._methods:
|
||||
|
@ -93,7 +90,7 @@ class VolumeActionsTest(test.TestCase):
|
|||
app = fakes.wsgi_app(fake_auth_context=self.context)
|
||||
for _action in self._actions:
|
||||
req = webob.Request.blank('/v2/%s/volumes/%s/action' %
|
||||
(fake.PROJECT_ID, self.UUID))
|
||||
(fake.PROJECT_ID, fake.VOLUME_ID))
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dump_as_bytes({_action: None})
|
||||
req.content_type = 'application/json'
|
||||
|
@ -257,7 +254,7 @@ class VolumeActionsTest(test.TestCase):
|
|||
with mock.patch.object(volume_api.API, 'attach',
|
||||
side_effect=volume_remote_error):
|
||||
id = fake.VOLUME_ID
|
||||
vol = {"instance_uuid": self.UUID,
|
||||
vol = {"instance_uuid": fake.INSTANCE_ID,
|
||||
"mountpoint": "/dev/vdc",
|
||||
"mode": "rw"}
|
||||
body = {"os-attach": vol}
|
||||
|
@ -276,7 +273,7 @@ class VolumeActionsTest(test.TestCase):
|
|||
with mock.patch.object(volume_api.API, 'attach',
|
||||
side_effect=volume_remote_error):
|
||||
id = fake.VOLUME_ID
|
||||
vol = {"instance_uuid": self.UUID,
|
||||
vol = {"instance_uuid": fake.INSTANCE_ID,
|
||||
"mountpoint": "/dev/vdc",
|
||||
"mode": "rw"}
|
||||
body = {"os-attach": vol}
|
||||
|
@ -318,7 +315,7 @@ class VolumeActionsTest(test.TestCase):
|
|||
with mock.patch.object(volume_api.API, 'detach',
|
||||
side_effect=volume_remote_error):
|
||||
id = fake.VOLUME_ID
|
||||
vol = {"attachment_id": self.UUID}
|
||||
vol = {"attachment_id": fake.ATTACHMENT_ID}
|
||||
body = {"os-detach": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes/%s/action' %
|
||||
(fake.PROJECT_ID, id))
|
||||
|
@ -335,7 +332,7 @@ class VolumeActionsTest(test.TestCase):
|
|||
with mock.patch.object(volume_api.API, 'detach',
|
||||
side_effect=volume_remote_error):
|
||||
id = fake.VOLUME_ID
|
||||
vol = {"attachment_id": self.UUID}
|
||||
vol = {"attachment_id": fake.ATTACHMENT_ID}
|
||||
body = {"os-detach": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes/%s/action' %
|
||||
(fake.PROJECT_ID, id))
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
import webob
|
||||
|
@ -71,7 +69,7 @@ class VolumeMigStatusAttributeTest(test.TestCase):
|
|||
super(VolumeMigStatusAttributeTest, self).setUp()
|
||||
self.mock_object(volume.api.API, 'get', fake_volume_api_get)
|
||||
self.mock_object(volume.api.API, 'get_all', fake_volume_get_all)
|
||||
self.UUID = uuid.uuid4()
|
||||
self.UUID = fake.UUID1
|
||||
|
||||
def test_get_volume_allowed(self):
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
@ -248,7 +247,7 @@ class VolumeTypesApiTest(test.TestCase):
|
|||
self.mock_object(volume_types, 'get_volume_type',
|
||||
return_volume_types_get_volume_type)
|
||||
|
||||
type_id = str(uuid.uuid4())
|
||||
type_id = fake.VOLUME_TYPE_ID
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/' % fake.PROJECT_ID
|
||||
+ type_id)
|
||||
res_dict = self.controller.show(req, type_id)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -128,7 +127,7 @@ class VolumeMetaDataTest(test.TestCase):
|
|||
self.ext_mgr.extensions = {}
|
||||
self.volume_controller = volumes.VolumeController(self.ext_mgr)
|
||||
self.controller = volume_metadata.Controller()
|
||||
self.req_id = str(uuid.uuid4())
|
||||
self.req_id = fake.REQUEST_ID
|
||||
self.url = '/v2/%s/volumes/%s/metadata' % (
|
||||
fake.PROJECT_ID, self.req_id)
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import os
|
|||
import tempfile
|
||||
import threading
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
from os_brick.initiator import linuxrbd
|
||||
|
@ -116,8 +115,8 @@ class BackupCephTestCase(test.TestCase):
|
|||
return db.volume_create(self.ctxt, vol)['id']
|
||||
|
||||
def _create_backup_db_entry(self, backupid, volid, size,
|
||||
userid=str(uuid.uuid4()),
|
||||
projectid=str(uuid.uuid4())):
|
||||
userid=fake.USER_ID,
|
||||
projectid=fake.PROJECT_ID):
|
||||
backup = {'id': backupid, 'size': size, 'volume_id': volid,
|
||||
'user_id': userid, 'project_id': projectid}
|
||||
return db.backup_create(self.ctxt, backup)['id']
|
||||
|
@ -170,12 +169,12 @@ class BackupCephTestCase(test.TestCase):
|
|||
|
||||
# Create volume.
|
||||
self.volume_size = 1
|
||||
self.volume_id = str(uuid.uuid4())
|
||||
self.volume_id = fake.VOLUME_ID
|
||||
self._create_volume_db_entry(self.volume_id, self.volume_size)
|
||||
self.volume = db.volume_get(self.ctxt, self.volume_id)
|
||||
|
||||
# Create backup of volume.
|
||||
self.backup_id = str(uuid.uuid4())
|
||||
self.backup_id = fake.BACKUP_ID
|
||||
self._create_backup_db_entry(self.backup_id, self.volume_id,
|
||||
self.volume_size)
|
||||
self.backup = objects.Backup.get_by_id(self.ctxt, self.backup_id)
|
||||
|
@ -198,7 +197,7 @@ class BackupCephTestCase(test.TestCase):
|
|||
self.alt_backup.parent.service_metadata = '{"base": "%s"}' % base_name
|
||||
|
||||
# Create alternate volume.
|
||||
self.alt_volume_id = str(uuid.uuid4())
|
||||
self.alt_volume_id = fake.VOLUME2_ID
|
||||
self._create_volume_db_entry(self.alt_volume_id, self.volume_size)
|
||||
self.alt_volume = db.volume_get(self.ctxt, self.alt_volume_id)
|
||||
|
||||
|
@ -284,11 +283,11 @@ class BackupCephTestCase(test.TestCase):
|
|||
|
||||
@common_mocks
|
||||
def test_get_backup_snap_name(self):
|
||||
snap_name = 'backup.%s.snap.3824923.1412' % (uuid.uuid4())
|
||||
snap_name = 'backup.%s.snap.3824923.1412' % (fake.VOLUME3_ID)
|
||||
|
||||
def get_backup_snaps(inst, *args):
|
||||
return [{'name': 'backup.%s.snap.6423868.2342' % (uuid.uuid4()),
|
||||
'backup_id': str(uuid.uuid4())},
|
||||
return [{'name': 'backup.%s.snap.6423868.2342' % (fake.UUID1),
|
||||
'backup_id': fake.BACKUP2_ID},
|
||||
{'name': snap_name,
|
||||
'backup_id': self.backup_id}]
|
||||
|
||||
|
@ -311,11 +310,11 @@ class BackupCephTestCase(test.TestCase):
|
|||
def test_get_backup_snaps(self):
|
||||
image = self.mock_rbd.Image.return_value
|
||||
image.list_snaps.return_value = [
|
||||
{'name': 'backup.%s.snap.6423868.2342' % (uuid.uuid4())},
|
||||
{'name': 'backup.%s.wambam.6423868.2342' % (uuid.uuid4())},
|
||||
{'name': 'backup.%s.snap.1321319.3235' % (uuid.uuid4())},
|
||||
{'name': 'bbbackup.%s.snap.1321319.3235' % (uuid.uuid4())},
|
||||
{'name': 'backup.%s.snap.3824923.1412' % (uuid.uuid4())}]
|
||||
{'name': 'backup.%s.snap.6423868.2342' % (fake.UUID1)},
|
||||
{'name': 'backup.%s.wambam.6423868.2342' % (fake.UUID2)},
|
||||
{'name': 'backup.%s.snap.1321319.3235' % (fake.UUID3)},
|
||||
{'name': 'bbbackup.%s.snap.1321319.3235' % (fake.UUID4)},
|
||||
{'name': 'backup.%s.snap.3824923.1412' % (fake.UUID5)}]
|
||||
snaps = self.service.get_backup_snaps(image)
|
||||
self.assertEqual(3, len(snaps))
|
||||
|
||||
|
@ -860,9 +859,9 @@ class BackupCephTestCase(test.TestCase):
|
|||
|
||||
@common_mocks
|
||||
def test_backup_vol_length_0(self):
|
||||
volume_id = fake.VOLUME_ID
|
||||
volume_id = fake.VOLUME4_ID
|
||||
self._create_volume_db_entry(volume_id, 0)
|
||||
backup_id = fake.BACKUP_ID
|
||||
backup_id = fake.BACKUP4_ID
|
||||
self._create_backup_db_entry(backup_id, volume_id, 1)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, backup_id)
|
||||
|
||||
|
@ -872,7 +871,7 @@ class BackupCephTestCase(test.TestCase):
|
|||
@common_mocks
|
||||
def test_backup_with_container_name(self):
|
||||
volume_size = self.volume_size * units.Gi
|
||||
backup_id = fake.BACKUP_ID
|
||||
backup_id = fake.BACKUP4_ID
|
||||
self._create_backup_db_entry(backup_id, self.volume_id, 1)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, backup_id)
|
||||
backup.container = "test"
|
||||
|
@ -1003,7 +1002,7 @@ class BackupCephTestCase(test.TestCase):
|
|||
|
||||
@common_mocks
|
||||
def test_delete_backup_snapshot(self):
|
||||
snap_name = 'backup.%s.snap.3824923.1412' % (uuid.uuid4())
|
||||
snap_name = 'backup.%s.snap.3824923.1412' % fake.UUID1
|
||||
base_name = self.service._get_backup_base_name(self.volume_id)
|
||||
self.mock_rbd.RBD.remove_snap = mock.Mock()
|
||||
thread_dict = {}
|
||||
|
@ -1470,7 +1469,7 @@ class VolumeMetadataBackupTestCase(test.TestCase):
|
|||
global RAISED_EXCEPTIONS
|
||||
RAISED_EXCEPTIONS = []
|
||||
super(VolumeMetadataBackupTestCase, self).setUp()
|
||||
self.backup_id = str(uuid.uuid4())
|
||||
self.backup_id = fake.BACKUP_ID
|
||||
self.mb = ceph.VolumeMetadataBackup(mock.Mock(), self.backup_id)
|
||||
|
||||
@common_meta_backup_mocks
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
""" Tests for the backup service base driver. """
|
||||
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
|
@ -25,6 +24,7 @@ from cinder import db
|
|||
from cinder import exception
|
||||
from cinder import objects
|
||||
from cinder.tests.unit.backup import fake_service
|
||||
from cinder.tests.unit import fake_constants as fake
|
||||
from cinder.tests.unit import test
|
||||
|
||||
_backup_db_fields = ['id', 'user_id', 'project_id',
|
||||
|
@ -43,8 +43,8 @@ class BackupBaseDriverTestCase(test.TestCase):
|
|||
return db.volume_create(self.ctxt, vol)['id']
|
||||
|
||||
def _create_backup_db_entry(self, backupid, volid, size,
|
||||
userid=str(uuid.uuid4()),
|
||||
projectid=str(uuid.uuid4())):
|
||||
userid=fake.USER_ID,
|
||||
projectid=fake.PROJECT_ID):
|
||||
backup = {'id': backupid, 'size': size, 'volume_id': volid,
|
||||
'user_id': userid, 'project_id': projectid}
|
||||
return db.backup_create(self.ctxt, backup)['id']
|
||||
|
@ -53,8 +53,8 @@ class BackupBaseDriverTestCase(test.TestCase):
|
|||
super(BackupBaseDriverTestCase, self).setUp()
|
||||
self.ctxt = context.get_admin_context()
|
||||
|
||||
self.volume_id = str(uuid.uuid4())
|
||||
self.backup_id = str(uuid.uuid4())
|
||||
self.volume_id = fake.VOLUME_ID
|
||||
self.backup_id = fake.BACKUP_ID
|
||||
|
||||
self._create_backup_db_entry(self.backup_id, self.volume_id, 1)
|
||||
self._create_volume_db_entry(self.volume_id, 1)
|
||||
|
@ -97,8 +97,8 @@ class BackupMetadataAPITestCase(test.TestCase):
|
|||
def setUp(self):
|
||||
super(BackupMetadataAPITestCase, self).setUp()
|
||||
self.ctxt = context.get_admin_context()
|
||||
self.volume_id = str(uuid.uuid4())
|
||||
self.backup_id = str(uuid.uuid4())
|
||||
self.volume_id = fake.VOLUME2_ID
|
||||
self.backup_id = fake.BACKUP2_ID
|
||||
self.volume_display_name = 'vol-1'
|
||||
self.volume_display_description = 'test vol'
|
||||
self._create_volume_db_entry(self.volume_id, 1,
|
||||
|
@ -179,7 +179,7 @@ class BackupMetadataAPITestCase(test.TestCase):
|
|||
self.bak_meta_api.TYPE_TAG_VOL_GLANCE_META: {}}
|
||||
|
||||
# Emulate restore to new volume
|
||||
volume_id = str(uuid.uuid4())
|
||||
volume_id = fake.VOLUME3_ID
|
||||
vol_name = 'restore_backup_%s' % (self.backup_id)
|
||||
self._create_volume_db_entry(volume_id, 1, vol_name, 'fake volume')
|
||||
|
||||
|
@ -284,7 +284,7 @@ class BackupMetadataAPITestCase(test.TestCase):
|
|||
|
||||
def _create_encrypted_volume_db_entry(self, id, type_id, encrypted):
|
||||
if encrypted:
|
||||
key_id = str(uuid.uuid4())
|
||||
key_id = fake.ENCRYPTION_KEY_ID
|
||||
vol = {'id': id, 'size': 1, 'status': 'available',
|
||||
'volume_type_id': type_id, 'encryption_key_id': key_id}
|
||||
else:
|
||||
|
@ -297,12 +297,12 @@ class BackupMetadataAPITestCase(test.TestCase):
|
|||
container = {}
|
||||
|
||||
# Create an encrypted volume
|
||||
enc_vol1_id = self._create_encrypted_volume_db_entry(str(uuid.uuid4()),
|
||||
enc_vol1_id = self._create_encrypted_volume_db_entry(fake.VOLUME4_ID,
|
||||
'enc_vol_type',
|
||||
True)
|
||||
|
||||
# Create a second encrypted volume, of a different volume type
|
||||
enc_vol2_id = self._create_encrypted_volume_db_entry(str(uuid.uuid4()),
|
||||
enc_vol2_id = self._create_encrypted_volume_db_entry(fake.VOLUME5_ID,
|
||||
'enc_vol_type2',
|
||||
True)
|
||||
|
||||
|
@ -318,12 +318,12 @@ class BackupMetadataAPITestCase(test.TestCase):
|
|||
container = {}
|
||||
|
||||
# Create an unencrypted volume
|
||||
vol1_id = self._create_encrypted_volume_db_entry(str(uuid.uuid4()),
|
||||
vol1_id = self._create_encrypted_volume_db_entry(fake.VOLUME6_ID,
|
||||
'vol_type1',
|
||||
False)
|
||||
|
||||
# Create a second unencrypted volume, of a different volume type
|
||||
vol2_id = self._create_encrypted_volume_db_entry(str(uuid.uuid4()),
|
||||
vol2_id = self._create_encrypted_volume_db_entry(fake.VOLUME7_ID,
|
||||
'vol_type2',
|
||||
False)
|
||||
|
||||
|
@ -341,12 +341,12 @@ class BackupMetadataAPITestCase(test.TestCase):
|
|||
container = {}
|
||||
|
||||
# Create an encrypted volume
|
||||
enc_vol1_id = self._create_encrypted_volume_db_entry(str(uuid.uuid4()),
|
||||
enc_vol1_id = self._create_encrypted_volume_db_entry(fake.VOLUME8_ID,
|
||||
'enc_vol_type',
|
||||
True)
|
||||
|
||||
# Create an encrypted volume of the same type
|
||||
enc_vol2_id = self._create_encrypted_volume_db_entry(str(uuid.uuid4()),
|
||||
enc_vol2_id = self._create_encrypted_volume_db_entry(fake.VOLUME9_ID,
|
||||
'enc_vol_type',
|
||||
True)
|
||||
|
||||
|
|
|
@ -132,8 +132,8 @@ class BaseBackupTest(test.TestCase):
|
|||
vol = {}
|
||||
vol['size'] = size
|
||||
vol['host'] = host
|
||||
vol['user_id'] = str(uuid.uuid4())
|
||||
vol['project_id'] = str(uuid.uuid4())
|
||||
vol['user_id'] = fake.USER_ID
|
||||
vol['project_id'] = fake.PROJECT_ID
|
||||
vol['status'] = status
|
||||
vol['display_name'] = display_name
|
||||
vol['display_description'] = display_description
|
||||
|
@ -158,8 +158,8 @@ class BaseBackupTest(test.TestCase):
|
|||
"""
|
||||
kwargs = {}
|
||||
kwargs['size'] = size
|
||||
kwargs['user_id'] = str(uuid.uuid4())
|
||||
kwargs['project_id'] = str(uuid.uuid4())
|
||||
kwargs['user_id'] = fake.USER_ID
|
||||
kwargs['project_id'] = fake.PROJECT_ID
|
||||
kwargs['status'] = status
|
||||
kwargs['display_name'] = display_name
|
||||
kwargs['display_description'] = display_description
|
||||
|
@ -203,7 +203,7 @@ class BaseBackupTest(test.TestCase):
|
|||
"""
|
||||
kwargs = {}
|
||||
kwargs['volume_id'] = volume_id
|
||||
kwargs['user_id'] = str(uuid.uuid4())
|
||||
kwargs['user_id'] = fake.USER_ID
|
||||
kwargs['project_id'] = project_id
|
||||
kwargs['status'] = status
|
||||
if backup_id:
|
||||
|
@ -392,9 +392,9 @@ class BackupTestCase(BaseBackupTest):
|
|||
def test_cleanup_incomplete_backup_operations_with_exceptions(self):
|
||||
"""Test cleanup resilience in the face of exceptions."""
|
||||
|
||||
fake_backup_list = [{'id': str(uuid.uuid4())},
|
||||
{'id': str(uuid.uuid4())},
|
||||
{'id': str(uuid.uuid4())}]
|
||||
fake_backup_list = [{'id': fake.BACKUP_ID},
|
||||
{'id': fake.BACKUP2_ID},
|
||||
{'id': fake.BACKUP3_ID}]
|
||||
mock_backup_get_by_host = self.mock_object(
|
||||
objects.BackupList, 'get_all_by_host')
|
||||
mock_backup_get_by_host.return_value = fake_backup_list
|
||||
|
@ -522,18 +522,18 @@ class BackupTestCase(BaseBackupTest):
|
|||
|
||||
fake_attachments = [
|
||||
{
|
||||
'id': str(uuid.uuid4()),
|
||||
'id': fake.ATTACHMENT_ID,
|
||||
'attached_host': 'testhost',
|
||||
'instance_uuid': None,
|
||||
},
|
||||
{
|
||||
'id': str(uuid.uuid4()),
|
||||
'id': fake.ATTACHMENT2_ID,
|
||||
'attached_host': 'testhost',
|
||||
'instance_uuid': None,
|
||||
}
|
||||
]
|
||||
fake_volume = {
|
||||
'id': str(uuid.uuid4()),
|
||||
'id': fake.VOLUME3_ID,
|
||||
'volume_attachment': fake_attachments
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,7 @@ class BackupTestCase(BaseBackupTest):
|
|||
backup = self._create_backup_db_entry(
|
||||
status=fields.BackupStatus.ERROR,
|
||||
volume_id=vol1_id,
|
||||
temp_snapshot_id=str(uuid.uuid4()))
|
||||
temp_snapshot_id=fake.SNAPSHOT_ID)
|
||||
|
||||
self.assertIsNone(
|
||||
self.backup_mgr._cleanup_temp_volumes_snapshots_for_one_backup(
|
||||
|
@ -588,7 +588,7 @@ class BackupTestCase(BaseBackupTest):
|
|||
db.volume_update(self.ctxt, vol1_id, {'status': 'backing-up'})
|
||||
backup = self._create_backup_db_entry(status=fields.BackupStatus.ERROR,
|
||||
volume_id=vol1_id,
|
||||
temp_volume_id=str(uuid.uuid4()))
|
||||
temp_volume_id=fake.VOLUME4_ID)
|
||||
|
||||
self.assertIsNone(
|
||||
self.backup_mgr._cleanup_temp_volumes_snapshots_for_one_backup(
|
||||
|
@ -1610,7 +1610,7 @@ class BackupTestCase(BaseBackupTest):
|
|||
self.assertEqual(2, notify.call_count)
|
||||
|
||||
def test_list_backup(self):
|
||||
project_id = str(uuid.uuid4())
|
||||
project_id = fake.PROJECT_ID
|
||||
backups = db.backup_get_all_by_project(self.ctxt, project_id)
|
||||
self.assertEqual(0, len(backups))
|
||||
|
||||
|
@ -1626,7 +1626,7 @@ class BackupTestCase(BaseBackupTest):
|
|||
Test deleted backups don't show up in backup_get_all_by_project.
|
||||
Unless context.read_deleted is 'yes'.
|
||||
"""
|
||||
project_id = str(uuid.uuid4())
|
||||
project_id = fake.PROJECT2_ID
|
||||
backups = db.backup_get_all_by_project(self.ctxt, project_id)
|
||||
self.assertEqual(0, len(backups))
|
||||
|
||||
|
@ -1716,7 +1716,7 @@ class BackupTestCase(BaseBackupTest):
|
|||
driver does not support verify.
|
||||
"""
|
||||
vol_size = 1
|
||||
backup_id = uuid.uuid4()
|
||||
backup_id = fake.BACKUP4_ID
|
||||
export = self._create_exported_record_entry(vol_size=vol_size,
|
||||
exported_id=backup_id)
|
||||
imported_record = self._create_export_record_db_entry(
|
||||
|
@ -1940,8 +1940,8 @@ class BackupAPITestCase(BaseBackupTest):
|
|||
|
||||
# Will try to backup from a different context
|
||||
new_context = copy.copy(self.ctxt)
|
||||
new_context.user_id = uuid.uuid4()
|
||||
new_context.project_id = uuid.uuid4()
|
||||
new_context.user_id = fake.USER3_ID
|
||||
new_context.project_id = fake.USER3_ID
|
||||
|
||||
# The opposite side of this test case is a "NotImplementedError:
|
||||
# Cannot load 'id' in the base class" being raised.
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
import json
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import units
|
||||
|
@ -25,6 +24,7 @@ from cinder import context
|
|||
from cinder import exception
|
||||
from cinder import objects
|
||||
from cinder.objects import fields
|
||||
from cinder.tests.unit import fake_constants as fake
|
||||
from cinder.tests.unit import test
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TestObjectReader(object):
|
|||
|
||||
class ChunkedDriverTestCase(test.TestCase):
|
||||
|
||||
def _create_backup_db_entry(self, volume_id=str(uuid.uuid4()),
|
||||
def _create_backup_db_entry(self, volume_id=fake.VOLUME_ID,
|
||||
restore_volume_id=None,
|
||||
display_name='test_backup',
|
||||
display_description='this is a test backup',
|
||||
|
@ -123,7 +123,7 @@ class ChunkedDriverTestCase(test.TestCase):
|
|||
status=fields.BackupStatus.CREATING,
|
||||
size=1,
|
||||
object_count=0,
|
||||
project_id=str(uuid.uuid4()),
|
||||
project_id=fake.PROJECT_ID,
|
||||
service=None,
|
||||
temp_volume_id=None,
|
||||
temp_snapshot_id=None,
|
||||
|
@ -138,7 +138,7 @@ class ChunkedDriverTestCase(test.TestCase):
|
|||
kwargs = {}
|
||||
kwargs['volume_id'] = volume_id
|
||||
kwargs['restore_volume_id'] = restore_volume_id
|
||||
kwargs['user_id'] = str(uuid.uuid4())
|
||||
kwargs['user_id'] = fake.USER_ID
|
||||
kwargs['project_id'] = project_id
|
||||
kwargs['host'] = 'testhost'
|
||||
kwargs['availability_zone'] = '1'
|
||||
|
@ -175,8 +175,8 @@ class ChunkedDriverTestCase(test.TestCase):
|
|||
vol = {}
|
||||
vol['size'] = size
|
||||
vol['host'] = host
|
||||
vol['user_id'] = str(uuid.uuid4())
|
||||
vol['project_id'] = str(uuid.uuid4())
|
||||
vol['user_id'] = fake.USER_ID
|
||||
vol['project_id'] = fake.PROJECT_ID
|
||||
vol['status'] = status
|
||||
vol['display_name'] = display_name
|
||||
vol['display_description'] = display_description
|
||||
|
|
|
@ -50,6 +50,7 @@ QOS_SPEC_ID = 'fc0f7527-79d7-44be-a4f6-3b24db8e11ac'
|
|||
QOS_SPEC2_ID = 'c561b69d-98d9-478c-815b-6de11f5a09c9'
|
||||
QOS_SPEC3_ID = '6034720b-f586-4302-a1eb-fe30672069f6'
|
||||
RAISE_ID = 'a56762e1-4a30-4008-b997-5a438ec9c457'
|
||||
REQUEST_ID = '253c2a22-931e-4104-a9ab-1d70071e4bd4'
|
||||
SNAPSHOT_ID = '253b2878-ec60-4793-ad19-e65496ec7aab'
|
||||
SNAPSHOT_NAME = 'snapshot-253b2878-ec60-4793-ad19-e65496ec7aab'
|
||||
SNAPSHOT2_ID = 'c02c44fa-5665-4a26-9e66-2ebaf25e5d2d'
|
||||
|
@ -57,6 +58,7 @@ SNAPSHOT3_ID = '454f9970-1e05-4193-a3ed-5c390c3faa18'
|
|||
UPDATE_FAILED_ID = '110b29df-5e0f-4dbb-840c-ef5963d06933'
|
||||
USER_ID = 'c853ca26-e8ea-4797-8a52-ee124a013d0e'
|
||||
USER2_ID = '95f7b7ed-bd7f-426e-b05f-f1ffeb4f09df'
|
||||
USER3_ID = '5f590c70-7f2b-4240-a9b2-a37d343e2a63'
|
||||
VOLUME_ID = '1e5177e7-95e5-4a0f-b170-e45f4b469f6a'
|
||||
VOLUME_NAME = 'volume-1e5177e7-95e5-4a0f-b170-e45f4b469f6a'
|
||||
VOLUME2_ID = '43a09914-e495-475f-b862-0bda3c8918e4'
|
||||
|
@ -68,6 +70,9 @@ VOLUME4_NAME = 'volume-904d4602-4301-4e9b-8df1-8133b51904e6'
|
|||
VOLUME5_ID = '17b0e01d-3d2d-4c31-a1aa-c962420bc3dc'
|
||||
VOLUME5_NAME = 'volume-17b0e01d-3d2d-4c31-a1aa-c962420bc3dc'
|
||||
VOLUME6_ID = '84375761-46e0-4df2-a567-02f0113428d7'
|
||||
VOLUME7_ID = '4d6722d1-fafb-455c-9a1c-bc542841c408'
|
||||
VOLUME8_ID = '439965c7-2ce5-4dff-81fe-549007b2b9da'
|
||||
VOLUME9_ID = '9bcc62a8-d407-4711-8471-8b9010ae10a3'
|
||||
VOLUME_NAME_ID = 'ee73d33c-52ed-4cb7-a8a9-2687c1205c22'
|
||||
VOLUME2_NAME_ID = '63fbdd21-03bc-4309-b867-2893848f86af'
|
||||
VOLUME_TYPE_ID = '4e9e6d23-eed0-426d-b90a-28f87a94b6fe'
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
import webob
|
||||
|
@ -32,15 +31,15 @@ class CinderPolicyTests(test.TestCase):
|
|||
self.project_id = fake_constants.PROJECT_ID
|
||||
self.other_project_id = fake_constants.PROJECT2_ID
|
||||
self.admin_context = cinder_context.RequestContext(
|
||||
user_id=uuid.uuid4().hex, project_id=self.project_id,
|
||||
user_id=fake_constants.USER_ID, project_id=self.project_id,
|
||||
roles=['admin']
|
||||
)
|
||||
self.user_context = cinder_context.RequestContext(
|
||||
user_id=uuid.uuid4().hex, project_id=self.project_id,
|
||||
user_id=fake_constants.USER2_ID, project_id=self.project_id,
|
||||
roles=['non-admin']
|
||||
)
|
||||
self.other_user_context = cinder_context.RequestContext(
|
||||
user_id=uuid.uuid4().hex, project_id=self.other_project_id,
|
||||
user_id=fake_constants.USER3_ID, project_id=self.other_project_id,
|
||||
roles=['non-admin']
|
||||
)
|
||||
fake_image.mock_image_service(self)
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# under the License.
|
||||
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
import eventlet
|
||||
|
||||
|
@ -252,7 +251,7 @@ class DellSCSanISCSIDriverTestCase(test.TestCase):
|
|||
|
||||
self.mock_sleep = self.mock_object(eventlet, 'sleep')
|
||||
|
||||
self.volid = str(uuid.uuid4())
|
||||
self.volid = fake.VOLUME_ID
|
||||
self.volume_name = "volume" + self.volid
|
||||
self.connector = {
|
||||
'ip': '10.0.0.2',
|
||||
|
|
|
@ -17,12 +17,10 @@
|
|||
import errno
|
||||
import os
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
from oslo_utils import imageutils
|
||||
from oslo_utils import units
|
||||
import six
|
||||
|
||||
from cinder import context
|
||||
from cinder import exception
|
||||
|
@ -395,7 +393,6 @@ class NfsDriverTestCase(test.TestCase):
|
|||
TEST_SHARES_CONFIG_FILE = '/etc/cinder/test-shares.conf'
|
||||
TEST_NFS_EXPORT_SPACES = 'nfs-host3:/export this'
|
||||
TEST_MNT_POINT_SPACES = '/ 0 0 0 /foo'
|
||||
VOLUME_UUID = '69ad4ff6-b892-4215-aaaa-aaaaaaaaaaaa'
|
||||
|
||||
def setUp(self):
|
||||
super(NfsDriverTestCase, self).setUp()
|
||||
|
@ -1236,7 +1233,7 @@ class NfsDriverTestCase(test.TestCase):
|
|||
# Volume source of the snapshot we are trying to clone from. We need it
|
||||
# to have a different id than the default provided.
|
||||
src_volume = self._simple_volume(size=10)
|
||||
src_volume.id = six.text_type(uuid.uuid4())
|
||||
src_volume.id = fake.VOLUME_ID
|
||||
src_volume_dir = os.path.join(self.TEST_MNT_POINT_BASE,
|
||||
drv._get_hash_str(
|
||||
src_volume.provider_location))
|
||||
|
|
|
@ -19,7 +19,6 @@ import datetime
|
|||
import enum
|
||||
import time
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
from castellan.common import exception as castellan_exception
|
||||
from castellan import key_manager
|
||||
|
@ -2019,9 +2018,8 @@ class VolumeTestCase(base.BaseVolumeTestCase):
|
|||
six.text_type(ex))
|
||||
|
||||
def test_unreserve_volume_success_in_use(self):
|
||||
UUID = six.text_type(uuid.uuid4())
|
||||
volume = tests_utils.create_volume(self.context, status='attaching')
|
||||
tests_utils.attach_volume(self.context, volume.id, UUID,
|
||||
tests_utils.attach_volume(self.context, volume.id, fake.INSTANCE_ID,
|
||||
'attached_host', 'mountpoint', mode='rw')
|
||||
|
||||
cinder.volume.api.API().unreserve_volume(self.context, volume)
|
||||
|
|
Loading…
Reference in New Issue