-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added integration test for enabling a unit
Signed-off-by: Michael Engel <mengel@redhat.com>
- Loading branch information
Showing
4 changed files
with
72 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,6 @@ | ||
summary: Test if a disabled systemd service can be enabled using hirtectl | ||
|
||
tier: 0 | ||
|
||
test: | | ||
pytest -svv |
10 changes: 10 additions & 0 deletions
10
tests/tests/tier0/hirte-enable-service/systemd/simple.service
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,10 @@ | ||
[Unit] | ||
Description=I am truth | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/bin/true | ||
RemainAfterExit=yes | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
49 changes: 49 additions & 0 deletions
49
tests/tests/tier0/hirte-enable-service/test_hirte_enable_service.py
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,49 @@ | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
import os | ||
import pytest | ||
from typing import Dict | ||
|
||
from hirte_test.config import HirteControllerConfig, HirteNodeConfig | ||
from hirte_test.container import HirteControllerContainer, HirteNodeContainer | ||
from hirte_test.test import HirteTest | ||
|
||
|
||
node_foo_name = "node-foo" | ||
simple_service = "simple.service" | ||
|
||
|
||
def exec(ctrl: HirteControllerContainer, nodes: Dict[str, HirteNodeContainer]): | ||
foo = nodes[node_foo_name] | ||
|
||
source_dir = "systemd" | ||
target_dir = os.path.join("/", "etc", "systemd", "system") | ||
|
||
foo.copy_systemd_service(simple_service, source_dir, target_dir) | ||
|
||
_, output = foo.exec_run(f"systemctl is-enabled {simple_service}") | ||
if output != "disabled": | ||
raise Exception(f"Failed pre-check if unit {simple_service} is enabled: {output}") | ||
|
||
ctrl.enable_unit(node_foo_name, simple_service) | ||
|
||
_, output = foo.exec_run(f"systemctl is-enabled {simple_service}") | ||
if output != "enabled": | ||
raise Exception(f"Unit {simple_service} expected to be enabled, but got: {output}") | ||
|
||
|
||
@pytest.mark.timeout(10) | ||
def test_proxy_service_start( | ||
hirte_test: HirteTest, | ||
hirte_ctrl_default_config: HirteControllerConfig, | ||
hirte_node_default_config: HirteNodeConfig): | ||
|
||
node_foo_cfg = hirte_node_default_config.deep_copy() | ||
node_foo_cfg.node_name = node_foo_name | ||
|
||
hirte_ctrl_default_config.allowed_node_names = [node_foo_name] | ||
|
||
hirte_test.set_hirte_controller_config(hirte_ctrl_default_config) | ||
hirte_test.add_hirte_node_config(node_foo_cfg) | ||
|
||
hirte_test.run(exec) |