Skip to content

Commit c3604ae

Browse files
Satellite-QEsynkd
andauthored
[6.19.z] Automate setting IoP log levels via satellite-installer (#20818)
Automate setting IoP log levels via satellite-installer (#20815) * Automate setting IoP log levels via satellite-installer This PR automates testing of SAT-41750, which introduced satellite-installer options that set the verbosity level of the IoP loggers. It verifies that none of these loggers are set to DEBUG by default, that all of them can be switched to DEBUG using satellite-installer, and that all of them can be switched back to their default values using satellite-installer. It also introduces a helper method for processing satellite-installer help output into a dictionary. * Change Satellite fixture to the correct IoP fixture (cherry picked from commit c484979) Co-authored-by: synkd <48261305+synkd@users.noreply.github.com>
1 parent 1e7706d commit c3604ae

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

tests/foreman/cli/test_rhcloud_iop.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,80 @@ def test_insights_client_registration_with_http_proxy(
332332
assert rhel_contenthost.execute('insights-client --test-connection').status == 0
333333
assert rhel_contenthost.execute('insights-client --status').status == 0
334334
assert rhel_contenthost.execute('insights-client --unregister').status == 0
335+
336+
337+
def process_iop_log_options(installer_output):
338+
"""Takes satellite-installer help output as input and returns a dictionary
339+
with the options as keys and the descriptions of the options as values.
340+
"""
341+
options_dict = {}
342+
for line in installer_output.split('\n'):
343+
parts = line.split()
344+
if parts:
345+
option = parts[0]
346+
description = ' '.join(parts[1:])
347+
options_dict[option] = description
348+
return options_dict
349+
350+
351+
def test_set_iop_log_level_via_installer(module_satellite_iop):
352+
"""Set IoP log level to DEBUG using satellite-installer options.
353+
354+
:id: 0268a6c1-56b5-4a0c-9df9-6c1b34f6cbd7
355+
356+
:steps:
357+
1. Run `satellite-installer --full-help` to get the current IoP log levels.
358+
2. Use satellite-installer to set all IoP log levels to DEBUG.
359+
3. Use satellite-installer to reset all IoP log levels to defaults.
360+
361+
:expectedresults:
362+
1. No IoP log levels are set to DEBUG by default.
363+
2. All IoP log levels can be set to DEBUG using satellite-installer.
364+
3. All IoP log levels can be reset to their default values using satellite-installer.
365+
366+
:Verifies: SAT-41750
367+
"""
368+
NEW_LOG_LEVEL = 'DEBUG'
369+
370+
# Retrieve the IoP log level settings from satellite-installer help output
371+
help_command = InstallerCommand('full-help').get_command()
372+
log_level_settings = module_satellite_iop.execute(
373+
f'{help_command} | grep iop.*log-level | grep -v reset'
374+
).stdout
375+
376+
# Process the log level options into a dictionary
377+
settings_dict = process_iop_log_options(log_level_settings)
378+
379+
# Verify that no IoP log levels are set to DEBUG by default
380+
assert NEW_LOG_LEVEL not in settings_dict.values()
381+
382+
# Use the installer to set all IoP log levels to DEBUG
383+
command = InstallerCommand(
384+
iop_core_engine_log_level_insights_core_dr=NEW_LOG_LEVEL,
385+
iop_core_engine_log_level_insights_kafka_service=NEW_LOG_LEVEL,
386+
iop_core_engine_log_level_insights_messaging=NEW_LOG_LEVEL,
387+
iop_core_engine_log_level_root=NEW_LOG_LEVEL,
388+
).get_command()
389+
module_satellite_iop.execute(command)
390+
391+
# Verify that log levels are now DEBUG
392+
new_log_level_settings = module_satellite_iop.execute(
393+
f'{help_command} | grep iop.*log-level | grep -v reset'
394+
).stdout
395+
new_settings_dict = process_iop_log_options(new_log_level_settings)
396+
for setting in new_settings_dict.values():
397+
assert 'DEBUG' in setting
398+
399+
# Ensure log levels are reset to defaults
400+
command = InstallerCommand(
401+
'reset-iop-core-engine-log-level-insights-core-dr',
402+
'reset-iop-core-engine-log-level-insights-kafka-service',
403+
'reset-iop-core-engine-log-level-insights-messaging',
404+
'reset-iop-core-engine-log-level-root',
405+
).get_command()
406+
module_satellite_iop.execute(command)
407+
log_level_settings = module_satellite_iop.execute(
408+
f'{help_command} | grep iop.*log-level | grep -v reset'
409+
).stdout
410+
settings_dict = process_iop_log_options(log_level_settings)
411+
assert NEW_LOG_LEVEL not in settings_dict.values()

0 commit comments

Comments
 (0)