File tree Expand file tree Collapse file tree
tests/pytests/functional/modules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -937,7 +937,17 @@ def traceroute(host):
937937 """
938938 ret = []
939939 cmd = "traceroute {}" .format (__utils__ ["network.sanitize_host" ](host ))
940- out = __salt__ ["cmd.run" ](cmd )
940+ # Bound the wall-clock time so callers aren't blocked indefinitely when
941+ # every hop times out (30 hops × 3 probes × 5 s = 450 s by default).
942+ # 120 s is enough for a well-routed destination and still returns partial
943+ # results (already-seen hops) for unreachable destinations.
944+ out = __salt__ ["cmd.run" ](cmd , timeout = 120 )
945+
946+ # When cmd.run hits its timeout it returns the exception message as stdout
947+ # rather than actual traceroute output. Detect that and bail early so the
948+ # parser below doesn't try to interpret the error string as hop data.
949+ if "Timed out after" in out :
950+ return ret
941951
942952 # Parse version of traceroute
943953 if __utils__ ["platform.is_sunos" ]() or __utils__ ["platform.is_aix" ]():
@@ -1041,7 +1051,7 @@ def traceroute(host):
10411051 # Parse anything else
10421052 else :
10431053 comps = line .split ()
1044- if len (comps ) >= 8 :
1054+ if len (comps ) >= 9 :
10451055 result = {
10461056 "count" : comps [0 ],
10471057 "hostname" : comps [1 ],
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ def test_network_netstat(network):
5757
5858@pytest .mark .skip_if_binaries_missing ("traceroute" )
5959@pytest .mark .slow_test
60- @pytest .mark .timeout (300 )
60+ @pytest .mark .timeout (150 )
6161def test_network_traceroute (network , url ):
6262 """
6363 network.traceroute
You can’t perform that action at this time.
0 commit comments