Adds libvirt watchdog

- Add test for different supported actions via Flavor and Image
- Adds ddt in requirements.txt

Change-Id: I5aee8f48325cd43d90c981252a5af1d745882239
This commit is contained in:
Amit Uniyal 2024-06-04 02:17:50 -04:00
parent d78d93803e
commit fd55f90eb6
2 changed files with 61 additions and 0 deletions

View File

@ -17,3 +17,4 @@ pymysql
# the vTPM tests require it
barbican-tempest-plugin<=1.6.0;python_version<='3.6'
barbican-tempest-plugin;python_version>'3.6'
ddt>=1.7.2

View File

@ -0,0 +1,60 @@
# Copyright 2024 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.
import ddt
from whitebox_tempest_plugin.api.compute import base
@ddt.ddt
class WatchdogDeviceTest(base.BaseWhiteboxComputeTest):
def _create_flavor_with_watchdog_property(self, action):
return self.create_flavor(
extra_specs={"hw:watchdog_action": action}
)
def _get_image_with_watchdog_property(self, action):
return self.copy_default_image(hw_watchdog_action=action)
def _get_watchdog_action_from_xml(self, server_id):
root = self.get_server_xml(server_id)
return root.find(".devices/watchdog")
@ddt.data('reset', 'poweroff', 'pause', 'none', 'disabled')
def test_actions_via_flavor(self, action):
flavor = self._create_flavor_with_watchdog_property(action)
server = self.create_test_server(
flavor=flavor['id'], wait_until='ACTIVE')
watchdog_dev = self._get_watchdog_action_from_xml(server['id'])
if action == 'disabled':
# as watchdog is disabled there is no watchdog dev in xml
self.assertIsNone(watchdog_dev)
else:
self.assertEqual(action, watchdog_dev.attrib['action'])
@ddt.data('reset', 'poweroff', 'pause', 'none', 'disabled')
def test_actions_via_image(self, action):
image_id = self._get_image_with_watchdog_property(action)
server = self.create_test_server(
image_id=image_id, wait_until='ACTIVE')
watchdog_dev = self._get_watchdog_action_from_xml(server['id'])
if action == 'disabled':
# as watchdog is disabled there is no watchdog dev in xml
self.assertIsNone(watchdog_dev)
else:
self.assertEqual(action, watchdog_dev.attrib['action'])