Merge "Remove unnecessary cleanup from ComputeAPITestCase"
This commit is contained in:
commit
1e41005f5a
@ -7207,7 +7207,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
inst_type['memory_mb'] = 2
|
inst_type['memory_mb'] = 2
|
||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
inst_type, self.fake_image['id'])
|
inst_type, self.fake_image['id'])
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_with_too_little_disk(self):
|
def test_create_with_too_little_disk(self):
|
||||||
# Test an instance type with too little disk space.
|
# Test an instance type with too little disk space.
|
||||||
@ -7226,7 +7225,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
inst_type['root_gb'] = 2
|
inst_type['root_gb'] = 2
|
||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
inst_type, self.fake_image['id'])
|
inst_type, self.fake_image['id'])
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_with_too_large_image(self):
|
def test_create_with_too_large_image(self):
|
||||||
# Test an instance type with too little disk space.
|
# Test an instance type with too little disk space.
|
||||||
@ -7246,7 +7244,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.fake_image['size'] = '1073741824'
|
self.fake_image['size'] = '1073741824'
|
||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
inst_type, self.fake_image['id'])
|
inst_type, self.fake_image['id'])
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_just_enough_ram_and_disk(self):
|
def test_create_just_enough_ram_and_disk(self):
|
||||||
# Test an instance type with just enough ram and disk space.
|
# Test an instance type with just enough ram and disk space.
|
||||||
@ -7262,7 +7259,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
inst_type, self.fake_image['id'])
|
inst_type, self.fake_image['id'])
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_with_no_ram_and_disk_reqs(self):
|
def test_create_with_no_ram_and_disk_reqs(self):
|
||||||
# Test an instance type with no min_ram or min_disk.
|
# Test an instance type with no min_ram or min_disk.
|
||||||
@ -7275,7 +7271,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
inst_type, self.fake_image['id'])
|
inst_type, self.fake_image['id'])
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_with_deleted_image(self):
|
def test_create_with_deleted_image(self):
|
||||||
# If we're given a deleted image by glance, we should not be able to
|
# If we're given a deleted image by glance, we should not be able to
|
||||||
@ -7333,10 +7328,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
(ref, resv_id) = self.compute_api.create(self.context,
|
(ref, resv_id) = self.compute_api.create(self.context,
|
||||||
flavors.get_default_flavor(),
|
flavors.get_default_flavor(),
|
||||||
'fake-image-uuid', **instance)
|
'fake-image-uuid', **instance)
|
||||||
try:
|
|
||||||
self.assertIsNotNone(ref[0]['display_name'])
|
self.assertIsNotNone(ref[0]['display_name'])
|
||||||
finally:
|
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_instance_sets_system_metadata(self):
|
def test_create_instance_sets_system_metadata(self):
|
||||||
# Make sure image properties are copied into system metadata.
|
# Make sure image properties are copied into system metadata.
|
||||||
@ -7344,7 +7336,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.context,
|
self.context,
|
||||||
instance_type=flavors.get_default_flavor(),
|
instance_type=flavors.get_default_flavor(),
|
||||||
image_href='fake-image-uuid')
|
image_href='fake-image-uuid')
|
||||||
try:
|
|
||||||
sys_metadata = db.instance_system_metadata_get(self.context,
|
sys_metadata = db.instance_system_metadata_get(self.context,
|
||||||
ref[0]['uuid'])
|
ref[0]['uuid'])
|
||||||
|
|
||||||
@ -7355,16 +7347,13 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.assertIn(key, sys_metadata)
|
self.assertIn(key, sys_metadata)
|
||||||
self.assertEqual(value, sys_metadata[key])
|
self.assertEqual(value, sys_metadata[key])
|
||||||
|
|
||||||
finally:
|
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_saves_type_in_system_metadata(self):
|
def test_create_saves_type_in_system_metadata(self):
|
||||||
instance_type = flavors.get_default_flavor()
|
instance_type = flavors.get_default_flavor()
|
||||||
(ref, resv_id) = self.compute_api.create(
|
(ref, resv_id) = self.compute_api.create(
|
||||||
self.context,
|
self.context,
|
||||||
instance_type=instance_type,
|
instance_type=instance_type,
|
||||||
image_href='some-fake-image')
|
image_href='some-fake-image')
|
||||||
try:
|
|
||||||
sys_metadata = db.instance_system_metadata_get(self.context,
|
sys_metadata = db.instance_system_metadata_get(self.context,
|
||||||
ref[0]['uuid'])
|
ref[0]['uuid'])
|
||||||
|
|
||||||
@ -7377,9 +7366,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.assertEqual(str(instance_type[key]),
|
self.assertEqual(str(instance_type[key]),
|
||||||
str(sys_metadata[sys_meta_key]))
|
str(sys_metadata[sys_meta_key]))
|
||||||
|
|
||||||
finally:
|
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_instance_associates_security_groups(self):
|
def test_create_instance_associates_security_groups(self):
|
||||||
# Make sure create associates security groups.
|
# Make sure create associates security groups.
|
||||||
group = self._create_group()
|
group = self._create_group()
|
||||||
@ -7388,7 +7374,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
instance_type=flavors.get_default_flavor(),
|
instance_type=flavors.get_default_flavor(),
|
||||||
image_href='some-fake-image',
|
image_href='some-fake-image',
|
||||||
security_group=['testgroup'])
|
security_group=['testgroup'])
|
||||||
try:
|
|
||||||
groups_for_instance = db.security_group_get_by_instance(
|
groups_for_instance = db.security_group_get_by_instance(
|
||||||
self.context, ref[0]['uuid'])
|
self.context, ref[0]['uuid'])
|
||||||
self.assertEqual(1, len(groups_for_instance))
|
self.assertEqual(1, len(groups_for_instance))
|
||||||
@ -7397,9 +7383,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
group.id,
|
group.id,
|
||||||
columns_to_join=['instances'])
|
columns_to_join=['instances'])
|
||||||
self.assertEqual(1, len(group_with_instances.instances))
|
self.assertEqual(1, len(group_with_instances.instances))
|
||||||
finally:
|
|
||||||
db.security_group_destroy(self.context, group['id'])
|
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
|
||||||
|
|
||||||
def test_create_instance_with_invalid_security_group_raises(self):
|
def test_create_instance_with_invalid_security_group_raises(self):
|
||||||
instance_type = flavors.get_default_flavor()
|
instance_type = flavors.get_default_flavor()
|
||||||
@ -7451,7 +7434,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
(refs, resv_id) = self.compute_api.create(
|
(refs, resv_id) = self.compute_api.create(
|
||||||
self.context, inst_type, self.fake_image['id'],
|
self.context, inst_type, self.fake_image['id'],
|
||||||
user_data=base64.encodestring('1' * 48510))
|
user_data=base64.encodestring('1' * 48510))
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_populate_instance_for_create(self):
|
def test_populate_instance_for_create(self):
|
||||||
base_options = {'image_ref': self.fake_image['id'],
|
base_options = {'image_ref': self.fake_image['id'],
|
||||||
@ -7495,10 +7477,8 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
(ref, resv_id) = self.compute_api.create(self.context,
|
(ref, resv_id) = self.compute_api.create(self.context,
|
||||||
flavors.get_default_flavor(), image_href='some-fake-image',
|
flavors.get_default_flavor(), image_href='some-fake-image',
|
||||||
display_name=display_name)
|
display_name=display_name)
|
||||||
try:
|
|
||||||
self.assertEqual(ref[0]['hostname'], hostname)
|
self.assertEqual(ref[0]['hostname'], hostname)
|
||||||
finally:
|
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
|
||||||
|
|
||||||
def test_instance_create_adds_to_instance_group(self):
|
def test_instance_create_adds_to_instance_group(self):
|
||||||
self.stubs.Set(fake_image._FakeImageService, 'show', self.fake_show)
|
self.stubs.Set(fake_image._FakeImageService, 'show', self.fake_show)
|
||||||
@ -7515,8 +7495,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
group = objects.InstanceGroup.get_by_uuid(self.context, group.uuid)
|
group = objects.InstanceGroup.get_by_uuid(self.context, group.uuid)
|
||||||
self.assertIn(refs[0]['uuid'], group.members)
|
self.assertIn(refs[0]['uuid'], group.members)
|
||||||
|
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_instance_create_with_group_name_fails(self):
|
def test_instance_create_with_group_name_fails(self):
|
||||||
self.stubs.Set(fake_image._FakeImageService, 'show', self.fake_show)
|
self.stubs.Set(fake_image._FakeImageService, 'show', self.fake_show)
|
||||||
|
|
||||||
@ -7534,12 +7512,10 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
instance_type=flavors.get_default_flavor(),
|
instance_type=flavors.get_default_flavor(),
|
||||||
image_href='some-fake-image',
|
image_href='some-fake-image',
|
||||||
security_group=['testgroup'])
|
security_group=['testgroup'])
|
||||||
try:
|
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
db.instance_destroy(self.context, ref[0]['uuid'])
|
||||||
group = db.security_group_get(self.context, group['id'])
|
group = db.security_group_get(self.context, group['id'])
|
||||||
self.assertEqual(0, len(group['instances']))
|
self.assertEqual(0, len(group['instances']))
|
||||||
finally:
|
|
||||||
db.security_group_destroy(self.context, group['id'])
|
|
||||||
|
|
||||||
def test_destroy_security_group_disassociates_instances(self):
|
def test_destroy_security_group_disassociates_instances(self):
|
||||||
# Make sure destroying security groups disassociates instances.
|
# Make sure destroying security groups disassociates instances.
|
||||||
@ -7551,14 +7527,11 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
image_href='some-fake-image',
|
image_href='some-fake-image',
|
||||||
security_group=['testgroup'])
|
security_group=['testgroup'])
|
||||||
|
|
||||||
try:
|
|
||||||
db.security_group_destroy(self.context, group['id'])
|
db.security_group_destroy(self.context, group['id'])
|
||||||
admin_deleted_context = context.get_admin_context(
|
admin_deleted_context = context.get_admin_context(
|
||||||
read_deleted="only")
|
read_deleted="only")
|
||||||
group = db.security_group_get(admin_deleted_context, group['id'])
|
group = db.security_group_get(admin_deleted_context, group['id'])
|
||||||
self.assertEqual(0, len(group['instances']))
|
self.assertEqual(0, len(group['instances']))
|
||||||
finally:
|
|
||||||
db.instance_destroy(self.context, ref[0]['uuid'])
|
|
||||||
|
|
||||||
def _test_rebuild(self, vm_state):
|
def _test_rebuild(self, vm_state):
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
@ -7611,7 +7584,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
'image_ramdisk_id': 'fake_ramdisk_id',
|
'image_ramdisk_id': 'fake_ramdisk_id',
|
||||||
'image_something_else': 'meow',
|
'image_something_else': 'meow',
|
||||||
'preserved': 'preserve this!'})
|
'preserved': 'preserve this!'})
|
||||||
instance.destroy()
|
|
||||||
|
|
||||||
def test_rebuild(self):
|
def test_rebuild(self):
|
||||||
self._test_rebuild(vm_state=vm_states.ACTIVE)
|
self._test_rebuild(vm_state=vm_states.ACTIVE)
|
||||||
@ -7687,7 +7659,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.compute_api.rebuild(self.context,
|
self.compute_api.rebuild(self.context,
|
||||||
instance, self.fake_image['id'], 'new_password')
|
instance, self.fake_image['id'], 'new_password')
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_rebuild_with_too_little_disk(self):
|
def test_rebuild_with_too_little_disk(self):
|
||||||
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
||||||
@ -7711,7 +7682,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.compute_api.rebuild(self.context,
|
self.compute_api.rebuild(self.context,
|
||||||
instance, self.fake_image['id'], 'new_password')
|
instance, self.fake_image['id'], 'new_password')
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_rebuild_with_just_enough_ram_and_disk(self):
|
def test_rebuild_with_just_enough_ram_and_disk(self):
|
||||||
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
||||||
@ -7729,7 +7699,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.compute_api.rebuild(self.context,
|
self.compute_api.rebuild(self.context,
|
||||||
instance, self.fake_image['id'], 'new_password')
|
instance, self.fake_image['id'], 'new_password')
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_rebuild_with_no_ram_and_disk_reqs(self):
|
def test_rebuild_with_no_ram_and_disk_reqs(self):
|
||||||
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
||||||
@ -7744,7 +7713,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.compute_api.rebuild(self.context,
|
self.compute_api.rebuild(self.context,
|
||||||
instance, self.fake_image['id'], 'new_password')
|
instance, self.fake_image['id'], 'new_password')
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_rebuild_with_too_large_image(self):
|
def test_rebuild_with_too_large_image(self):
|
||||||
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
instance = self._create_fake_instance_obj(params={'image_ref': '1'})
|
||||||
@ -7767,7 +7735,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.fake_image['size'] = '1073741824'
|
self.fake_image['size'] = '1073741824'
|
||||||
self.compute_api.rebuild(self.context,
|
self.compute_api.rebuild(self.context,
|
||||||
instance, self.fake_image['id'], 'new_password')
|
instance, self.fake_image['id'], 'new_password')
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_hostname_create(self):
|
def test_hostname_create(self):
|
||||||
# Ensure instance hostname is set during creation.
|
# Ensure instance hostname is set during creation.
|
||||||
@ -7793,8 +7760,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
return fake_bdms, volume
|
return fake_bdms, volume
|
||||||
|
|
||||||
@mock.patch.object(objects.BlockDeviceMappingList,
|
@mock.patch.object(objects.BlockDeviceMappingList, 'get_by_instance_uuid')
|
||||||
'get_by_instance_uuid')
|
|
||||||
@mock.patch.object(cinder.API, 'get')
|
@mock.patch.object(cinder.API, 'get')
|
||||||
def test_rescue_volume_backed_no_image(self, mock_get_vol, mock_get_bdms):
|
def test_rescue_volume_backed_no_image(self, mock_get_vol, mock_get_bdms):
|
||||||
# Instance started without an image
|
# Instance started without an image
|
||||||
@ -7814,11 +7780,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.rescue, self.context,
|
self.compute_api.rescue, self.context,
|
||||||
volume_backed_inst_1)
|
volume_backed_inst_1)
|
||||||
|
|
||||||
self.compute.terminate_instance(self.context, volume_backed_inst_1,
|
@mock.patch.object(objects.BlockDeviceMappingList, 'get_by_instance_uuid')
|
||||||
[], [])
|
|
||||||
|
|
||||||
@mock.patch.object(objects.BlockDeviceMappingList,
|
|
||||||
'get_by_instance_uuid')
|
|
||||||
@mock.patch.object(cinder.API, 'get')
|
@mock.patch.object(cinder.API, 'get')
|
||||||
def test_rescue_volume_backed_placeholder_image(self,
|
def test_rescue_volume_backed_placeholder_image(self,
|
||||||
mock_get_vol,
|
mock_get_vol,
|
||||||
@ -7841,9 +7803,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.rescue, self.context,
|
self.compute_api.rescue, self.context,
|
||||||
volume_backed_inst_2)
|
volume_backed_inst_2)
|
||||||
|
|
||||||
self.compute.terminate_instance(self.context, volume_backed_inst_2,
|
|
||||||
[], [])
|
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
# Test get instance.
|
# Test get instance.
|
||||||
exp_instance = self._create_fake_instance_obj()
|
exp_instance = self._create_fake_instance_obj()
|
||||||
@ -7905,10 +7864,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
search_opts={'name': 'noth.*'})
|
search_opts={'name': 'noth.*'})
|
||||||
self.assertEqual(len(instances), 0)
|
self.assertEqual(len(instances), 0)
|
||||||
|
|
||||||
db.instance_destroy(c, instance1['uuid'])
|
|
||||||
db.instance_destroy(c, instance2['uuid'])
|
|
||||||
db.instance_destroy(c, instance3['uuid'])
|
|
||||||
|
|
||||||
def test_get_all_by_multiple_options_at_once(self):
|
def test_get_all_by_multiple_options_at_once(self):
|
||||||
# Test searching by multiple options at once.
|
# Test searching by multiple options at once.
|
||||||
c = context.get_admin_context()
|
c = context.get_admin_context()
|
||||||
@ -7937,7 +7892,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
'uuid': '00000000-0000-0000-0000-000000000010',
|
'uuid': '00000000-0000-0000-0000-000000000010',
|
||||||
'info_cache': objects.InstanceInfoCache(
|
'info_cache': objects.InstanceInfoCache(
|
||||||
network_info=fake_network_info('192.168.0.1'))})
|
network_info=fake_network_info('192.168.0.1'))})
|
||||||
instance2 = self._create_fake_instance_obj({
|
self._create_fake_instance_obj({ # instance2
|
||||||
'display_name': 'woo',
|
'display_name': 'woo',
|
||||||
'uuid': '00000000-0000-0000-0000-000000000020',
|
'uuid': '00000000-0000-0000-0000-000000000020',
|
||||||
'info_cache': objects.InstanceInfoCache(
|
'info_cache': objects.InstanceInfoCache(
|
||||||
@ -7977,10 +7932,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.assertEqual(len(instances), 1)
|
self.assertEqual(len(instances), 1)
|
||||||
self.assertEqual(instances[0]['uuid'], instance3['uuid'])
|
self.assertEqual(instances[0]['uuid'], instance3['uuid'])
|
||||||
|
|
||||||
db.instance_destroy(c, instance1['uuid'])
|
|
||||||
db.instance_destroy(c, instance2['uuid'])
|
|
||||||
db.instance_destroy(c, instance3['uuid'])
|
|
||||||
|
|
||||||
def test_get_all_by_image(self):
|
def test_get_all_by_image(self):
|
||||||
# Test searching instances by image.
|
# Test searching instances by image.
|
||||||
|
|
||||||
@ -8007,10 +7958,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
search_opts={'image': ['1234', '4567']})
|
search_opts={'image': ['1234', '4567']})
|
||||||
self.assertEqual(len(instances), 3)
|
self.assertEqual(len(instances), 3)
|
||||||
|
|
||||||
db.instance_destroy(c, instance1['uuid'])
|
|
||||||
db.instance_destroy(c, instance2['uuid'])
|
|
||||||
db.instance_destroy(c, instance3['uuid'])
|
|
||||||
|
|
||||||
def test_get_all_by_flavor(self):
|
def test_get_all_by_flavor(self):
|
||||||
# Test searching instances by image.
|
# Test searching instances by image.
|
||||||
|
|
||||||
@ -8047,10 +7994,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.assertIn(instance2['uuid'], instance_uuids)
|
self.assertIn(instance2['uuid'], instance_uuids)
|
||||||
self.assertIn(instance3['uuid'], instance_uuids)
|
self.assertIn(instance3['uuid'], instance_uuids)
|
||||||
|
|
||||||
db.instance_destroy(c, instance1['uuid'])
|
|
||||||
db.instance_destroy(c, instance2['uuid'])
|
|
||||||
db.instance_destroy(c, instance3['uuid'])
|
|
||||||
|
|
||||||
def test_get_all_by_state(self):
|
def test_get_all_by_state(self):
|
||||||
# Test searching instances by state.
|
# Test searching instances by state.
|
||||||
|
|
||||||
@ -8087,16 +8030,12 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
power_state.RUNNING]})
|
power_state.RUNNING]})
|
||||||
self.assertEqual(len(instances), 3)
|
self.assertEqual(len(instances), 3)
|
||||||
|
|
||||||
db.instance_destroy(c, instance1['uuid'])
|
|
||||||
db.instance_destroy(c, instance2['uuid'])
|
|
||||||
db.instance_destroy(c, instance3['uuid'])
|
|
||||||
|
|
||||||
def test_get_all_by_metadata(self):
|
def test_get_all_by_metadata(self):
|
||||||
# Test searching instances by metadata.
|
# Test searching instances by metadata.
|
||||||
|
|
||||||
c = context.get_admin_context()
|
c = context.get_admin_context()
|
||||||
instance0 = self._create_fake_instance_obj()
|
self._create_fake_instance_obj() # instance0
|
||||||
instance1 = self._create_fake_instance_obj({
|
self._create_fake_instance_obj({ # instance1
|
||||||
'metadata': {'key1': 'value1'}})
|
'metadata': {'key1': 'value1'}})
|
||||||
instance2 = self._create_fake_instance_obj({
|
instance2 = self._create_fake_instance_obj({
|
||||||
'metadata': {'key2': 'value2'}})
|
'metadata': {'key2': 'value2'}})
|
||||||
@ -8147,12 +8086,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.assertEqual(len(instances), 1)
|
self.assertEqual(len(instances), 1)
|
||||||
self.assertEqual(instances[0]['uuid'], instance4['uuid'])
|
self.assertEqual(instances[0]['uuid'], instance4['uuid'])
|
||||||
|
|
||||||
db.instance_destroy(c, instance0['uuid'])
|
|
||||||
db.instance_destroy(c, instance1['uuid'])
|
|
||||||
db.instance_destroy(c, instance2['uuid'])
|
|
||||||
db.instance_destroy(c, instance3['uuid'])
|
|
||||||
db.instance_destroy(c, instance4['uuid'])
|
|
||||||
|
|
||||||
def test_get_all_by_system_metadata(self):
|
def test_get_all_by_system_metadata(self):
|
||||||
# Test searching instances by system metadata.
|
# Test searching instances by system metadata.
|
||||||
|
|
||||||
@ -8252,8 +8185,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.assertIn('metadata', payload)
|
self.assertIn('metadata', payload)
|
||||||
self.assertEqual(payload['metadata'], {'key3': 'value3'})
|
self.assertEqual(payload['metadata'], {'key3': 'value3'})
|
||||||
|
|
||||||
db.instance_destroy(_context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_disallow_metadata_changes_during_building(self):
|
def test_disallow_metadata_changes_during_building(self):
|
||||||
def fake_change_instance_metadata(inst, ctxt, diff, instance=None,
|
def fake_change_instance_metadata(inst, ctxt, diff, instance=None,
|
||||||
instance_uuid=None):
|
instance_uuid=None):
|
||||||
@ -8296,8 +8227,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
expected = {instance['uuid']: [fault_fixture]}
|
expected = {instance['uuid']: [fault_fixture]}
|
||||||
self.assertEqual(output, expected)
|
self.assertEqual(output, expected)
|
||||||
|
|
||||||
db.instance_destroy(_context, instance['uuid'])
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_db_block_device_mapping(bdm_ref):
|
def _parse_db_block_device_mapping(bdm_ref):
|
||||||
attr_list = ('delete_on_termination', 'device_name', 'no_device',
|
attr_list = ('delete_on_termination', 'device_name', 'no_device',
|
||||||
@ -8453,12 +8382,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
for expected, got in zip(expected_result, bdms):
|
for expected, got in zip(expected_result, bdms):
|
||||||
self.assertThat(expected, matchers.IsSubDictOf(got))
|
self.assertThat(expected, matchers.IsSubDictOf(got))
|
||||||
|
|
||||||
for bdm in db.block_device_mapping_get_all_by_instance(
|
|
||||||
self.context, instance['uuid']):
|
|
||||||
db.block_device_mapping_destroy(self.context, bdm['id'])
|
|
||||||
instance.refresh()
|
|
||||||
self.compute.terminate_instance(self.context, instance, [], [])
|
|
||||||
|
|
||||||
def _test_check_and_transform_bdm(self, bdms, expected_bdms,
|
def _test_check_and_transform_bdm(self, bdms, expected_bdms,
|
||||||
image_bdms=None, base_options=None,
|
image_bdms=None, base_options=None,
|
||||||
legacy_bdms=False,
|
legacy_bdms=False,
|
||||||
@ -8693,11 +8616,8 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
"""
|
"""
|
||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
flavors.get_default_flavor(), image_href='some-fake-image')
|
flavors.get_default_flavor(), image_href='some-fake-image')
|
||||||
try:
|
|
||||||
self.assertEqual(len(refs), 1)
|
self.assertEqual(len(refs), 1)
|
||||||
self.assertEqual(refs[0]['reservation_id'], resv_id)
|
self.assertEqual(refs[0]['reservation_id'], resv_id)
|
||||||
finally:
|
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_reservation_ids_two_instances(self):
|
def test_reservation_ids_two_instances(self):
|
||||||
"""Verify building 2 instances at once results in a
|
"""Verify building 2 instances at once results in a
|
||||||
@ -8707,15 +8627,11 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
flavors.get_default_flavor(), image_href='some-fake-image',
|
flavors.get_default_flavor(), image_href='some-fake-image',
|
||||||
min_count=2, max_count=2)
|
min_count=2, max_count=2)
|
||||||
try:
|
|
||||||
self.assertEqual(len(refs), 2)
|
self.assertEqual(len(refs), 2)
|
||||||
self.assertIsNotNone(resv_id)
|
self.assertIsNotNone(resv_id)
|
||||||
finally:
|
|
||||||
for instance in refs:
|
for instance in refs:
|
||||||
self.assertEqual(instance['reservation_id'], resv_id)
|
self.assertEqual(instance['reservation_id'], resv_id)
|
||||||
|
|
||||||
db.instance_destroy(self.context, refs[0]['uuid'])
|
|
||||||
|
|
||||||
def test_multi_instance_display_name_template(self):
|
def test_multi_instance_display_name_template(self):
|
||||||
self.flags(multi_instance_display_name_template='%(name)s')
|
self.flags(multi_instance_display_name_template='%(name)s')
|
||||||
(refs, resv_id) = self.compute_api.create(self.context,
|
(refs, resv_id) = self.compute_api.create(self.context,
|
||||||
@ -8748,44 +8664,37 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
# Test the instance architecture.
|
# Test the instance architecture.
|
||||||
i_ref = self._create_fake_instance_obj()
|
i_ref = self._create_fake_instance_obj()
|
||||||
self.assertEqual(i_ref['architecture'], arch.X86_64)
|
self.assertEqual(i_ref['architecture'], arch.X86_64)
|
||||||
db.instance_destroy(self.context, i_ref['uuid'])
|
|
||||||
|
|
||||||
def test_instance_unknown_architecture(self):
|
def test_instance_unknown_architecture(self):
|
||||||
# Test if the architecture is unknown.
|
# Test if the architecture is unknown.
|
||||||
instance = self._create_fake_instance_obj(
|
instance = self._create_fake_instance_obj(
|
||||||
params={'architecture': ''})
|
params={'architecture': ''})
|
||||||
try:
|
|
||||||
self.compute.run_instance(self.context, instance, {}, {}, None,
|
self.compute.run_instance(self.context, instance, {}, {}, None,
|
||||||
None, None, True, None, False)
|
None, None, True, None, False)
|
||||||
instance = db.instance_get_by_uuid(self.context,
|
instance = db.instance_get_by_uuid(self.context,
|
||||||
instance['uuid'])
|
instance['uuid'])
|
||||||
self.assertNotEqual(instance['architecture'], 'Unknown')
|
self.assertNotEqual(instance['architecture'], 'Unknown')
|
||||||
finally:
|
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_instance_name_template(self):
|
def test_instance_name_template(self):
|
||||||
# Test the instance_name template.
|
# Test the instance_name template.
|
||||||
self.flags(instance_name_template='instance-%d')
|
self.flags(instance_name_template='instance-%d')
|
||||||
i_ref = self._create_fake_instance_obj()
|
i_ref = self._create_fake_instance_obj()
|
||||||
self.assertEqual(i_ref['name'], 'instance-%d' % i_ref['id'])
|
self.assertEqual(i_ref['name'], 'instance-%d' % i_ref['id'])
|
||||||
db.instance_destroy(self.context, i_ref['uuid'])
|
|
||||||
|
|
||||||
self.flags(instance_name_template='instance-%(uuid)s')
|
self.flags(instance_name_template='instance-%(uuid)s')
|
||||||
i_ref = self._create_fake_instance_obj()
|
i_ref = self._create_fake_instance_obj()
|
||||||
self.assertEqual(i_ref['name'], 'instance-%s' % i_ref['uuid'])
|
self.assertEqual(i_ref['name'], 'instance-%s' % i_ref['uuid'])
|
||||||
db.instance_destroy(self.context, i_ref['uuid'])
|
|
||||||
|
|
||||||
self.flags(instance_name_template='%(id)d-%(uuid)s')
|
self.flags(instance_name_template='%(id)d-%(uuid)s')
|
||||||
i_ref = self._create_fake_instance_obj()
|
i_ref = self._create_fake_instance_obj()
|
||||||
self.assertEqual(i_ref['name'], '%d-%s' %
|
self.assertEqual(i_ref['name'], '%d-%s' %
|
||||||
(i_ref['id'], i_ref['uuid']))
|
(i_ref['id'], i_ref['uuid']))
|
||||||
db.instance_destroy(self.context, i_ref['uuid'])
|
|
||||||
|
|
||||||
# not allowed.. default is uuid
|
# not allowed.. default is uuid
|
||||||
self.flags(instance_name_template='%(name)s')
|
self.flags(instance_name_template='%(name)s')
|
||||||
i_ref = self._create_fake_instance_obj()
|
i_ref = self._create_fake_instance_obj()
|
||||||
self.assertEqual(i_ref['name'], i_ref['uuid'])
|
self.assertEqual(i_ref['name'], i_ref['uuid'])
|
||||||
db.instance_destroy(self.context, i_ref['uuid'])
|
|
||||||
|
|
||||||
def test_add_remove_fixed_ip(self):
|
def test_add_remove_fixed_ip(self):
|
||||||
instance = self._create_fake_instance_obj(params={'host': CONF.host})
|
instance = self._create_fake_instance_obj(params={'host': CONF.host})
|
||||||
@ -8847,8 +8756,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.detach_volume,
|
self.compute_api.detach_volume,
|
||||||
self.context, instance, volume)
|
self.context, instance, volume)
|
||||||
|
|
||||||
@mock.patch.object(objects.BlockDeviceMappingList,
|
@mock.patch.object(objects.BlockDeviceMappingList, 'get_by_instance_uuid')
|
||||||
'get_by_instance_uuid')
|
|
||||||
@mock.patch.object(cinder.API, 'get')
|
@mock.patch.object(cinder.API, 'get')
|
||||||
def test_no_rescue_in_volume_state_attaching(self,
|
def test_no_rescue_in_volume_state_attaching(self,
|
||||||
mock_get_vol,
|
mock_get_vol,
|
||||||
@ -8903,8 +8811,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.get_vnc_console,
|
self.compute_api.get_vnc_console,
|
||||||
self.context, instance, 'novnc')
|
self.context, instance, 'novnc')
|
||||||
|
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_spice_console(self):
|
def test_spice_console(self):
|
||||||
# Make sure we can a spice console for an instance.
|
# Make sure we can a spice console for an instance.
|
||||||
|
|
||||||
@ -8944,8 +8850,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.get_spice_console,
|
self.compute_api.get_spice_console,
|
||||||
self.context, instance, 'spice')
|
self.context, instance, 'spice')
|
||||||
|
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_rdp_console(self):
|
def test_rdp_console(self):
|
||||||
# Make sure we can a rdp console for an instance.
|
# Make sure we can a rdp console for an instance.
|
||||||
|
|
||||||
@ -8985,8 +8889,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.get_rdp_console,
|
self.compute_api.get_rdp_console,
|
||||||
self.context, instance, 'rdp')
|
self.context, instance, 'rdp')
|
||||||
|
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_serial_console(self):
|
def test_serial_console(self):
|
||||||
# Make sure we can get a serial proxy url for an instance.
|
# Make sure we can get a serial proxy url for an instance.
|
||||||
|
|
||||||
@ -9027,8 +8929,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.get_serial_console,
|
self.compute_api.get_serial_console,
|
||||||
self.context, instance, 'serial')
|
self.context, instance, 'serial')
|
||||||
|
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_console_output(self):
|
def test_console_output(self):
|
||||||
fake_instance = {'uuid': 'fake_uuid',
|
fake_instance = {'uuid': 'fake_uuid',
|
||||||
'host': 'fake_compute_host'}
|
'host': 'fake_compute_host'}
|
||||||
@ -9054,8 +8954,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.get_console_output,
|
self.compute_api.get_console_output,
|
||||||
self.context, instance)
|
self.context, instance)
|
||||||
|
|
||||||
db.instance_destroy(self.context, instance['uuid'])
|
|
||||||
|
|
||||||
def test_attach_interface(self):
|
def test_attach_interface(self):
|
||||||
new_type = flavors.get_flavor_by_flavor_id('4')
|
new_type = flavors.get_flavor_by_flavor_id('4')
|
||||||
sys_meta = flavors.save_flavor_info({}, new_type)
|
sys_meta = flavors.save_flavor_info({}, new_type)
|
||||||
@ -9396,10 +9294,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
instance = self.compute_api.get(self.context, instance['uuid'],
|
instance = self.compute_api.get(self.context, instance['uuid'],
|
||||||
want_objects=True)
|
want_objects=True)
|
||||||
self.compute_api.inject_network_info(self.context, instance)
|
self.compute_api.inject_network_info(self.context, instance)
|
||||||
self.stubs.Set(self.compute_api.network_api,
|
|
||||||
'deallocate_for_instance',
|
|
||||||
lambda *a, **kw: None)
|
|
||||||
self.compute_api.delete(self.context, instance)
|
|
||||||
|
|
||||||
def test_reset_network(self):
|
def test_reset_network(self):
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
@ -9454,10 +9348,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.compute_api.get_diagnostics(self.context, instance)
|
self.compute_api.get_diagnostics(self.context, instance)
|
||||||
|
|
||||||
self.stubs.Set(self.compute_api.network_api, 'deallocate_for_instance',
|
|
||||||
lambda *a, **kw: None)
|
|
||||||
self.compute_api.delete(self.context, instance)
|
|
||||||
|
|
||||||
def test_get_instance_diagnostics(self):
|
def test_get_instance_diagnostics(self):
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
|
|
||||||
@ -9468,10 +9358,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.compute_api.get_instance_diagnostics(self.context, instance)
|
self.compute_api.get_instance_diagnostics(self.context, instance)
|
||||||
|
|
||||||
self.stubs.Set(self.compute_api.network_api, 'deallocate_for_instance',
|
|
||||||
lambda *a, **kw: None)
|
|
||||||
self.compute_api.delete(self.context, instance)
|
|
||||||
|
|
||||||
def test_secgroup_refresh(self):
|
def test_secgroup_refresh(self):
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
|
|
||||||
@ -9641,7 +9527,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
instance.refresh()
|
instance.refresh()
|
||||||
self.assertEqual(instance.task_state, task_states.REBUILDING)
|
self.assertEqual(instance.task_state, task_states.REBUILDING)
|
||||||
self.assertEqual(instance.host, 'fake_dest_host')
|
self.assertEqual(instance.host, 'fake_dest_host')
|
||||||
instance.destroy()
|
|
||||||
|
|
||||||
def test_fail_evacuate_from_non_existing_host(self):
|
def test_fail_evacuate_from_non_existing_host(self):
|
||||||
inst = {}
|
inst = {}
|
||||||
@ -9669,7 +9554,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.evacuate, self.context.elevated(), instance,
|
self.compute_api.evacuate, self.context.elevated(), instance,
|
||||||
host='fake_dest_host', on_shared_storage=True,
|
host='fake_dest_host', on_shared_storage=True,
|
||||||
admin_password=None)
|
admin_password=None)
|
||||||
instance.destroy()
|
|
||||||
|
|
||||||
def test_fail_evacuate_from_running_host(self):
|
def test_fail_evacuate_from_running_host(self):
|
||||||
instance = self._create_fake_instance_obj(services=True)
|
instance = self._create_fake_instance_obj(services=True)
|
||||||
@ -9685,7 +9569,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.evacuate, self.context.elevated(), instance,
|
self.compute_api.evacuate, self.context.elevated(), instance,
|
||||||
host='fake_dest_host', on_shared_storage=True,
|
host='fake_dest_host', on_shared_storage=True,
|
||||||
admin_password=None)
|
admin_password=None)
|
||||||
instance.destroy()
|
|
||||||
|
|
||||||
def test_fail_evacuate_instance_in_wrong_state(self):
|
def test_fail_evacuate_instance_in_wrong_state(self):
|
||||||
states = [vm_states.BUILDING, vm_states.PAUSED, vm_states.SUSPENDED,
|
states = [vm_states.BUILDING, vm_states.PAUSED, vm_states.SUSPENDED,
|
||||||
@ -9699,7 +9582,6 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.compute_api.evacuate, self.context, instance,
|
self.compute_api.evacuate, self.context, instance,
|
||||||
host='fake_dest_host', on_shared_storage=True,
|
host='fake_dest_host', on_shared_storage=True,
|
||||||
admin_password=None)
|
admin_password=None)
|
||||||
instance.destroy()
|
|
||||||
|
|
||||||
def test_get_migrations(self):
|
def test_get_migrations(self):
|
||||||
migration = test_migration.fake_db_migration(uuid="1234")
|
migration = test_migration.fake_db_migration(uuid="1234")
|
||||||
|
Loading…
Reference in New Issue
Block a user