Skip to content

Commit

Permalink
Add bluechi_is_online module and integration test
Browse files Browse the repository at this point in the history
- Adds bluechi_is_online module to provide bluechi-is-online node methods to Python code.
- Adds a test to verify  invocation without additional parameters.

Signed-off-by: nsimsolo <[email protected]>
  • Loading branch information
nsimsolo committed Dec 4, 2024
1 parent fcaadfd commit a91d307
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/bluechi.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/bluechi_test/bluechi_is_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ def agent_is_online(self) -> bool:
0,
)
return result == 0

def node_is_online(self, node_name: str) -> bool:
result, output = self.run(
"Checking controller status.",
f"node {node_name}",
False,
0,
)
return result == 0
2 changes: 2 additions & 0 deletions tests/tests/tier0/bluechi-is-online-node/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
summary: on the controller machine test the connection of the given node to the controller
id: fa5a2ff8-fbea-4a0c-8106-a8cb2c295581
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Copyright Contributors to the Eclipse BlueChi project
#
# SPDX-License-Identifier: LGPL-2.1-or-later
from typing import Dict

from bluechi_test.config import BluechiAgentConfig, BluechiControllerConfig
from bluechi_test.machine import BluechiAgentMachine, BluechiControllerMachine
from bluechi_test.test import BluechiTest

NODE_FOO = "node-foo"


def check_execs(ctrl: BluechiControllerMachine, node: BluechiAgentMachine):
# Check that the BlueChi controller is online at the startup
result = ctrl.bluechi_is_online.node_is_online(node_name=NODE_FOO)
assert result, f"bluechi-agent for node {node.name} should be online"

# Stop the BlueChi controller
node.systemctl.stop_unit("bluechi-agent")
assert node.wait_for_unit_state_to_be("bluechi-agent", "inactive")

# Check that the BlueChi controller is offline
result = ctrl.bluechi_is_online.node_is_online(node_name=NODE_FOO)
assert not result, f"bluechi-agent for node {node.name} should be offline"


def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]):
node_foo = nodes.get(NODE_FOO)
check_execs(ctrl=ctrl, node=node_foo)


def test_bluechi_is_online_controller(
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_ctrl_default_config.allowed_node_names = [NODE_FOO]

bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config)
bluechi_test.add_bluechi_agent_config(node_foo_cfg)

bluechi_test.run(exec)

0 comments on commit a91d307

Please sign in to comment.