Skip to content

Commit 58a668a

Browse files
committed
[Storage] Use ssh connection retries
1 parent 9ec6aeb commit 58a668a

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

tests/storage/snapshots/utils.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,3 @@ def fail_to_create_snapshot_no_permissions(snapshot_name, namespace, vm_name, cl
4747
def start_windows_vm_after_restore(vm_restore, windows_vm):
4848
vm_restore.wait_restore_done(timeout=TIMEOUT_10MIN)
4949
running_vm(vm=windows_vm)
50-
51-
52-
def run_command_on_vm_and_check_output(vm, command, expected_result):
53-
"""Run command on RHEL VM via SSH and verify expected result is in output.
54-
55-
Args:
56-
vm (VirtualMachineForTests): VM to run command on.
57-
command (str): Command to run.
58-
expected_result (str): Expected result to check.
59-
60-
Raises:
61-
AssertionError: If expected result is not in output.
62-
"""
63-
cmd_output = run_ssh_commands(
64-
host=vm.ssh_exec,
65-
commands=shlex.split(f"bash -c {shlex.quote(command)}"),
66-
)[0].strip()
67-
expected_result = expected_result.strip()
68-
assert expected_result in cmd_output, f"Expected '{expected_result}' in output '{cmd_output}'"

utilities/storage.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,26 @@ def write_file_via_ssh(vm: virt_util.VirtualMachineForTests, filename: str, cont
646646
run_ssh_commands(host=vm.ssh_exec, commands=cmd)
647647

648648

649+
650+
def run_command_on_vm_and_check_output(vm, command, expected_result):
651+
"""Run command on RHEL VM via SSH and verify expected result is in output.
652+
653+
Args:
654+
vm (VirtualMachineForTests): VM to run command on.
655+
command (str): Command to run.
656+
expected_result (str): Expected result to check.
657+
658+
Raises:
659+
AssertionError: If expected result is not in output.
660+
"""
661+
cmd_output = run_ssh_commands(
662+
host=vm.ssh_exec,
663+
commands=shlex.split(f"bash -c {shlex.quote(command)}"),
664+
)[0].strip()
665+
expected_result = expected_result.strip()
666+
assert expected_result in cmd_output, f"Expected '{expected_result}' in output '{cmd_output}'"
667+
668+
649669
def run_command_on_cirros_vm_and_check_output(vm, command, expected_result):
650670
with console.Console(vm=vm) as vm_console:
651671
vm_console.sendline(command)

0 commit comments

Comments
 (0)