diff options
author | Ryan Lahfa <masterancpp@gmail.com> | 2023-10-21 17:26:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-21 17:26:57 +0100 |
commit | c5442c247f882a4d953c4ac02aa93b6aab6f02fe (patch) | |
tree | 49644a97e83d95d386d0d8a94c127fa2df073c56 /nixos/lib | |
parent | 2caca43de3d3e678a0d2873fa12abdb845eae585 (diff) | |
parent | e5c2c71280244eca8fd2dc87f2be0ca1db7f49dd (diff) |
Merge pull request #257262 from dongcarl/2023-09-nginx-fixes
nixos/nginx: Allow empty port for listen directive (for unix socket)
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/test-driver/test_driver/machine.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/nixos/lib/test-driver/test_driver/machine.py b/nixos/lib/test-driver/test_driver/machine.py index 7ed001a1dfce4..b1688cd3b64f0 100644 --- a/nixos/lib/test-driver/test_driver/machine.py +++ b/nixos/lib/test-driver/test_driver/machine.py @@ -791,6 +791,28 @@ class Machine: with self.nested(f"waiting for TCP port {port} on {addr}"): retry(port_is_open, timeout) + def wait_for_open_unix_socket( + self, addr: str, is_datagram: bool = False, timeout: int = 900 + ) -> None: + """ + Wait until a process is listening on the given UNIX-domain socket + (default to a UNIX-domain stream socket). + """ + + nc_flags = [ + "-z", + "-uU" if is_datagram else "-U", + ] + + def socket_is_open(_: Any) -> bool: + status, _ = self.execute(f"nc {' '.join(nc_flags)} {addr}") + return status == 0 + + with self.nested( + f"waiting for UNIX-domain {'datagram' if is_datagram else 'stream'} on '{addr}'" + ): + retry(socket_is_open, timeout) + def wait_for_closed_port( self, port: int, addr: str = "localhost", timeout: int = 900 ) -> None: |