Limit logging in security group logging tests

Log only up to given limit start and end entries, avoid over log of
test since lots of traffic generated to test security group logging ovn
feature and its limits, and this caused log file size to increase substantially.

Security group logging tests now differentiate between entries
fetched for test assertions (fully), and for test log (partly).

This handles issue of tempest failing even if tests pass successfully
due to tempest log file size being too large.

Related-Bug: #2102022
Change-Id: I4e49f537f9779e503050bd50fd4b52e921f3dbe5
This commit is contained in:
Maor Blaustein 2025-03-12 09:31:55 +02:00
parent d08fcd29e9
commit a01def7a72

View File

@ -70,6 +70,7 @@ class BaseSecGroupLoggingTest(
ConnectionResetError,
EOFError)
ENTRY_PTN = 'acl_log'
LOGGING_LIMIT_PER_TEST = 60
@classmethod
def resource_setup(cls):
@ -148,6 +149,18 @@ class BaseSecGroupLoggingTest(
self.project_id, security_group=-1, security_group_rule=-1)
self._hypervisors_counts = dict()
@classmethod
def limit_log_entries(cls, entries, limit_amount=-1):
_limit_amount = cls.LOGGING_LIMIT_PER_TEST if limit_amount == -1 \
else limit_amount
if len(entries) > _limit_amount:
_limit_log_portion = _limit_amount // 2
limited_entries = entries[:_limit_log_portion] + ['...'] + \
entries[-_limit_log_portion:]
else:
limited_entries = entries
return limited_entries
def _create_ssh_client(self, host, username=None, key_file=None):
"""Returns ssh client.
@ -229,11 +242,15 @@ class BaseSecGroupLoggingTest(
new_logs = [output for output in cmd_outputs
if a < int(output.split("|")[1]) <= b]
new_logs_str = "\n".join(new_logs)
# entries in memory for testing
self._hypervisors_counts[hypervisor_ssh.host][
'tested_logs'] = new_logs_str
# log in tempest the retrieved entries and amount
mess = "The following SGL entries fetched: %d < log ID <= %d\n\n%s"
LOG.debug(mess, a, b, new_logs_str)
# log only up to limit entries, avoid test over log for limit tests
# which generate lots of traffic
new_logs_log = self.limit_log_entries(new_logs)
# log in tempest retrieved start/end entries and total amount
mess = "SGL start/end entries sample: %d < log ID <= %d\n\n%s"
LOG.debug(mess, a, b, new_logs_log)
# SGL entries amount - used to verify rate/burst limits applied
_test_logs_amount = len(new_logs)
self._hypervisors_counts[hypervisor_ssh.host][