Skip to content

Commit

Permalink
Merge pull request #240 from xcp-ng/system_tests
Browse files Browse the repository at this point in the history
Add tests for systemd units
  • Loading branch information
stormi authored Aug 14, 2024
2 parents 077d9d2 + 9d2cf44 commit 0e6c43d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"tests/migration",
"tests/network",
"tests/snapshot",
"tests/system",
"tests/xapi",
"tests/xapi-plugins",
],
Expand Down
31 changes: 31 additions & 0 deletions tests/system/test_systemd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import logging
import pytest
import re

# Requirements:
# - an XCP-ng host (--hosts) >= 8.2

pytest.fixture(scope='module')
def test_failed_units(host):
failed_services = host.ssh(['systemctl', '--state=failed', '--full', '--all',
'--no-pager', '--no-legend'])
for unit in failed_services.splitlines():
logging.error(f"Unit {unit.split()[0]} failed")

assert not failed_services

white_list_issues = [
"Cannot add dependency job for unit [email protected], ignoring: Unit is masked.",
"Cannot add dependency job for unit display-manager.service, ignoring: Unit not found.",
]

pytest.fixture(scope='module')
def test_verify_default_target(host):
analyse = host.ssh(['systemd-analyze', 'verify', 'default.target'])
err = False
for line in analyse.splitlines():
if line not in white_list_issues:
logging.error(f"{line}")
err = True

assert not err

0 comments on commit 0e6c43d

Please sign in to comment.