-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR will add bluechi the ability to reset failed all units or reset one failed unit. Solves: #932 Signed-off-by: Artiom Divak <[email protected]>
- Loading branch information
1 parent
a890cbb
commit 9f7478d
Showing
14 changed files
with
287 additions
and
18 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
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
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
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
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
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,3 @@ | ||
summary: Test bluechictl daemon-reload. This test will send an unrunble test will | ||
fail at start but then will be change and update with daemon-reload | ||
id: 6c67e96d-db4b-4a54-980c-287e33450abf |
62 changes: 62 additions & 0 deletions
62
tests/tests/tier0/bluechi-reset-failed-unit/test_bluechi_reset_failed_unit.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,62 @@ | ||
# | ||
# Copyright Contributors to the Eclipse BlueChi project | ||
# | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import logging | ||
from typing import Dict | ||
|
||
from bluechi_test.config import BluechiAgentConfig, BluechiControllerConfig | ||
from bluechi_test.machine import BluechiAgentMachine, BluechiControllerMachine | ||
from bluechi_test.service import Option, Section, SimpleRemainingService | ||
from bluechi_test.test import BluechiTest | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
NODE_FOO = "node-foo" | ||
|
||
|
||
def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]): | ||
|
||
node_foo = nodes[NODE_FOO] | ||
|
||
# Create a service which won't start due to nonexistent executable | ||
failed_service_1 = SimpleRemainingService(name="simple1.service") | ||
failed_service_1.set_option(Section.Service, Option.ExecStart, "/s") | ||
failed_service_2 = SimpleRemainingService(name="simple2.service") | ||
failed_service_2.set_option(Section.Service, Option.ExecStart, "/s") | ||
failed_service_3 = SimpleRemainingService(name="simple3.service") | ||
failed_service_3.set_option(Section.Service, Option.ExecStart, "/bin/sleep 60") | ||
|
||
node_foo.install_systemd_service(failed_service_1) | ||
node_foo.install_systemd_service(failed_service_2) | ||
node_foo.install_systemd_service(failed_service_3) | ||
|
||
ctrl.bluechictl.start_unit(NODE_FOO, failed_service_1.name) | ||
ctrl.bluechictl.start_unit(NODE_FOO, failed_service_2.name) | ||
ctrl.bluechictl.start_unit(NODE_FOO, failed_service_3.name) | ||
|
||
assert node_foo.wait_for_unit_state_to_be(failed_service_1.name, "failed") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_2.name, "failed") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_3.name, "active") | ||
|
||
ctrl.bluechictl.reset_failed_unit(NODE_FOO, failed_service_1.name) | ||
|
||
assert node_foo.wait_for_unit_state_to_be(failed_service_1.name, "inactive") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_2.name, "failed") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_3.name, "active") | ||
|
||
|
||
def test_bluechi_reset_failed( | ||
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) |
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,3 @@ | ||
summary: Test bluechictl daemon-reload. This test will send an unrunble test will | ||
fail at start but then will be change and update with daemon-reload | ||
id: fc5db6a7-1367-450b-b674-35b9541d4f3e |
62 changes: 62 additions & 0 deletions
62
tests/tests/tier0/bluechi-reset-failed/test_bluechi_reset_failed.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,62 @@ | ||
# | ||
# Copyright Contributors to the Eclipse BlueChi project | ||
# | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import logging | ||
from typing import Dict | ||
|
||
from bluechi_test.config import BluechiAgentConfig, BluechiControllerConfig | ||
from bluechi_test.machine import BluechiAgentMachine, BluechiControllerMachine | ||
from bluechi_test.service import Option, Section, SimpleRemainingService | ||
from bluechi_test.test import BluechiTest | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
NODE_FOO = "node-foo" | ||
|
||
|
||
def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]): | ||
|
||
node_foo = nodes[NODE_FOO] | ||
|
||
# Create a service which won't start due to nonexistent executable | ||
failed_service_1 = SimpleRemainingService(name="simple1.service") | ||
failed_service_1.set_option(Section.Service, Option.ExecStart, "/s") | ||
failed_service_2 = SimpleRemainingService(name="simple2.service") | ||
failed_service_2.set_option(Section.Service, Option.ExecStart, "/s") | ||
failed_service_3 = SimpleRemainingService(name="simple3.service") | ||
failed_service_3.set_option(Section.Service, Option.ExecStart, "/bin/sleep 60") | ||
|
||
node_foo.install_systemd_service(failed_service_1) | ||
node_foo.install_systemd_service(failed_service_2) | ||
node_foo.install_systemd_service(failed_service_3) | ||
|
||
ctrl.bluechictl.start_unit(NODE_FOO, failed_service_1.name) | ||
ctrl.bluechictl.start_unit(NODE_FOO, failed_service_2.name) | ||
ctrl.bluechictl.start_unit(NODE_FOO, failed_service_3.name) | ||
|
||
assert node_foo.wait_for_unit_state_to_be(failed_service_1.name, "failed") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_2.name, "failed") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_3.name, "active") | ||
|
||
ctrl.bluechictl.reset_failed(NODE_FOO) | ||
|
||
assert node_foo.wait_for_unit_state_to_be(failed_service_1.name, "inactive") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_2.name, "inactive") | ||
assert node_foo.wait_for_unit_state_to_be(failed_service_3.name, "active") | ||
|
||
|
||
def test_bluechi_reset_failed( | ||
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) |