container-test-driver: implement wait_for_open_port
This commit is contained in:
@@ -2,6 +2,7 @@ import argparse
|
||||
import ctypes
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
@@ -303,6 +304,15 @@ class Machine:
|
||||
retry(check_success, timeout)
|
||||
return output
|
||||
|
||||
def wait_for_open_port(
|
||||
self, port: int, addr: str = "localhost", timeout: int = 900
|
||||
) -> None:
|
||||
"""
|
||||
Wait for a port to be open on the given address.
|
||||
"""
|
||||
command = f"nc -z {shlex.quote(addr)} {port}"
|
||||
self.wait_until_succeeds(command, timeout=timeout)
|
||||
|
||||
def wait_for_unit(self, unit: str, timeout: int = 900) -> None:
|
||||
"""
|
||||
Wait for a systemd unit to get into "active" state.
|
||||
|
||||
Reference in New Issue
Block a user