Skip to content

Commit e1cc0ed

Browse files
committed
Add regression test for bug #1928063
Related-Bug: #1928063 Change-Id: Ieb19b4e5ffde56b7f72805aa231f595f45989e60
1 parent 02f4235 commit e1cc0ed

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import copy
14+
import mock
15+
16+
from oslo_utils.fixture import uuidsentinel as uuids
17+
18+
from nova import test
19+
from nova.tests.functional.api import client
20+
from nova.tests.functional.libvirt import base
21+
from nova.tests.unit.virt.libvirt import fakelibvirt
22+
from nova.virt.libvirt.host import SEV_KERNEL_PARAM_FILE
23+
24+
25+
class TestSEVInstanceReboot(base.ServersTestBase):
26+
"""Regression test for bug #1899835
27+
28+
This regression test aims to assert the failure to hard reboot SEV based
29+
instances due to the use of image_meta.name within
30+
nova.virt.hardware.get_mem_encryption_constraint.
31+
"""
32+
microversion = 'latest'
33+
34+
@test.patch_exists(SEV_KERNEL_PARAM_FILE, True)
35+
@test.patch_open(SEV_KERNEL_PARAM_FILE, "1\n")
36+
@mock.patch.object(
37+
fakelibvirt.virConnect, '_domain_capability_features',
38+
new=fakelibvirt.virConnect._domain_capability_features_with_SEV)
39+
def setUp(self):
40+
super().setUp()
41+
42+
# Configure the compute to allow SEV based instances and then start
43+
self.flags(num_memory_encrypted_guests=16, group='libvirt')
44+
self.start_compute()
45+
46+
# Create a SEV enabled image for the test
47+
sev_image = copy.deepcopy(self.glance.image1)
48+
sev_image['id'] = uuids.sev_image_id
49+
sev_image['properties']['hw_firmware_type'] = 'uefi'
50+
sev_image['properties']['hw_machine_type'] = 'q35'
51+
sev_image['properties']['hw_mem_encryption'] = 'True'
52+
self.glance.create(None, sev_image)
53+
54+
def test_hard_reboot(self):
55+
# Launch a SEV based instance and then attempt to hard reboot
56+
server = self._create_server(
57+
image_uuid=uuids.sev_image_id,
58+
networks='none'
59+
)
60+
61+
# FIXME(lyarwood): This is bug #1928063, the instance fails to reboot
62+
# due to a NotImplementedError exception being raised when we try to
63+
# access image_meta.name as this isn't stashed in the system_metadata
64+
# of the instance and as a result is not provided in the image_meta
65+
# associated with the instance during this flow.
66+
ex = self.assertRaises(
67+
client.OpenStackApiException,
68+
self._reboot_server, server, hard=True)
69+
self.assertEqual(500, ex.response.status_code)

0 commit comments

Comments
 (0)