πŸ”Š [wait_tcp_port_ready] make logs more meaningful, by showing name of host

The user deserves to know which host was unreachable, at least, not
just the port:

```2021-04-19 23:54:54.453 INFO LISA.lisa 'customized_0' attached to test case 'ATest.a_test': [Errno -2] Name or service not known```

was not telling anything
This commit is contained in:
Gustavo Lima Chaves 2021-04-19 16:45:10 -07:00 ΠΊΠΎΠΌΠΌΠΈΡ‚ ΠΏΡ€ΠΎΠΈΠ·Π²Ρ‘Π» Chi Song
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ e043cbde76
ΠšΠΎΠΌΠΌΠΈΡ‚ bcbd06168f
1 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 16 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 12 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -38,18 +38,22 @@ def wait_tcp_port_ready(
timout_timer = create_timer()
while timout_timer.elapsed(False) < timeout:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as tcp_socket:
result = tcp_socket.connect_ex((address, port))
if result == 0:
is_ready = True
break
else:
if times % 10 == 0 and log:
log.debug(
f"cannot connect to TCP port: {port}, error code: {result}, "
f"tried times: {times}, elapsed: {timout_timer}. retrying..."
)
sleep(1)
times += 1
try:
result = tcp_socket.connect_ex((address, port))
if result == 0:
is_ready = True
break
else:
if times % 10 == 0 and log:
log.debug(
f"cannot connect to {address}:{port}, "
f"error code: {result}, tried times: {times},"
f" elapsed: {timout_timer}. retrying..."
)
sleep(1)
times += 1
except Exception as e:
raise LisaException(f"failed to connect to {address}:{port}: {e}")
return is_ready, result