Skip to content

Commit

Permalink
add wait time for results if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dcmcand committed Nov 14, 2024
1 parent 65f580a commit 22c184e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/tests_deployment/test_jupyterhub_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ def extract_output(delimiter: str, output: str) -> str:
return output.strip()


def run_command_list(commands: list[str], channel: paramiko.Channel) -> dict[str, str]:
def run_command_list(
commands: list[str], channel: paramiko.Channel, wait_time: int = 0
) -> dict[str, str]:
command_delimiters = {}
for command in commands:
delimiter = uuid.uuid4().hex
command_delimiters[command] = delimiter
b = channel.send(f"echo {delimiter}start; {command}; echo {delimiter}end\n")
if b == 0:
print(f"Command '{command}' failed to send")
# Wait for the output to be ready before reading
time.sleep(wait_time)
while not channel.recv_ready():
time.sleep(1)
print("Waiting for output")
Expand Down Expand Up @@ -143,7 +147,7 @@ def test_contains_jupyterhub_ssh(paramiko_object):
"ls -la ~/..data": "No such file or directory",
}

outputs = run_command_list(commands_contain.keys(), channel)
outputs = run_command_list(commands_contain.keys(), channel, 30)
for command, expected_output in commands_contain.items():
assert (
expected_output in outputs[command]
Expand Down

0 comments on commit 22c184e

Please sign in to comment.