Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize bluechictl-is-enabled test #975

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def check_execs(
def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]):
node_foo = nodes[node_foo_name]

# Traversing over existing unit files is the easiest way to cover all existing enablement statuses
# Traversing over existing unit files is the easiest way to cover all existing enablement statuses, to improve
# performance each status is checked only once
checked_statuses = set()
all_res, all_out = ctrl.bluechictl.list_unit_files(node_name=node_foo_name)
assert all_res == 0
all_unit_files = parse_bluechictl_list_output(
Expand All @@ -45,7 +47,9 @@ def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]):
item_class=SystemdUnitFile,
)
for unit in all_unit_files[node_foo_name].values():
check_execs(ctrl=ctrl, node=node_foo, unit_name=unit.key)
if unit.state not in checked_statuses:
checked_statuses.add(unit.state)
check_execs(ctrl=ctrl, node=node_foo, unit_name=unit.key)

# Error message from bluechictl is not completely the same as from systemctl for non-existent service
check_execs(
Expand Down