Skip to content

Commit

Permalink
refactor(test): Use check_output in check_guest_connections
Browse files Browse the repository at this point in the history
Now that the assertion on the `run` return code is paired with the .run
call itself, combine them into .check_output.

Also use check_output further up.

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat committed Dec 13, 2024
1 parent fc23b71 commit 130af91
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/framework/utils_vsock.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def check_guest_connections(vm, server_port_path, blob_path, blob_hash):
# Avoids: "bash: fork: retry: Resource temporarily unavailable"
# Needed to execute the bash script that tests for concurrent
# vsock guest initiated connections.
pids_max_file = "/sys/fs/cgroup/system.slice/ssh.service/pids.max"
ecode, _, _ = vm.ssh.run(f"echo 1024 > {pids_max_file}")
assert ecode == 0, "Unable to set max process count for guest ssh service."
vm.ssh.check_output(
"echo 1024 > /sys/fs/cgroup/system.slice/ssh.service/pids.max"
)

# Build the guest worker sub-command.
# `vsock_helper` will read the blob file from STDIN and send the echo
Expand All @@ -183,9 +183,7 @@ def check_guest_connections(vm, server_port_path, blob_path, blob_hash):
cmd += "done;"
cmd += "for w in $workers; do wait $w || (wait; exit 1); done"

ecode, _, stderr = vm.ssh.run(cmd)

assert ecode == 0, stderr
vm.ssh.check_output(cmd)
finally:
echo_server.terminate()
rc = echo_server.wait()
Expand Down

0 comments on commit 130af91

Please sign in to comment.