Dettaching instance_uuid for standalone TC's

For standalone test cases, where delete_node is set as False,
the instance_uuid remains attached with the node even after test
case execution.

This affects the serial execution of tempest test cases as
instance_uuid is already associated to node which results in
failure of consecutive test cases.
This dettaches instance_uuid of a node while cleanup.

Change-Id: I854c533ef4f76f3abb589dbcc9c39358ebedc194
This commit is contained in:
Ameya Raut 2022-04-19 09:27:28 +00:00
parent d3360cf3b6
commit c652e31d42

View File

@ -122,6 +122,16 @@ class BaremetalStandaloneManager(bm.BaremetalScenarioTest,
node_id, instance_uuid=instance_uuid)
return body
@classmethod
def _disassociate_instance_with_node(cls, node_id):
"""Disassociate instance_uuid from attached node.
:param node_id: Name or UUID of the node.
"""
cls.update_node(node_id, [{'op': 'replace',
'path': '/instance_uuid',
'value': None}])
@classmethod
def get_node_vifs(cls, node_id):
"""Return a list of VIFs for a given node.
@ -230,6 +240,28 @@ class BaremetalStandaloneManager(bm.BaremetalScenarioTest,
return nodes[0]
@classmethod
def unreserve_node(cls, node):
"""Unreserves node by disassociating instance_uuid attached to node.
:param node: Ironic node to disassociate instance_uuid from.
"""
def _try_to_disassociate_instance():
_, node_prop = cls.baremetal_client.show_node(node['uuid'])
if node_prop['instance_uuid']:
try:
cls._disassociate_instance_with_node(node['uuid'])
except lib_exc.Conflict:
return False
return True
if (not test_utils.call_until_true(
_try_to_disassociate_instance,
duration=CONF.baremetal.association_timeout, sleep_for=1)):
msg = ('Timed out waiting to disassociate instance from '
'ironic node uuid %s' % node['instance_uuid'])
raise lib_exc.TimeoutException(msg)
@classmethod
def boot_node(cls, image_ref=None, image_checksum=None,
boot_option=None):
@ -568,6 +600,7 @@ class BaremetalStandaloneScenarioTest(BaremetalStandaloneManager):
except lib_exc.NotFound:
pass
cls.terminate_node(cls.node['uuid'])
cls.unreserve_node(cls.node)
base.reset_baremetal_api_microversion()
super(BaremetalStandaloneManager, cls).resource_cleanup()