mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
support alpine linux ping
This commit is contained in:
@ -480,7 +480,7 @@ def _bsd_parse(data):
|
||||
'round_trip_ms_min': split_line[0],
|
||||
'round_trip_ms_avg': split_line[1],
|
||||
'round_trip_ms_max': split_line[2],
|
||||
'round_trip_ms_stddev': split_line[3].replace(' ms', '')
|
||||
'round_trip_ms_stddev': split_line[3].replace(' ms', '') if len(split_line) == 4 else None
|
||||
}
|
||||
)
|
||||
|
||||
|
1
tests/fixtures/alpine-linux-3.13/ping-hostname.json
vendored
Normal file
1
tests/fixtures/alpine-linux-3.13/ping-hostname.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"destination_ip":"142.250.125.102","data_bytes":56,"pattern":null,"destination":"google.com","packets_transmitted":4,"packets_received":4,"packet_loss_percent":0.0,"duplicates":0,"round_trip_ms_min":1.281,"round_trip_ms_avg":1.345,"round_trip_ms_max":1.408,"round_trip_ms_stddev":null,"responses":[{"type":"reply","bytes":64,"response_ip":"142.250.125.102","icmp_seq":0,"ttl":42,"time_ms":1.331,"duplicate":false},{"type":"reply","bytes":64,"response_ip":"142.250.125.102","icmp_seq":1,"ttl":42,"time_ms":1.281,"duplicate":false},{"type":"reply","bytes":64,"response_ip":"142.250.125.102","icmp_seq":2,"ttl":42,"time_ms":1.408,"duplicate":false},{"type":"reply","bytes":64,"response_ip":"142.250.125.102","icmp_seq":3,"ttl":42,"time_ms":1.36,"duplicate":false}]}
|
9
tests/fixtures/alpine-linux-3.13/ping-hostname.out
vendored
Normal file
9
tests/fixtures/alpine-linux-3.13/ping-hostname.out
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
PING google.com (142.250.125.102): 56 data bytes
|
||||
64 bytes from 142.250.125.102: seq=0 ttl=42 time=1.331 ms
|
||||
64 bytes from 142.250.125.102: seq=1 ttl=42 time=1.281 ms
|
||||
64 bytes from 142.250.125.102: seq=2 ttl=42 time=1.408 ms
|
||||
64 bytes from 142.250.125.102: seq=3 ttl=42 time=1.360 ms
|
||||
|
||||
--- google.com ping statistics ---
|
||||
4 packets transmitted, 4 packets received, 0% packet loss
|
||||
round-trip min/avg/max = 1.281/1.345/1.408 ms
|
1
tests/fixtures/alpine-linux-3.13/ping-ip.json
vendored
Normal file
1
tests/fixtures/alpine-linux-3.13/ping-ip.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"destination_ip":"8.8.8.8","data_bytes":56,"pattern":null,"destination":"8.8.8.8","packets_transmitted":1,"packets_received":1,"packet_loss_percent":0.0,"duplicates":0,"round_trip_ms_min":1.637,"round_trip_ms_avg":1.637,"round_trip_ms_max":1.637,"round_trip_ms_stddev":null,"responses":[{"type":"reply","bytes":64,"response_ip":"8.8.8.8","icmp_seq":0,"ttl":42,"time_ms":1.637,"duplicate":false}]}
|
6
tests/fixtures/alpine-linux-3.13/ping-ip.out
vendored
Normal file
6
tests/fixtures/alpine-linux-3.13/ping-ip.out
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
PING 8.8.8.8 (8.8.8.8): 56 data bytes
|
||||
64 bytes from 8.8.8.8: seq=0 ttl=42 time=1.637 ms
|
||||
|
||||
--- 8.8.8.8 ping statistics ---
|
||||
1 packets transmitted, 1 packets received, 0% packet loss
|
||||
round-trip min/avg/max = 1.637/1.637/1.637 ms
|
@ -203,6 +203,13 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/pi/ping-ip-O-D.out'), 'r', encoding='utf-8') as f:
|
||||
self.pi_ping_ip_O_D = f.read()
|
||||
|
||||
# alpine-linux
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/alpine-linux-3.13/ping-ip.out'), 'r', encoding='utf-8') as f:
|
||||
self.alpine_linux_3_13_ping_ip = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/alpine-linux-3.13/ping-hostname.out'), 'r', encoding='utf-8') as f:
|
||||
self.alpine_linux_3_13_ping_hostname = f.read()
|
||||
|
||||
# output
|
||||
|
||||
# centos
|
||||
@ -397,6 +404,14 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/pi/ping-ip-O-D.json'), 'r', encoding='utf-8') as f:
|
||||
self.pi_ping_ip_O_D_json = json.loads(f.read())
|
||||
|
||||
# alpine-linux
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/alpine-linux-3.13/ping-ip.json'), 'r', encoding='utf-8') as f:
|
||||
self.alpine_linux_3_13_ping_ip_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/alpine-linux-3.13/ping-hostname.json'), 'r', encoding='utf-8') as f:
|
||||
self.alpine_linux_3_13_ping_hostname_json = json.loads(f.read())
|
||||
|
||||
|
||||
def test_ping_nodata(self):
|
||||
"""
|
||||
Test 'ping' with no data
|
||||
@ -775,6 +790,18 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ping.parse(self.pi_ping_ip_O_D, quiet=True), self.pi_ping_ip_O_D_json)
|
||||
|
||||
def test_ping_ip_alpine_linux(self):
|
||||
"""
|
||||
Test 'ping <ip> -O' on alpine linux
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ping.parse(self.alpine_linux_3_13_ping_ip, quiet=True), self.alpine_linux_3_13_ping_ip_json)
|
||||
|
||||
def test_ping_hostname_alpine_linux(self):
|
||||
"""
|
||||
Test 'ping6 <hostname>' on alpine linux
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ping.parse(self.alpine_linux_3_13_ping_hostname, quiet=True), self.alpine_linux_3_13_ping_hostname_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user