Fix SGL test multicompute and cleanup

There are environments, like Openstack on Openshift (or CRC) where we
might see two nodes on an environment but one is not acting like a
compute node, thus no VMs can be spawned there. This change checks
specifically for compute nodes and not just nodes on a deployment.

Furthermore, the ALL network log object used to remain in between test
runs because it did not have a cleanup. This is now properly handled.

Change-Id: I1debc663bb19260d6a7bdd7ea642eaa51994a4ca
Signed-off-by: Elvira García <egarciar@redhat.com>
This commit is contained in:
Elvira García 2025-02-10 14:37:08 +01:00
parent 37a4f7b828
commit de9fd26d70
2 changed files with 13 additions and 10 deletions

View File

@ -361,10 +361,10 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase):
(node['is_controller'] or node['is_compute'])]
@classmethod
def is_setup_single_node(cls):
def is_setup_single_compute(cls):
if not hasattr(cls, 'nodes'):
cls.discover_nodes()
return len(cls.nodes) == 1
return len([node for node in cls.nodes if node['is_compute']]) == 1
def get_node_setting(self, node_name, setting):
for node in self.nodes:

View File

@ -346,7 +346,7 @@ class BaseSecGroupLoggingTest(
event='ALL',
description='',
enabled=True,
add_cleanup=True):
fail_if_deleted=True):
_log = self.create_log(
name=name or data_utils.rand_name('{}-test-log'.format(
self.__class__.__name__)),
@ -354,8 +354,12 @@ class BaseSecGroupLoggingTest(
resource_id=resource_id or self.secgrp['id'],
event=event,
enabled=enabled)
if add_cleanup:
if fail_if_deleted:
self.addCleanup(self.admin_client.delete_log, _log['id'])
else:
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_client.delete_log, _log['id'])
return _log
def verify_meter_and_band_amounts(self, meter_range, meter_band_range):
@ -650,13 +654,12 @@ class BaseSecGroupLoggingTest(
round((1 + offset) * long_test_target)),
limits_fail_msg)
self._verify_duplicate_entries(vm_a)
# NOTE(mblue): skip multi-compute test when setup is single node
for vms_same_compute in (True, False):
if self.is_setup_single_node() and not vms_same_compute:
continue
self._verify_duplicate_entries(vms_same_compute, vm_a)
if not self.is_setup_single_compute():
self._verify_duplicate_entries(vm_a, same_compute=False)
def _verify_duplicate_entries(self, same_compute, vm_a):
def _verify_duplicate_entries(self, vm_a, same_compute=True):
# 18) create second VM on the same/different compute node
compute_hint_str = 'same' if same_compute else 'different'
vm_b = self._create_server(
@ -744,7 +747,7 @@ class BaseSecGroupLoggingTest(
else:
rotate_prefix = 'sudo podman exec logrotate_crond '
# 1) enable logging for "all" events
local_log = self._create_log(event='ALL', add_cleanup=False)
local_log = self._create_log(event='ALL', fail_if_deleted=False)
# 2) attempt ssh to VM from undercloud ("drop" event),
# this ensures an initial log entry exists, with needed count value.
self.try_ssh_traffic(vm_a['ssh_client'])