From fd55f90eb69e96fbea609f3b6e736620c7189dc2 Mon Sep 17 00:00:00 2001 From: Amit Uniyal Date: Tue, 4 Jun 2024 02:17:50 -0400 Subject: [PATCH] Adds libvirt watchdog - Add test for different supported actions via Flavor and Image - Adds ddt in requirements.txt Change-Id: I5aee8f48325cd43d90c981252a5af1d745882239 --- requirements.txt | 1 + .../api/compute/test_watchdog_devices.py | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 whitebox_tempest_plugin/api/compute/test_watchdog_devices.py diff --git a/requirements.txt b/requirements.txt index b3f0b891..5afab7b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/whitebox_tempest_plugin/api/compute/test_watchdog_devices.py b/whitebox_tempest_plugin/api/compute/test_watchdog_devices.py new file mode 100644 index 00000000..a544ec2b --- /dev/null +++ b/whitebox_tempest_plugin/api/compute/test_watchdog_devices.py @@ -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'])