Skip to content

Commit

Permalink
tests(minimal): rsyslog not in minimal images expect warning (canonic…
Browse files Browse the repository at this point in the history
…al#5811)

Adapt test_no_problems to use verify_clean_boot instead of
verify_clean_log.

Fix verify_clean_boot to retain platform-specific ignored tracebacks
before passing it into _verify_clean_boot.
  • Loading branch information
blackboxsw committed Oct 11, 2024
1 parent a62656c commit fbcfaf2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
40 changes: 24 additions & 16 deletions tests/integration_tests/modules/test_combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
get_inactive_modules,
lxd_has_nocloud,
verify_clean_boot,
verify_clean_log,
verify_ordered_items_in_text,
)

Expand Down Expand Up @@ -150,17 +149,16 @@ def test_deprecated_message(self, class_client: IntegrationInstance):
# user-data. Pass 22.2 in against the client's version_boundary.
if lifecycle.should_log_deprecation("22.2", version_boundary):
deprecated_messages.append(boundary_message)
verify_clean_boot(
class_client, require_deprecations=deprecated_messages
)
else:
# Expect the distros deprecated call to be redacted.
# jsonschema still emits deprecation log due to changed_version
# instead of deprecated_version
verify_clean_boot(
class_client, require_deprecations=deprecated_messages
)
assert f"[INFO]: {boundary_message}" in log
verify_clean_boot(
class_client,
require_deprecations=deprecated_messages,
ignore_warnings=True,
)

def test_ntp_with_apt(self, class_client: IntegrationInstance):
"""LP #1628337.
Expand Down Expand Up @@ -212,11 +210,11 @@ def test_random_seed_data(self, class_client: IntegrationInstance):
assert result.startswith("MYUb34023nD:LFDK10913jk;dfnk:Df")

def test_rsyslog(self, class_client: IntegrationInstance):
"""Test rsyslog is configured correctly."""
client = class_client
assert "My test log" in client.read_from_file(
"/var/spool/rsyslog/cloudinit.log"
)
"""Test rsyslog is configured correctly when applicable."""
if class_client.execute("command -v rsyslogd").ok:
assert "My test log" in class_client.read_from_file(
"/var/spool/rsyslog/cloudinit.log"
)

def test_runcmd(self, class_client: IntegrationInstance):
"""Test runcmd works as expected"""
Expand Down Expand Up @@ -247,9 +245,7 @@ def test_timezone(self, class_client: IntegrationInstance):
assert timezone_output.strip() == "CET"

def test_no_problems(self, class_client: IntegrationInstance):
"""Test no errors, warnings, deprecations, tracebacks or
inactive modules.
"""
"""Test no errors, warnings, tracebacks or inactive modules."""
client = class_client
status_file = client.read_from_file("/run/cloud-init/status.json")
status_json = json.loads(status_file)["v1"]
Expand All @@ -260,7 +256,19 @@ def test_no_problems(self, class_client: IntegrationInstance):
assert result_json["errors"] == []

log = client.read_from_file("/var/log/cloud-init.log")
verify_clean_log(log, ignore_deprecations=False)
require_warnings = []
if class_client.execute("command -v rsyslogd").failed:
# Some minimal images may not have an installed rsyslog package
# Test user-data doesn't provide install_rsyslog: true so expect
# warnings when not installed.
require_warnings.append(
"Failed to reload-or-try-restart rsyslog.service:"
" Unit rsyslog.service not found."
)
# Set ignore_deprecations=True as test_deprecated_message covers this
verify_clean_boot(
client, ignore_deprecations=True, require_warnings=require_warnings
)
requested_modules = {
"apt_configure",
"byobu",
Expand Down
6 changes: 5 additions & 1 deletion tests/integration_tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def append_or_create_list(
ignore_warnings,
"Unable to disable SSH logins for opc given ssh_redirect_user",
)

# Preserve platform-specific tracebacks expected
if isinstance(ignore_tracebacks, list):
ignore_tracebacks.extend(traceback_texts)
elif ignore_tracebacks is None:
ignore_tracebacks = traceback_texts
_verify_clean_boot(
instance,
ignore_deprecations=ignore_deprecations,
Expand Down

0 comments on commit fbcfaf2

Please sign in to comment.