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

Remove timeouts for bash exec commands from tests #974

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
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 @@ -6,7 +6,7 @@
import time
import unittest

from bluechi_machine_lib.util import Timeout, run_command
from bluechi_machine_lib.util import run_command

service = "org.eclipse.bluechi.Agent"
object = "/org/eclipse/bluechi"
Expand All @@ -19,14 +19,13 @@ def test_agent_start_as_user(self):
result, _, _ = run_command("systemctl --user start bluechi-agent")
assert result == 0

with Timeout(5, "Timeout waiting for agent to connect to user bus"):
while True:
result, output, _ = run_command(
f"busctl --user get-property {service} {object} {interface} Status"
)
if output == 's "offline"':
break
time.sleep(0.5)
while True:
result, output, _ = run_command(
f"busctl --user get-property {service} {object} {interface} Status"
)
if output == 's "offline"':
break
time.sleep(0.5)

result, _, _ = run_command("systemctl --user stop bluechi-agent")
assert result == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from bluechi_test.service import Option, Section
from bluechi_test.test import BluechiTest
from bluechi_test.util import Timeout, read_file
from bluechi_test.util import read_file

NODE_FOO = "node-foo"

Expand All @@ -29,15 +29,11 @@ def cmd_on_port(
expected_result: int = 0,
expected_command: str = None,
) -> None:
with Timeout(
seconds=5,
error_message=f"Timeout waiting for '{expected_command}' to listen on port '{port}'",
):
while True:
res, output = machine.exec_run(f"bash /var/cmd-on-port.sh {port}")
if res == expected_result and expected_command in str(output):
break
time.sleep(0.2)
while True:
res, output = machine.exec_run(f"bash /var/cmd-on-port.sh {port}")
if res == expected_result and expected_command in str(output):
break
time.sleep(0.2)


def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
)
from bluechi_test.service import Option, Section
from bluechi_test.test import BluechiTest
from bluechi_test.util import Timeout

NODE_FOO = "node-foo"

Expand All @@ -28,15 +27,11 @@ def cmd_on_port(
expected_result: int = 0,
expected_command: str = None,
) -> None:
with Timeout(
seconds=5,
error_message=f"Timeout waiting for '{expected_command}' to listen on port '{port}'",
):
while True:
res, output = machine.exec_run(f"bash /var/cmd-on-port.sh {port}")
if res == expected_result and expected_command in str(output):
break
time.sleep(0.2)
while True:
res, output = machine.exec_run(f"bash /var/cmd-on-port.sh {port}")
if res == expected_result and expected_command in str(output):
break
time.sleep(0.2)


def exec(ctrl: BluechiControllerMachine, nodes: Dict[str, BluechiAgentMachine]):
Expand Down