Replace uuid4() with uuidsentinel
As of now, in most of the test cases, uuidsentinel is used for generating a UUID except at some places where uuid4() is used. In order to maintain consistency, we propose to use uuidsentinel module for generating UUIDs throughout the test cases. There are some cases where unique UUIDs are required. For such cases, generate_uuid() from oslo_utils.uuidutils is used. Change-Id: Ifaee2f79fc33d189751c4e3f405b579dd8d89784
This commit is contained in:
@@ -327,7 +327,7 @@ class UnsupportedDbRegexpTestCase(DbTestCase):
|
||||
self.assertRaises(exception.MarkerNotFound,
|
||||
db.instance_get_all_by_filters,
|
||||
self.context, {'display_name': '%test%'},
|
||||
marker=str(stdlib_uuid.uuid4()))
|
||||
marker=uuidsentinel.uuid1)
|
||||
|
||||
def _assert_equals_inst_order(self, correct_order, filters,
|
||||
sort_keys=None, sort_dirs=None,
|
||||
@@ -2833,7 +2833,7 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
ctxt = context.get_admin_context()
|
||||
instance = db.instance_create(ctxt, dict(display_name='bdm-test'))
|
||||
bdm = {
|
||||
'volume_id': uuidutils.generate_uuid(),
|
||||
'volume_id': uuidsentinel.uuid1,
|
||||
'device_name': '/dev/vdb',
|
||||
'instance_uuid': instance['uuid'],
|
||||
}
|
||||
@@ -2860,7 +2860,7 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_delete_instance_faults_on_instance_destroy(self):
|
||||
ctxt = context.get_admin_context()
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
# Create faults
|
||||
db.instance_create(ctxt, {'uuid': uuid})
|
||||
|
||||
@@ -2884,7 +2884,7 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_delete_instance_group_member_on_instance_destroy(self):
|
||||
ctxt = context.get_admin_context()
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
db.instance_create(ctxt, {'uuid': uuid})
|
||||
values = {'name': 'fake_name', 'user_id': 'fake',
|
||||
'project_id': 'fake'}
|
||||
@@ -3768,7 +3768,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_start(self):
|
||||
"""Create an instance action."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action_values = self._create_action_values(uuid)
|
||||
action = db.action_start(self.ctxt, action_values)
|
||||
@@ -3780,7 +3780,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_finish(self):
|
||||
"""Create an instance action."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action_values = self._create_action_values(uuid)
|
||||
db.action_start(self.ctxt, action_values)
|
||||
@@ -3793,7 +3793,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_finish_without_started_event(self):
|
||||
"""Create an instance finish action."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action_values = self._create_action_values(uuid)
|
||||
action_values['finish_time'] = timeutils.utcnow()
|
||||
@@ -3802,7 +3802,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_actions_get_by_instance(self):
|
||||
"""Ensure we can get actions by UUID."""
|
||||
uuid1 = str(stdlib_uuid.uuid4())
|
||||
uuid1 = uuidsentinel.uuid1
|
||||
|
||||
expected = []
|
||||
|
||||
@@ -3815,7 +3815,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
expected.append(action)
|
||||
|
||||
# Create some extra actions
|
||||
uuid2 = str(stdlib_uuid.uuid4())
|
||||
uuid2 = uuidsentinel.uuid2
|
||||
ctxt2 = context.get_admin_context()
|
||||
action_values = self._create_action_values(uuid2, 'reboot', ctxt2)
|
||||
db.action_start(ctxt2, action_values)
|
||||
@@ -3827,7 +3827,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_actions_get_are_in_order(self):
|
||||
"""Ensure retrived actions are in order."""
|
||||
uuid1 = str(stdlib_uuid.uuid4())
|
||||
uuid1 = uuidsentinel.uuid1
|
||||
|
||||
extra = {
|
||||
'created_at': timeutils.utcnow()
|
||||
@@ -3847,8 +3847,8 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
def test_instance_action_get_by_instance_and_action(self):
|
||||
"""Ensure we can get an action by instance UUID and action id."""
|
||||
ctxt2 = context.get_admin_context()
|
||||
uuid1 = str(stdlib_uuid.uuid4())
|
||||
uuid2 = str(stdlib_uuid.uuid4())
|
||||
uuid1 = uuidsentinel.uuid1
|
||||
uuid2 = uuidsentinel.uuid2
|
||||
|
||||
action_values = self._create_action_values(uuid1)
|
||||
db.action_start(self.ctxt, action_values)
|
||||
@@ -3869,7 +3869,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_event_start(self):
|
||||
"""Create an instance action event."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action_values = self._create_action_values(uuid)
|
||||
action = db.action_start(self.ctxt, action_values)
|
||||
@@ -3885,7 +3885,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_event_start_without_action(self):
|
||||
"""Create an instance action event."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
event_values = self._create_event_values(uuid)
|
||||
self.assertRaises(exception.InstanceActionNotFound,
|
||||
@@ -3893,7 +3893,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_event_finish_without_started_event(self):
|
||||
"""Finish an instance action event."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
db.action_start(self.ctxt, self._create_action_values(uuid))
|
||||
|
||||
@@ -3907,7 +3907,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_event_finish_without_action(self):
|
||||
"""Finish an instance action event."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
event_values = {
|
||||
'finish_time': timeutils.utcnow() + datetime.timedelta(seconds=5),
|
||||
@@ -3919,7 +3919,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_event_finish_success(self):
|
||||
"""Finish an instance action event."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action = db.action_start(self.ctxt, self._create_action_values(uuid))
|
||||
|
||||
@@ -3939,7 +3939,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_event_finish_error(self):
|
||||
"""Finish an instance action event with an error."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action = db.action_start(self.ctxt, self._create_action_values(uuid))
|
||||
|
||||
@@ -3959,7 +3959,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_and_event_start_string_time(self):
|
||||
"""Create an instance action and event with a string start_time."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action = db.action_start(self.ctxt, self._create_action_values(uuid))
|
||||
|
||||
@@ -3971,7 +3971,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_action_events_get_are_in_order(self):
|
||||
"""Ensure retrived action events are in order."""
|
||||
uuid1 = str(stdlib_uuid.uuid4())
|
||||
uuid1 = uuidsentinel.uuid1
|
||||
|
||||
action = db.action_start(self.ctxt,
|
||||
self._create_action_values(uuid1))
|
||||
@@ -4000,8 +4000,8 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
def test_instance_action_event_get_by_id(self):
|
||||
"""Get a specific instance action event."""
|
||||
ctxt2 = context.get_admin_context()
|
||||
uuid1 = str(stdlib_uuid.uuid4())
|
||||
uuid2 = str(stdlib_uuid.uuid4())
|
||||
uuid1 = uuidsentinel.uuid1
|
||||
uuid2 = uuidsentinel.uuid2
|
||||
|
||||
action = db.action_start(self.ctxt,
|
||||
self._create_action_values(uuid1))
|
||||
@@ -4023,7 +4023,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
['instance_uuid', 'request_id'])
|
||||
|
||||
def test_instance_action_event_start_with_different_request_id(self):
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action_values = self._create_action_values(uuid)
|
||||
action = db.action_start(self.ctxt, action_values)
|
||||
@@ -4039,7 +4039,7 @@ class InstanceActionTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
self._assertActionEventSaved(event, action['id'])
|
||||
|
||||
def test_instance_action_event_finish_with_different_request_id(self):
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
action = db.action_start(self.ctxt, self._create_action_values(uuid))
|
||||
|
||||
@@ -4078,7 +4078,7 @@ class InstanceFaultTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_fault_create(self):
|
||||
"""Ensure we can create an instance fault."""
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
|
||||
# Ensure no faults registered for this instance
|
||||
faults = db.instance_fault_get_by_instance_uuids(self.ctxt, [uuid])
|
||||
@@ -4100,7 +4100,7 @@ class InstanceFaultTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_instance_fault_get_by_instance(self):
|
||||
"""Ensure we can retrieve faults for instance."""
|
||||
uuids = [str(stdlib_uuid.uuid4()), str(stdlib_uuid.uuid4())]
|
||||
uuids = [uuidsentinel.uuid1, uuidsentinel.uuid2]
|
||||
fault_codes = [404, 500]
|
||||
expected = {}
|
||||
|
||||
@@ -4121,7 +4121,7 @@ class InstanceFaultTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
self._assertEqualListsOfObjects(expected[uuid], faults[uuid])
|
||||
|
||||
def test_instance_faults_get_by_instance_uuids_no_faults(self):
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuidsentinel.uuid1
|
||||
# None should be returned when no faults exist.
|
||||
faults = db.instance_fault_get_by_instance_uuids(self.ctxt, [uuid])
|
||||
expected = {uuid: []}
|
||||
@@ -6553,7 +6553,7 @@ class VirtualInterfaceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
'instance_uuid': self.instance_uuid,
|
||||
'address': 'fake_address',
|
||||
'network_id': self.network['id'],
|
||||
'uuid': str(stdlib_uuid.uuid4()),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'tag': 'fake-tag',
|
||||
}
|
||||
|
||||
@@ -7652,7 +7652,7 @@ class S3ImageTestCase(test.TestCase):
|
||||
|
||||
def test_s3_image_get_by_uuid_not_found(self):
|
||||
self.assertRaises(exception.ImageNotFound, db.s3_image_get_by_uuid,
|
||||
self.ctxt, uuidutils.generate_uuid())
|
||||
self.ctxt, uuidsentinel.uuid1)
|
||||
|
||||
|
||||
class ComputeNodeTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
@@ -8264,7 +8264,7 @@ class ConsoleTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
]
|
||||
self.console_pools = [db.console_pool_create(self.ctxt, val)
|
||||
for val in pools_data]
|
||||
instance_uuid = uuidutils.generate_uuid()
|
||||
instance_uuid = uuidsentinel.uuid1
|
||||
db.instance_create(self.ctxt, {'uuid': instance_uuid})
|
||||
self.console_data = [{'instance_name': 'name' + str(x),
|
||||
'instance_uuid': instance_uuid,
|
||||
@@ -8319,7 +8319,7 @@ class ConsoleTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
def test_console_get_all_by_instance_empty(self):
|
||||
consoles_get = db.console_get_all_by_instance(self.ctxt,
|
||||
uuidutils.generate_uuid())
|
||||
uuidsentinel.uuid2)
|
||||
self.assertEqual(consoles_get, [])
|
||||
|
||||
def test_console_delete(self):
|
||||
@@ -8332,7 +8332,7 @@ class ConsoleTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
self.assertRaises(exception.ConsoleNotFoundInPoolForInstance,
|
||||
db.console_get_by_pool_instance, self.ctxt,
|
||||
self.consoles[0]['pool_id'],
|
||||
uuidutils.generate_uuid())
|
||||
uuidsentinel.uuid2)
|
||||
|
||||
def test_console_get_not_found(self):
|
||||
self.assertRaises(exception.ConsoleNotFound, db.console_get,
|
||||
@@ -8341,7 +8341,7 @@ class ConsoleTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
def test_console_get_not_found_instance(self):
|
||||
self.assertRaises(exception.ConsoleNotFoundForInstance, db.console_get,
|
||||
self.ctxt, self.consoles[0]['id'],
|
||||
uuidutils.generate_uuid())
|
||||
uuidsentinel.uuid2)
|
||||
|
||||
|
||||
class CellTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
@@ -10082,7 +10082,7 @@ class TestInstanceInfoCache(test.TestCase):
|
||||
|
||||
def test_instance_info_cache_create_using_update(self):
|
||||
network_info = 'net'
|
||||
instance_uuid = uuidutils.generate_uuid()
|
||||
instance_uuid = uuidsentinel.uuid1
|
||||
db.instance_info_cache_update(self.context, instance_uuid,
|
||||
{'network_info': network_info})
|
||||
info_cache = db.instance_info_cache_get(self.context, instance_uuid)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
# under the License.
|
||||
|
||||
import importlib
|
||||
import uuid
|
||||
|
||||
from migrate import exceptions as versioning_exceptions
|
||||
from migrate import UniqueConstraint
|
||||
@@ -200,7 +199,7 @@ class TestFlavorCheck(test.TestCase):
|
||||
|
||||
def test_upgrade_clean(self):
|
||||
inst = objects.Instance(context=self.context,
|
||||
uuid=uuid.uuid4(),
|
||||
uuid=uuidsentinel.fake,
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
system_metadata={'foo': 'bar'})
|
||||
@@ -209,7 +208,7 @@ class TestFlavorCheck(test.TestCase):
|
||||
|
||||
def test_upgrade_dirty(self):
|
||||
inst = objects.Instance(context=self.context,
|
||||
uuid=uuid.uuid4(),
|
||||
uuid=uuidsentinel.fake,
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
system_metadata={'foo': 'bar',
|
||||
@@ -220,7 +219,7 @@ class TestFlavorCheck(test.TestCase):
|
||||
|
||||
def test_upgrade_flavor_deleted_instances(self):
|
||||
inst = objects.Instance(context=self.context,
|
||||
uuid=uuid.uuid4(),
|
||||
uuid=uuidsentinel.fake,
|
||||
user_id=self.context.user_id,
|
||||
project_id=self.context.project_id,
|
||||
system_metadata={'foo': 'bar',
|
||||
|
||||
@@ -12,13 +12,12 @@
|
||||
|
||||
"""Implementation of a fake volume API."""
|
||||
|
||||
import uuid
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -38,7 +37,7 @@ class fake_volume(object):
|
||||
if snapshot is not None:
|
||||
snapshot_id = snapshot['id']
|
||||
if volume_id is None:
|
||||
volume_id = str(uuid.uuid4())
|
||||
volume_id = uuids.fake1
|
||||
self.vol = {
|
||||
'created_at': timeutils.utcnow(),
|
||||
'deleted_at': None,
|
||||
@@ -84,7 +83,7 @@ class fake_snapshot(object):
|
||||
|
||||
def __init__(self, volume_id, size, name, desc, id=None):
|
||||
if id is None:
|
||||
id = str(uuid.uuid4())
|
||||
id = uuids.fake2
|
||||
self.snap = {
|
||||
'created_at': timeutils.utcnow(),
|
||||
'deleted_at': None,
|
||||
@@ -212,7 +211,7 @@ class API(object):
|
||||
volume['attach_time'] = timeutils.utcnow()
|
||||
volume['multiattach'] = True
|
||||
volume['attachments'] = {instance_uuid:
|
||||
{'attachment_id': str(uuid.uuid4()),
|
||||
{'attachment_id': uuids.fake3,
|
||||
'mountpoint': mountpoint}}
|
||||
|
||||
def reset_fake_api(self, context):
|
||||
|
||||
@@ -244,7 +244,7 @@ class TestNeutronv2Base(test.TestCase):
|
||||
'bff4a5a6b9eb4ea2a6efec6eefb77936')
|
||||
self.tenant_id = '9d049e4b60b64716978ab415e6fbd5c0'
|
||||
self.instance = {'project_id': self.tenant_id,
|
||||
'uuid': str(uuid.uuid4()),
|
||||
'uuid': uuids.fake,
|
||||
'display_name': 'test_instance',
|
||||
'hostname': 'test-instance',
|
||||
'availability_zone': 'nova',
|
||||
@@ -252,7 +252,7 @@ class TestNeutronv2Base(test.TestCase):
|
||||
'info_cache': {'network_info': []},
|
||||
'security_groups': []}
|
||||
self.instance2 = {'project_id': self.tenant_id,
|
||||
'uuid': str(uuid.uuid4()),
|
||||
'uuid': uuids.fake,
|
||||
'display_name': 'test_instance2',
|
||||
'availability_zone': 'nova',
|
||||
'info_cache': {'network_info': []},
|
||||
@@ -417,7 +417,7 @@ class TestNeutronv2Base(test.TestCase):
|
||||
def _fake_instance_info_cache(self, nw_info, instance_uuid=None):
|
||||
info_cache = {}
|
||||
if instance_uuid is None:
|
||||
info_cache['instance_uuid'] = str(uuid.uuid4())
|
||||
info_cache['instance_uuid'] = uuids.fake
|
||||
else:
|
||||
info_cache['instance_uuid'] = instance_uuid
|
||||
info_cache['deleted'] = False
|
||||
@@ -3152,7 +3152,7 @@ class TestNeutronv2WithMock(test.TestCase):
|
||||
|
||||
@mock.patch('oslo_concurrency.lockutils.lock')
|
||||
def test_get_instance_nw_info_locks_per_instance(self, mock_lock):
|
||||
instance = objects.Instance(uuid=uuid.uuid4())
|
||||
instance = objects.Instance(uuid=uuids.fake)
|
||||
api = neutronapi.API()
|
||||
mock_lock.side_effect = test.TestingException
|
||||
self.assertRaises(test.TestingException,
|
||||
@@ -3197,7 +3197,7 @@ class TestNeutronv2WithMock(test.TestCase):
|
||||
meta={"tenant_id": instance_networks[0]["tenant_id"]})}]
|
||||
)
|
||||
|
||||
instance_uuid = uuid.uuid4()
|
||||
instance_uuid = uuids.fake
|
||||
instance = objects.Instance(uuid=instance_uuid,
|
||||
info_cache=objects.InstanceInfoCache(
|
||||
context=self.context,
|
||||
@@ -3382,7 +3382,7 @@ class TestNeutronv2WithMock(test.TestCase):
|
||||
|
||||
def test_allocate_floating_ip_no_ipv4_subnet(self):
|
||||
api = neutronapi.API()
|
||||
net_id = uuid.uuid4()
|
||||
net_id = uuids.fake
|
||||
error_msg = ('Bad floatingip request: Network %s does not contain '
|
||||
'any IPv4 subnet' % net_id)
|
||||
with test.nested(
|
||||
@@ -3512,7 +3512,7 @@ class TestNeutronv2WithMock(test.TestCase):
|
||||
# setup fake data
|
||||
instance = fake_instance.fake_instance_obj(self.context)
|
||||
mock_preexisting.return_value = []
|
||||
port_data = {'ports': [{'id': str(uuid.uuid4())}]}
|
||||
port_data = {'ports': [{'id': uuids.fake}]}
|
||||
ports = set([port['id'] for port in port_data.get('ports')])
|
||||
api = neutronapi.API()
|
||||
# setup mocks
|
||||
@@ -3635,7 +3635,7 @@ class TestNeutronv2WithMock(test.TestCase):
|
||||
mock_client.update_port.return_value = 'port'
|
||||
|
||||
instance = {'project_id': '9d049e4b60b64716978ab415e6fbd5c0',
|
||||
'uuid': str(uuid.uuid4()),
|
||||
'uuid': uuids.fake,
|
||||
'display_name': 'test_instance',
|
||||
'availability_zone': 'nova',
|
||||
'host': 'some_host'}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
@@ -21,12 +20,13 @@ from oslo_utils import timeutils
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.tests.unit.objects import test_objects
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
_TS_NOW = timeutils.utcnow(with_timezone=True)
|
||||
# o.vo.fields.DateTimeField converts to tz-aware and
|
||||
# in process we lose microsecond resolution.
|
||||
_TS_NOW = _TS_NOW.replace(microsecond=0)
|
||||
_DB_UUID = str(uuid.uuid4())
|
||||
_DB_UUID = uuids.fake
|
||||
_INST_GROUP_DB = {
|
||||
'id': 1,
|
||||
'uuid': _DB_UUID,
|
||||
@@ -275,10 +275,10 @@ class TestRemoteInstanceGroupObject(test_objects._RemoteTest,
|
||||
|
||||
|
||||
def _mock_db_list_get(*args):
|
||||
instances = [(str(uuid.uuid4()), 'f1', 'p1'),
|
||||
(str(uuid.uuid4()), 'f2', 'p1'),
|
||||
(str(uuid.uuid4()), 'f3', 'p2'),
|
||||
(str(uuid.uuid4()), 'f4', 'p2')]
|
||||
instances = [(uuids.f1, 'f1', 'p1'),
|
||||
(uuids.f2, 'f2', 'p1'),
|
||||
(uuids.f3, 'f3', 'p2'),
|
||||
(uuids.f4, 'f4', 'p2')]
|
||||
result = []
|
||||
for instance in instances:
|
||||
values = copy.deepcopy(_INST_GROUP_DB)
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
@@ -20,8 +19,9 @@ from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import fields
|
||||
from nova.tests.unit.objects import test_objects
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
fake_instance_uuid = str(uuid.uuid4())
|
||||
fake_instance_uuid = uuids.fake
|
||||
|
||||
fake_obj_numa_topology = objects.InstanceNUMATopology(
|
||||
instance_uuid = fake_instance_uuid,
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
@@ -19,9 +17,10 @@ from nova import exception
|
||||
from nova import objects
|
||||
from nova.tests.unit.objects import test_instance_numa_topology
|
||||
from nova.tests.unit.objects import test_objects
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
|
||||
fake_instance_uuid = str(uuid.uuid4())
|
||||
fake_instance_uuid = uuids.fake
|
||||
|
||||
fake_migration_context_obj = objects.MigrationContext()
|
||||
fake_migration_context_obj.instance_uuid = fake_instance_uuid
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
|
||||
from nova import context
|
||||
@@ -324,8 +322,8 @@ class TestInventory(test_objects._LocalTest):
|
||||
# and should be moved.
|
||||
# Create 2 resource providers with DISK_GB resources. And
|
||||
# update total value for second one.
|
||||
db_rp1, db_inv1 = self._make_inventory(str(uuid.uuid4()))
|
||||
db_rp2, db_inv2 = self._make_inventory(str(uuid.uuid4()))
|
||||
db_rp1, db_inv1 = self._make_inventory(uuids.fake_1)
|
||||
db_rp2, db_inv2 = self._make_inventory(uuids.fake_2)
|
||||
|
||||
objects.Inventory._update_in_db(self.context,
|
||||
db_inv2.id,
|
||||
|
||||
Reference in New Issue
Block a user