Skip to content
Open
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
9 changes: 6 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
TCP_TIMEOUT_30SEC,
TIMEOUT_1MIN,
TIMEOUT_1SEC,
TIMEOUT_2MIN,
TIMEOUT_3MIN,
TIMEOUT_5SEC,
TIMEOUT_10MIN,
Expand Down Expand Up @@ -233,17 +234,19 @@ def get_os_cpu_count(vm):
cmd = shlex.split("echo %NUMBER_OF_PROCESSORS%")
else:
cmd = shlex.split("nproc --all")
return int(run_ssh_commands(host=vm.ssh_exec, commands=cmd)[0].strip())
return int(run_ssh_commands(host=vm.ssh_exec, commands=cmd, wait_timeout=TIMEOUT_2MIN)[0].strip())


def get_os_memory_value(vm):
if "windows" in vm.name:
cmd = shlex.split("wmic ComputerSystem get TotalPhysicalMemory")
wmic_total_mem = run_ssh_commands(host=vm.ssh_exec, commands=cmd)[0].strip().split()[1]
wmic_total_mem = (
run_ssh_commands(host=vm.ssh_exec, commands=cmd, wait_timeout=TIMEOUT_2MIN)[0].strip().split()[1]
)
return f"{round(float(bitmath.Bit(int(wmic_total_mem)).to_Gib()))}Gi"
else:
cmd = shlex.split("awk \"'{print$2/1024/1024;exit}'\" /proc/meminfo")
meminfo = run_ssh_commands(host=vm.ssh_exec, commands=cmd)[0].strip()
meminfo = run_ssh_commands(host=vm.ssh_exec, commands=cmd, wait_timeout=TIMEOUT_2MIN)[0].strip()
return f"{round(float(meminfo))}Gi"


Expand Down
1 change: 1 addition & 0 deletions tests/virt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def get_stress_ng_pid(ssh_exec, windows=False):
host=ssh_exec,
commands=shlex.split(f"{command_prefix} bash -c 'pgrep {stress}'"),
tcp_timeout=TCP_TIMEOUT_30SEC,
wait_timeout=TIMEOUT_2MIN,
)[0].split("\n")[0]


Expand Down
4 changes: 3 additions & 1 deletion utilities/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,7 @@ def fetch_pid_from_linux_vm(vm, process_name):
cmd_res = run_ssh_commands(
host=vm.ssh_exec,
commands=shlex.split(f"pgrep {process_name} -x || true"),
wait_timeout=TIMEOUT_2MIN,
)[0].strip()
assert cmd_res, f"VM {vm.name}, '{process_name}' process not found"
return int(cmd_res)
Expand All @@ -2384,6 +2385,7 @@ def fetch_pid_from_windows_vm(vm, process_name):
host=vm.ssh_exec,
commands=shlex.split(f"powershell -Command (Get-Process -Name {process_name.removesuffix('.exe')}).Id"),
tcp_timeout=TCP_TIMEOUT_30SEC,
wait_timeout=TIMEOUT_2MIN,
)[0].strip()
assert cmd_res, f"Process '{process_name}' not in output: {cmd_res}"
return int(cmd_res)
Expand Down Expand Up @@ -2620,7 +2622,7 @@ def validate_virtctl_guest_agent_data_over_time(vm: VirtualMachineForTests) -> b

def get_vm_boot_time(vm: VirtualMachineForTests) -> str:
boot_command = 'net statistics workstation | findstr "Statistics since"' if "windows" in vm.name else "who -b"
return run_ssh_commands(host=vm.ssh_exec, commands=shlex.split(boot_command))[0]
return run_ssh_commands(host=vm.ssh_exec, commands=shlex.split(boot_command), wait_timeout=TIMEOUT_2MIN)[0]


def username_password_from_cloud_init(vm_volumes: list[dict[str, Any]]) -> tuple[str, str]:
Expand Down