Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions tests/foreman/cli/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pytest

from robottelo.config import settings
from robottelo.constants import FOREMANCTL_PARAMETERS_FILE
from robottelo.logging import logger

pytestmark = pytest.mark.e2e
Expand Down Expand Up @@ -246,3 +247,81 @@ def test_positive_logging_from_pulp3(module_org, target_sat):
# verify pulp correlation id in message
message_log = target_sat.execute(f'cat {test_logfile} | grep {pulp_correlation_id}')
assert message_log.status == 0


@pytest.mark.foremanctl
def test_positive_foremanctl_log_level(module_target_sat):
"""Verify foremanctl deploy log level parameters for Foreman and Proxy services.

:id: 3170785b-5327-43f6-a2b5-8e3f4049da45

:steps:
1. Deploy with --foreman-log-level=debug --foreman-proxy-log-level=debug --log-level=debug
2. Verify all three parameters are persisted in parameters file
3. Trigger Foreman activity and verify DEBUG [D] output in foreman journal
4. Trigger Proxy activity and verify DEBUG [D] output in foreman-proxy journal
5. Reset all log level parameters in a single deploy
6. Verify all log level parameters are removed from parameters file

:expectedresults:
1. All log level parameters are persisted correctly
2. Both services emit DEBUG-level [D] log entries
3. All parameters are removed after reset
"""
sat = module_target_sat

result = sat.execute(
'foremanctl deploy'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fails, as module_target_sat has no foremanctl 😕

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubhamsg199 is working on fixing it in the workflows

' --add-feature hammer'
' --foreman-log-level=debug'
' --foreman-proxy-log-level=debug'
' --log-level=debug',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since --log-level=debug sets foreman and proxy both log levels as debug. would it be better to provide diffrent values for --foreman-log-level and --foreman-proxy-log-level to a different value than debug? that way we also test that --foreman-log-level = something overides --log-level for foreman?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since --log-level is for updating loglevels on all services, we can omit that from here and have a separate test for that where we just update it then check if foreman/-proxy/etc loglevels are updated, wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can, but what i had in my mind was:-

  • deploy with --log-level X and see log levels are configured as X for all services(currently all means foreman and proxy only)
  • then redeploy with --foreman-log-level Y and --foreman-proxy-log-level Z and see if they overide the configuration set by --log-level for these services.

timeout='30m',
)
assert result.status == 0, (
f'foremanctl deploy with log level parameters failed:\n{result.stderr}'
)

# Verify all parameters are persisted
params = sat.load_remote_yaml_file(FOREMANCTL_PARAMETERS_FILE)
assert params.foreman_log_level == 'debug', (
f'foreman_log_level not persisted correctly: {params.get("foreman_log_level")}'
)
assert params.foreman_proxy_log_level == 'debug', (
f'foreman_proxy_log_level not persisted correctly: {params.get("foreman_proxy_log_level")}'
)
assert params.log_level == 'debug', (
f'log_level not persisted correctly: {params.get("log_level")}'
)

# Trigger activity and verify DEBUG [D|...] output in foreman journal
sat.execute('hammer host list')
result = sat.execute(r'journalctl --no-pager -u foreman.service --since "-2 min" | grep "\[D|"')
assert result.status == 0, 'No DEBUG-level [D|...] messages found in foreman.service journal'

# Trigger activity and verify DEBUG [D] output in foreman-proxy journal
sat.execute('hammer proxy refresh-features --id 1')
result = sat.execute(
r'journalctl --no-pager -u foreman-proxy.service --since "-2 min" | grep "\[D\]"'
)
assert result.status == 0, 'No DEBUG-level [D] messages found in foreman-proxy.service journal'

# Reset all log level parameters in a single deploy
result = sat.execute(
'foremanctl deploy'
' --reset-foreman-log-level'
' --reset-foreman-proxy-log-level'
' --reset-log-level',
timeout='30m',
)
assert result.status == 0, f'Reset log level parameters failed:\n{result.stderr}'

# Verify all parameters are removed
params = sat.load_remote_yaml_file(FOREMANCTL_PARAMETERS_FILE)
assert 'foreman_log_level' not in params, (
'foreman_log_level still present in parameters after reset'
)
assert 'foreman_proxy_log_level' not in params, (
'foreman_proxy_log_level still present in parameters after reset'
)
assert 'log_level' not in params, 'log_level still present in parameters after reset'
Loading