-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for -c option check if port is change
Added an option to add open ports for spawned containers. And also added a test to check if conf file change with -c option will change the ports for agent and ctrl. Related-to: #668 Signed-off-by: Artiom Divak <adivak@redhat.com>
- Loading branch information
1 parent
cbcd280
commit 4805b3d
Showing
6 changed files
with
89 additions
and
3 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
2 changes: 2 additions & 0 deletions
2
tests/tests/tier0/bluechi-change-port-with-c-cmd-option/config-files/agent_port_8421.conf
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 @@ | ||
[bluechi-agent] | ||
ManagerPort=8421 |
2 changes: 2 additions & 0 deletions
2
tests/tests/tier0/bluechi-change-port-with-c-cmd-option/config-files/ctrl_port_8421.conf
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 @@ | ||
[bluechi-controller] | ||
ManagerPort=8421 |
2 changes: 2 additions & 0 deletions
2
tests/tests/tier0/bluechi-change-port-with-c-cmd-option/main.fmf
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 chenging port with cmd -c option | ||
id: 5645dcdf-acaa-4a04-8c0d-d478c8a6f2a3 |
68 changes: 68 additions & 0 deletions
68
...tier0/bluechi-change-port-with-c-cmd-option/test_bluechi_change_port_with_c_cmd_option.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,68 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
from typing import Dict | ||
import os | ||
import time | ||
|
||
from bluechi_test.test import BluechiTest | ||
from bluechi_test.container import BluechiControllerContainer, BluechiNodeContainer | ||
from bluechi_test.config import BluechiControllerConfig, BluechiNodeConfig | ||
from bluechi_test.util import read_file | ||
|
||
NODE_FOO = "node-foo" | ||
|
||
|
||
def check_if_node_and_ctrl_connected(ctrl, node): | ||
assert os.popen("lsof -i:8421").read() | ||
assert "Registered managed node from" in ctrl.exec_run("systemctl status bluechi-controller.service")[1] | ||
assert f"Connected to manager as '{NODE_FOO}'" in node.exec_run("systemctl status bluechi-agent.service")[1] | ||
|
||
|
||
def check_if_node_disconnected(node): | ||
time.sleep(1) | ||
assert not os.popen("lsof -i:8420 | grep slirp4net").read() | ||
assert "Disconnected from manager" in node.exec_run("systemctl status bluechi-agent.service")[1] | ||
|
||
|
||
|
||
def exec(ctrl: BluechiControllerContainer, nodes: Dict[str, BluechiNodeContainer]): | ||
node_foo = nodes[NODE_FOO] | ||
config_file_location = "/var/tmp" | ||
bluechi_agent_str = "bluechi-agent" | ||
bluechi_controller_str = "bluechi-controller" | ||
file_location_ctrl = os.path.join("config-files", "ctrl_port_8421.conf") | ||
file_location_agent = os.path.join("config-files", "agent_port_8421.conf") | ||
|
||
# Copying relevant config files into the nodes container | ||
content = read_file(file_location_agent) | ||
node_foo.create_file(config_file_location, file_location_agent, content) | ||
content = read_file(file_location_ctrl) | ||
ctrl.create_file(config_file_location, file_location_ctrl, content) | ||
|
||
ctrl.restart_with_config_file( | ||
os.path.join(config_file_location, "ctrl_port_8421.conf"), bluechi_controller_str) | ||
assert ctrl.wait_for_unit_state_to_be(bluechi_controller_str, "active") | ||
check_if_node_disconnected(node_foo) | ||
|
||
|
||
node_foo.restart_with_config_file( | ||
os.path.join(config_file_location, "agent_port_8421.conf"), bluechi_agent_str) | ||
assert node_foo.wait_for_unit_state_to_be(bluechi_agent_str, "active") | ||
check_if_node_and_ctrl_connected(ctrl, node_foo) | ||
|
||
|
||
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 | ||
|
||
bluechi_ctrl_default_config.allowed_node_names = [NODE_FOO] | ||
bluechi_test.set_bluechi_controller_config(bluechi_ctrl_default_config) | ||
|
||
bluechi_test.add_bluechi_node_config(node_foo_cfg) | ||
|
||
bluechi_test.additional_ports = {"8421": "8421"} | ||
|
||
bluechi_test.run(exec) |