Skip to content

Commit

Permalink
integration tests: invalid bluechi agent port
Browse files Browse the repository at this point in the history
This test includes three nodes: bluechi-controller, node-foo, node-bar.

- bluechi-controller is the controller node

- node-foo will start the agent service with normal
  configuration using port 8420

- node-bar will try to start the agent service with
  incorrect port (842O) and should fail (as expected)

Signed-off-by: Douglas Schilling Landgraf <[email protected]>
  • Loading branch information
dougsland committed Aug 19, 2023
1 parent 86462a0 commit 37ab795
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
summary: Test if bluechi agent can handle invalid port in the configuration file
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SPDX-License-Identifier: GPL-2.0-or-later

import pytest
from typing import Dict

from bluechi_test.test import BluechiTest
from bluechi_test.container import BluechiControllerContainer, BluechiNodeContainer
from bluechi_test.config import BluechiControllerConfig, BluechiNodeConfig

NODE_FOO = "node-foo"
NODE_BAR = "node-bar"


def start_with_invalid_port(ctrl: BluechiControllerContainer, nodes: Dict[str, BluechiNodeContainer]):
result, _ = nodes[NODE_FOO].exec_run('systemctl restart bluechi-agent')
assert result == 0

result, _ = nodes[NODE_BAR].exec_run('systemctl restart bluechi-agent')
assert result == 1


@pytest.mark.timeout(60)
def test_agent_invalid_port_configuration(
bluechi_test: BluechiTest,
bluechi_node_default_config: BluechiNodeConfig, bluechi_ctrl_default_config: BluechiControllerConfig):

node_foo_cfg = bluechi_node_default_config.deep_copy()
node_foo_cfg.node_name = NODE_FOO
node_foo_cfg.manager_port = "8420"

node_bar_cfg = bluechi_node_default_config.deep_copy()
node_bar_cfg.node_name = NODE_BAR
node_bar_cfg.manager_port = "842O"

bluechi_ctrl_default_config.allowed_node_names = [NODE_FOO, NODE_BAR]
bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config)

bluechi_test.add_bluechi_node_config(node_foo_cfg)
bluechi_test.add_bluechi_node_config(node_bar_cfg)

bluechi_test.run(start_with_invalid_port)

0 comments on commit 37ab795

Please sign in to comment.