-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reload Integration Test This test will test the functionality of ReloadUnit. Two services will be added to the node container. One of them will be activated by bluechictl and then reloaded with bluechi reload and that suppose to make the other service active. Signed-off-by: Artiom Divak <adivak@redhat.com>
- Loading branch information
1 parent
3d6ec94
commit 5b0cddf
Showing
5 changed files
with
69 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,2 @@ | ||
summary: Test reload service | ||
id: 44b0d11e-fcad-4523-acf7-ff0c0421501e |
7 changes: 7 additions & 0 deletions
7
tests/tests/tier0/bluechi-reload-unit/systemd/service-for-reload.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,7 @@ | ||
[Unit] | ||
Description=A very simple service | ||
[Service] | ||
Type=simple | ||
ExecStart=/bin/true | ||
RemainAfterExit=yes | ||
ExecReload=systemctl start 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,7 @@ | ||
[Unit] | ||
Description=Service For Integration Test | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/bin/true | ||
RemainAfterExit=yes |
44 changes: 44 additions & 0 deletions
44
tests/tests/tier0/bluechi-reload-unit/test_bluechi_reload_unit_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,44 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
import logging | ||
import os | ||
|
||
from typing import Dict | ||
from bluechi_test.test import BluechiTest | ||
from bluechi_test.machine import BluechiControllerMachine, BluechiAgentMachine | ||
from bluechi_test.config import BluechiControllerConfig, BluechiAgentConfig | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
NODE_FOO = "node-foo" | ||
|
||
|
||
def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]): | ||
|
||
foo = nodes[NODE_FOO] | ||
target_dir = os.path.join("/", "etc", "systemd", "system") | ||
foo.copy_systemd_service("service-for-reload.service", "systemd", target_dir) | ||
foo.copy_systemd_service("simple.service", "systemd", target_dir) | ||
assert foo.wait_for_unit_state_to_be("simple.service", "inactive") | ||
assert foo.wait_for_unit_state_to_be("service-for-reload.service", "inactive") | ||
|
||
ctrl.bluechictl.start_unit(NODE_FOO, "service-for-reload.service") | ||
assert foo.wait_for_unit_state_to_be("simple.service", "inactive") | ||
assert foo.wait_for_unit_state_to_be("service-for-reload.service", "active") | ||
|
||
ctrl.bluechictl.reload_unit(NODE_FOO, "service-for-reload.service") | ||
assert foo.wait_for_unit_state_to_be("simple.service", "active") | ||
assert foo.wait_for_unit_state_to_be("service-for-reload.service", "active") | ||
|
||
|
||
def test_bluechi_reload_unit_service( | ||
bluechi_test: BluechiTest, | ||
bluechi_node_default_config: BluechiAgentConfig, bluechi_ctrl_default_config: BluechiControllerConfig): | ||
node_foo_cfg = bluechi_node_default_config.deep_copy() | ||
node_foo_cfg.node_name = NODE_FOO | ||
|
||
bluechi_test.add_bluechi_agent_config(node_foo_cfg) | ||
|
||
bluechi_ctrl_default_config.allowed_node_names = [NODE_FOO] | ||
bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config) | ||
|
||
bluechi_test.run(exec) |