Merge "Updated watchdog tests with machine type"
This commit is contained in:
commit
ec77c3c868
@ -20,40 +20,46 @@ from whitebox_tempest_plugin.api.compute import base
|
|||||||
@ddt.ddt
|
@ddt.ddt
|
||||||
class WatchdogDeviceTest(base.BaseWhiteboxComputeTest):
|
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):
|
def _get_watchdog_action_from_xml(self, server_id):
|
||||||
root = self.get_server_xml(server_id)
|
root = self.get_server_xml(server_id)
|
||||||
return root.find(".devices/watchdog")
|
return root.find(".devices/watchdog")
|
||||||
|
|
||||||
@ddt.data('reset', 'poweroff', 'pause', 'none', 'disabled')
|
@ddt.data('reset', 'poweroff', 'pause', 'none', 'disabled')
|
||||||
def test_actions_via_flavor(self, action):
|
def test_action_with_flavor(self, action):
|
||||||
flavor = self._create_flavor_with_watchdog_property(action)
|
flavor_id = self.create_flavor(
|
||||||
|
extra_specs={"hw:watchdog_action": action})['id']
|
||||||
server = self.create_test_server(
|
server = self.create_test_server(
|
||||||
flavor=flavor['id'], wait_until='ACTIVE')
|
flavor=flavor_id, wait_until='ACTIVE')
|
||||||
|
|
||||||
watchdog_dev = self._get_watchdog_action_from_xml(server['id'])
|
watchdog_dev = self._get_watchdog_action_from_xml(server['id'])
|
||||||
|
|
||||||
if action == 'disabled':
|
if action == 'disabled':
|
||||||
# as watchdog is disabled there is no watchdog dev in xml
|
# as watchdog is disabled there is no watchdog dev in xml
|
||||||
self.assertIsNone(watchdog_dev)
|
self.assertIsNone(watchdog_dev)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(action, watchdog_dev.attrib['action'])
|
self.assertEqual(action, watchdog_dev.attrib['action'])
|
||||||
|
|
||||||
@ddt.data('reset', 'poweroff', 'pause', 'none', 'disabled')
|
@ddt.data(
|
||||||
def test_actions_via_image(self, action):
|
('reset', 'pc'), ('poweroff', 'pc'), ('pause', 'pc'), ('none', 'pc'),
|
||||||
image_id = self._get_image_with_watchdog_property(action)
|
('disabled', 'pc'),
|
||||||
|
('reset', 'q35'), ('poweroff', 'q35'), ('pause', 'q35'),
|
||||||
|
('none', 'q35'), ('disabled', 'q35')
|
||||||
|
)
|
||||||
|
@ddt.unpack
|
||||||
|
def test_action_with_image(self, action, m_type):
|
||||||
|
image_id = self.copy_default_image(
|
||||||
|
hw_watchdog_action=action,
|
||||||
|
hw_machine_type=m_type
|
||||||
|
)
|
||||||
server = self.create_test_server(
|
server = self.create_test_server(
|
||||||
image_id=image_id, wait_until='ACTIVE')
|
image_id=image_id, wait_until='ACTIVE')
|
||||||
|
|
||||||
watchdog_dev = self._get_watchdog_action_from_xml(server['id'])
|
watchdog_dev = self._get_watchdog_action_from_xml(server['id'])
|
||||||
|
|
||||||
if action == 'disabled':
|
if m_type == 'q35' and action == 'disabled':
|
||||||
|
# for machine_type q35, disabled watchdog exist with 'reset'
|
||||||
|
self.assertEqual('reset', watchdog_dev.attrib['action'])
|
||||||
|
elif m_type == 'pc' and action == 'disabled':
|
||||||
# as watchdog is disabled there is no watchdog dev in xml
|
# as watchdog is disabled there is no watchdog dev in xml
|
||||||
self.assertIsNone(watchdog_dev)
|
self.assertIsNone(watchdog_dev)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user