mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
add tests for unparsable lines on linux
This commit is contained in:
1
tests/fixtures/centos-7.7/ping-ip-O-unparsedlines.json
vendored
Normal file
1
tests/fixtures/centos-7.7/ping-ip-O-unparsedlines.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"destination_ip":"127.0.0.1","data_bytes":56,"pattern":null,"destination":"127.0.0.1","packets_transmitted":20,"packets_received":20,"packet_loss_percent":0.0,"duplicates":0,"time_ms":19070.0,"round_trip_ms_min":0.038,"round_trip_ms_avg":0.047,"round_trip_ms_max":0.08,"round_trip_ms_stddev":0.011,"responses":[{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":1,"ttl":64,"time_ms":0.038,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":2,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":3,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"unparsable_line","unparsed_line":"64 bytes from 127.0.0.1: error - weird error"},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":5,"ttl":64,"time_ms":0.08,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":6,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":7,"ttl":64,"time_ms":0.047,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":8,"ttl":64,"time_ms":0.04,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":9,"ttl":64,"time_ms":0.052,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":10,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":11,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":12,"ttl":64,"time_ms":0.043,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":13,"ttl":64,"time_ms":0.05,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":14,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":15,"ttl":64,"time_ms":0.062,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":16,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":17,"ttl":64,"time_ms":0.046,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":18,"ttl":64,"time_ms":0.045,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":19,"ttl":64,"time_ms":0.044,"duplicate":false},{"type":"reply","timestamp":null,"bytes":64,"response_ip":"127.0.0.1","icmp_seq":20,"ttl":64,"time_ms":0.044,"duplicate":false}]}
|
27
tests/fixtures/centos-7.7/ping-ip-O-unparsedlines.out
vendored
Normal file
27
tests/fixtures/centos-7.7/ping-ip-O-unparsedlines.out
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
|
||||
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.038 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.043 ms: some weird error
|
||||
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.044 ms
|
||||
64 bytes from 127.0.0.1: error - weird error
|
||||
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.080 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.043 ms
|
||||
this is a weird error message
|
||||
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.047 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.040 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.052 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.044 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=11 ttl=64 time=0.043 ms
|
||||
unparsable line
|
||||
64 bytes from 127.0.0.1: icmp_seq=12 ttl=64 time=0.043 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=13 ttl=64 time=0.050 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=14 ttl=64 time=0.045 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=15 ttl=64 time=0.062 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=16 ttl=64 time=0.046 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=17 ttl=64 time=0.046 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=18 ttl=64 time=0.045 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=19 ttl=64 time=0.044 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=20 ttl=64 time=0.044 ms
|
||||
|
||||
--- 127.0.0.1 ping statistics ---
|
||||
20 packets transmitted, 20 received, 0% packet loss, time 19070ms
|
||||
rtt min/avg/max/mdev = 0.038/0.047/0.080/0.011 ms
|
@ -45,6 +45,9 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping6-ip-dup.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_ping6_ip_dup = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping-ip-O-unparsedlines.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_ping_ip_O_unparsedlines = f.read()
|
||||
|
||||
# ubuntu
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping-ip-O.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_ping_ip_O = f.read()
|
||||
@ -230,6 +233,9 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping6-ip-dup.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_ping6_ip_dup_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping-ip-O-unparsedlines.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_ping_ip_O_unparsedlines_json = json.loads(f.read())
|
||||
|
||||
# ubunutu
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping-ip-O.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_ping_ip_O_json = json.loads(f.read())
|
||||
@ -451,6 +457,12 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ping.parse(self.centos_7_7_ping6_ip_dup, quiet=True), self.centos_7_7_ping6_ip_dup_json)
|
||||
|
||||
def test_ping_ip_O_unparsedlines_centos_7_7(self):
|
||||
"""
|
||||
Test 'ping <ip> -O' on Centos 7.7 with unparsable lines and error messages
|
||||
"""
|
||||
self.assertEqual(jc.parsers.ping.parse(self.centos_7_7_ping_ip_O_unparsedlines, quiet=True), self.centos_7_7_ping_ip_O_unparsedlines_json)
|
||||
|
||||
def test_ping_ip_O_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'ping <ip> -O' on Ubuntu 18.4
|
||||
|
Reference in New Issue
Block a user