From 20e04f5e47e98cd8c0936888cd715571494206ad Mon Sep 17 00:00:00 2001 From: Paras Babbar Date: Thu, 21 May 2020 18:20:46 -0400 Subject: [PATCH] Validate hw_video_type image property This patch tests the hw_video_type image property with values virtio and none. Change-Id: Iea5c2a73674a97ad212cfcf5f8dea9185f8bda27 --- .zuul.yaml | 1 + .../api/compute/test_hw_video_type.py | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 whitebox_tempest_plugin/api/compute/test_hw_video_type.py diff --git a/.zuul.yaml b/.zuul.yaml index 37055ba8..63c57fa4 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -46,6 +46,7 @@ tox_envlist: all tempest_concurrency: 1 tempest_test_regex: ^whitebox_tempest_plugin\. + tempest_black_regex: "create_none_instance|virtio_to_none|none_to_virtio" devstack_plugins: whitebox-tempest-plugin: https://opendev.org/x/whitebox-tempest-plugin.git devstack_localrc: diff --git a/whitebox_tempest_plugin/api/compute/test_hw_video_type.py b/whitebox_tempest_plugin/api/compute/test_hw_video_type.py new file mode 100644 index 00000000..a792fcd5 --- /dev/null +++ b/whitebox_tempest_plugin/api/compute/test_hw_video_type.py @@ -0,0 +1,60 @@ +# Copyright 2020 Red Hat +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tempest.common import waiters + +from whitebox_tempest_plugin.api.compute import base + + +class HwVideoModelTest(base.BaseWhiteboxComputeTest): + """Tests the support of different hardware video model type + virtio and none that can be set through image + meta data property flag "hw_video_model". + """ + + def setUp(self): + super(HwVideoModelTest, self).setUp() + + self.virtio_image_id = self.copy_default_image(hw_video_model='virtio') + self.none_image_id = self.copy_default_image(hw_video_model='none') + + def _assert_hw_video_type(self, server, hw_video_type): + root = self.get_server_xml(server['id']) + hw_video = root.find('./devices/video/model') + self.assertEqual(hw_video_type, hw_video.get('type')) + + def test_create_virtio_instance(self): + server = self.create_test_server(image_id=self.virtio_image_id) + self._assert_hw_video_type(server, 'virtio') + + def test_create_none_instance(self): + server = self.create_test_server(image_id=self.none_image_id) + self._assert_hw_video_type(server, 'none') + + def test_rebuild_virtio_to_none(self): + server = self.create_test_server(image_id=self.virtio_image_id) + self._assert_hw_video_type(server, 'virtio') + self.servers_client.rebuild_server(server['id'], self.none_image_id) + waiters.wait_for_server_status(self.servers_client, server['id'], + 'ACTIVE') + self._assert_hw_video_type(server, 'none') + + def test_rebuild_none_to_virtio(self): + server = self.create_test_server(image_id=self.virtio_image_id) + self._assert_hw_video_type(server, 'virtio') + self.servers_client.rebuild_server(server['id'], self.none_image_id) + waiters.wait_for_server_status(self.servers_client, server['id'], + 'ACTIVE') + self._assert_hw_video_type(server, 'none')