Merge "Add test to check boot server in UEFI type" into mcp/yoga
diff --git a/tempest/api/compute/admin/test_create_server.py b/tempest/api/compute/admin/test_create_server.py
index ccdfbf3..6239c66 100644
--- a/tempest/api/compute/admin/test_create_server.py
+++ b/tempest/api/compute/admin/test_create_server.py
@@ -135,3 +135,36 @@
servers_client=self.client)
disks_num_eph = len(linux_client.get_disks().split('\n'))
self.assertEqual(disks_num + 1, disks_num_eph)
+
+
+class ServersTestUEFI(base.BaseV2ComputeAdminTest):
+ """Test creating server with UEFI firmware type"""
+
+ @classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(ServersTestUEFI, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(ServersTestUEFI, cls).setup_clients()
+ cls.client = cls.servers_client
+
+ @decorators.idempotent_id('94feb6c3-d07e-b3b9-def8-64fd082d9b21')
+ def test_created_server_uefi(self):
+ # create custom image with uefi type
+ custom_img = self.create_image_with_custom_property(
+ hw_machine_type='q35',
+ hw_firmware_type='uefi',
+ )
+ # create the server and wait for it to become ready
+ validation_resources = self.get_class_validation_resources(
+ self.os_primary)
+ server = self.create_test_server(
+ image_id=custom_img, validatable=True,
+ validation_resources=validation_resources, wait_until='SSHABLE')
+ # check UEFI boot loader in console log server
+ uefi_boot_loader = "UEFI Misc Device"
+ console_log = self.client.get_console_output(server['id'])['output']
+ self.assertTrue(console_log, "Console output was empty.")
+ self.assertIn(uefi_boot_loader, console_log)
diff --git a/tempest/api/compute/admin/test_volume.py b/tempest/api/compute/admin/test_volume.py
index 7b50857..9092f9c 100644
--- a/tempest/api/compute/admin/test_volume.py
+++ b/tempest/api/compute/admin/test_volume.py
@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import io
import testtools
from tempest.api.compute import base
@@ -40,35 +39,6 @@
cls.prepare_instance_network()
super(BaseAttachSCSIVolumeTest, cls).setup_credentials()
- def _create_image_with_custom_property(self, **kwargs):
- """Wrapper utility that returns the custom image.
-
- Creates a new image by downloading the default image's bits and
- uploading them to a new image. Any kwargs are set as image properties
- on the new image.
-
- :param return image_id: The UUID of the newly created image.
- """
- image = self.admin_image_client.show_image(CONF.compute.image_ref)
- image_data = self.admin_image_client.show_image_file(
- CONF.compute.image_ref).data
- image_file = io.BytesIO(image_data)
- create_dict = {
- 'container_format': image['container_format'],
- 'disk_format': image['disk_format'],
- 'min_disk': image['min_disk'],
- 'min_ram': image['min_ram'],
- 'visibility': 'public',
- }
- create_dict.update(kwargs)
- new_image = self.admin_image_client.create_image(**create_dict)
- self.addCleanup(self.admin_image_client.wait_for_resource_deletion,
- new_image['id'])
- self.addCleanup(self.admin_image_client.delete_image, new_image['id'])
- self.admin_image_client.store_image_file(new_image['id'], image_file)
-
- return new_image['id']
-
class AttachSCSIVolumeTestJSON(BaseAttachSCSIVolumeTest):
"""Test attaching scsi volume to server"""
@@ -88,7 +58,7 @@
virtio-scsi mode with further asserting list volume attachments
in instance after attach and detach of the volume.
"""
- custom_img = self._create_image_with_custom_property(
+ custom_img = self.create_image_with_custom_property(
hw_scsi_model='virtio-scsi',
hw_disk_bus='scsi',
hw_cdrom_bus='scsi')
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index e16afaf..3a5c275 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import io
import time
from oslo_log import log as logging
@@ -689,3 +690,34 @@
for target_host in hosts:
if source_host != target_host:
return target_host
+
+ def create_image_with_custom_property(self, base_image=None, **kwargs):
+ """Wrapper utility that returns the custom image.
+
+ Creates a new image by downloading the base image bits and
+ uploading them to a new image. Any kwargs are set as image properties
+ on the new image.
+
+ :param return image_id: The UUID of the newly created image.
+ """
+ if base_image is None:
+ base_image = CONF.compute.image_ref
+ image = self.admin_image_client.show_image(base_image)
+ image_data = self.admin_image_client.show_image_file(
+ base_image).data
+ image_file = io.BytesIO(image_data)
+ create_dict = {
+ 'container_format': image['container_format'],
+ 'disk_format': image['disk_format'],
+ 'min_disk': image['min_disk'],
+ 'min_ram': image['min_ram'],
+ 'visibility': 'public',
+ }
+ create_dict.update(kwargs)
+ new_image = self.admin_image_client.create_image(**create_dict)
+ self.addCleanup(self.admin_image_client.wait_for_resource_deletion,
+ new_image['id'])
+ self.addCleanup(self.admin_image_client.delete_image, new_image['id'])
+ self.admin_image_client.store_image_file(new_image['id'], image_file)
+
+ return new_image['id']