-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from xcp-ng/system_tests
Add tests for systemd units
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |