pytest-docker-tools
pytest-docker-tools copied to clipboard
Race in container.ready
PDB session
(Pdb) p self.ports.values()
[[]]
(Pdb) self.reload()
(Pdb) p self.ports.values()
[[51350]]
Maybe something like this?
# If a user has exposed a port then wait for LISTEN socket to show up in netstat
ports = self._container.attrs["NetworkSettings"]["Ports"]
for port, listeners in ports.items():
if not listeners:
continue
++ if port not in self.ports:
++ return False
port, proto = port.split("/")
assert proto in ("tcp", "udp")
if proto == "tcp" and port not in self.get_open_tcp_ports():
return False
if proto == "udp" and port not in self.get_open_udp_ports():
return False
First time seen it in 1000's of tests, so unlikely to repro outside of a unittest.