forked from p15670423/monkey
Agent: User ceil on ping timeouts
This is due to older version of ping which doesn't support float timeouts. It is throwing `bad linger time` Error.
This commit is contained in:
parent
6cd74453cf
commit
9c25b3590b
|
@ -80,4 +80,5 @@ def _build_ping_command(host: str, timeout: float):
|
||||||
ping_count_flag = "-n" if "win32" == sys.platform else "-c"
|
ping_count_flag = "-n" if "win32" == sys.platform else "-c"
|
||||||
ping_timeout_flag = "-w" if "win32" == sys.platform else "-W"
|
ping_timeout_flag = "-w" if "win32" == sys.platform else "-W"
|
||||||
|
|
||||||
return ["ping", ping_count_flag, "1", ping_timeout_flag, str(timeout), host]
|
# on older version of ping the timeout must be an integer, thus we use ceil
|
||||||
|
return ["ping", ping_count_flag, "1", ping_timeout_flag, str(math.ceil(timeout)), host]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import math
|
||||||
import subprocess
|
import subprocess
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
@ -172,4 +173,4 @@ def test_linux_timeout(assert_expected_timeout):
|
||||||
timeout_flag = "-W"
|
timeout_flag = "-W"
|
||||||
timeout = 1.42379
|
timeout = 1.42379
|
||||||
|
|
||||||
assert_expected_timeout(timeout_flag, timeout, str(timeout))
|
assert_expected_timeout(timeout_flag, timeout, str(math.ceil(timeout)))
|
||||||
|
|
Loading…
Reference in New Issue