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:
Ilija Lazoroski 2022-04-01 15:03:01 +02:00 committed by Mike Salvatore
parent 6cd74453cf
commit 9c25b3590b
2 changed files with 4 additions and 2 deletions

View File

@ -80,4 +80,5 @@ def _build_ping_command(host: str, timeout: float):
ping_count_flag = "-n" if "win32" == sys.platform else "-c"
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]

View File

@ -1,3 +1,4 @@
import math
import subprocess
from unittest.mock import MagicMock
@ -172,4 +173,4 @@ def test_linux_timeout(assert_expected_timeout):
timeout_flag = "-W"
timeout = 1.42379
assert_expected_timeout(timeout_flag, timeout, str(timeout))
assert_expected_timeout(timeout_flag, timeout, str(math.ceil(timeout)))