1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

add dest-unreachable test

This commit is contained in:
Kelly Brazil
2023-09-15 12:09:38 -07:00
parent 84f0246b2d
commit 3249a017ae
5 changed files with 42 additions and 4 deletions

View File

@ -0,0 +1 @@
{"type":"summary","destination_ip":"10.0.3.22","sent_bytes":56,"pattern":null,"packets_transmitted":3,"packets_received":0,"packet_loss_percent":100.0,"duplicates":0,"errors":3,"corrupted":null,"time_ms":2049.0,"round_trip_ms_min":null,"round_trip_ms_avg":null,"round_trip_ms_max":null,"round_trip_ms_stddev":null}

View File

@ -0,0 +1 @@
{"destination_ip":"10.0.3.22","data_bytes":56,"pattern":null,"destination":"10.0.3.22","duplicates":0,"packets_transmitted":3,"packets_received":0,"errors":3,"packet_loss_percent":100.0,"time_ms":2049.0,"responses":[]}

View File

@ -0,0 +1,8 @@
PING 10.0.3.22 (10.0.3.22) 56(84) bytes of data.
From 10.0.0.1 icmp_seq=1 Destination Host Unreachable
From 10.0.0.1 icmp_seq=2 Destination Host Unreachable
From 10.0.0.1 icmp_seq=3 Destination Host Unreachable
--- 10.0.3.22 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2049ms
pipe 3

View File

@ -53,7 +53,7 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping-missing-hostname.out'), 'r', encoding='utf-8') as f:
centos_7_7_ping_missing_hostname = f.read()
# ubuntu
# ubuntu 18.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping-ip-O.out'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping_ip_O = f.read()
@ -81,6 +81,10 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping6-hostname-O-D-p-s.out'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping6_hostname_O_D_p_s = f.read()
# ubuntu 22.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-22.04/ping-dest-unreachable.out'), 'r', encoding='utf-8') as f:
ubuntu_22_4_ping_dest_unreachable = f.read()
# fedora
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/ping-ip-O.out'), 'r', encoding='utf-8') as f:
fedora32_ping_ip_O = f.read()
@ -257,7 +261,7 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping-missing-hostname.json'), 'r', encoding='utf-8') as f:
centos_7_7_ping_missing_hostname_json = json.loads(f.read())
# ubunutu
# ubunutu 18.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping-ip-O.json'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping_ip_O_json = json.loads(f.read())
@ -285,6 +289,10 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping6-hostname-O-D-p-s.json'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping6_hostname_O_D_p_s_json = json.loads(f.read())
# ubuntu 22.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-22.04/ping-dest-unreachable.json'), 'r', encoding='utf-8') as f:
ubuntu_22_4_ping_dest_unreachable_json = json.loads(f.read())
# fedora
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/ping-ip-O.json'), 'r', encoding='utf-8') as f:
fedora32_ping_ip_O_json = json.loads(f.read())
@ -555,6 +563,12 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.ping.parse(self.ubuntu_18_4_ping6_hostname_O_D_p_s, quiet=True), self.ubuntu_18_4_ping6_hostname_O_D_p_s_json)
def test_ping_dest_unreachable_ubuntu_22_4(self):
"""
Test 'ping' on Ubuntu 22.4 with destination unreachable message
"""
self.assertEqual(jc.parsers.ping.parse(self.ubuntu_22_4_ping_dest_unreachable, quiet=True), self.ubuntu_22_4_ping_dest_unreachable_json)
def test_ping_ip_O_fedora32(self):
"""
Test 'ping <ip> -O' on fedora32

View File

@ -58,7 +58,7 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping-missing-hostname.out'), 'r', encoding='utf-8') as f:
centos_7_7_ping_missing_hostname = f.read()
# ubuntu
# ubuntu 18.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping-ip-O.out'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping_ip_O = f.read()
@ -86,6 +86,10 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping6-hostname-O-D-p-s.out'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping6_hostname_O_D_p_s = f.read()
# ubuntu 22.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-22.04/ping-dest-unreachable.out'), 'r', encoding='utf-8') as f:
ubuntu_22_4_ping_dest_unreachable = f.read()
# fedora
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/ping-ip-O.out'), 'r', encoding='utf-8') as f:
fedora32_ping_ip_O = f.read()
@ -252,7 +256,7 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ping-missing-hostname-streaming.json'), 'r', encoding='utf-8') as f:
centos_7_7_ping_missing_hostname_json = json.loads(f.read())
# ubunutu
# ubunutu 18.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping-ip-O-streaming.json'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping_ip_O_streaming_json = json.loads(f.read())
@ -280,6 +284,10 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ping6-hostname-O-D-p-s-streaming.json'), 'r', encoding='utf-8') as f:
ubuntu_18_4_ping6_hostname_O_D_p_s_streaming_json = json.loads(f.read())
# ubuntu 22.4
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-22.04/ping-dest-unreachable-streaming.json'), 'r', encoding='utf-8') as f:
ubuntu_22_4_ping_dest_unreachable_streaming_json = json.loads(f.read())
# fedora
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/fedora32/ping-ip-O-streaming.json'), 'r', encoding='utf-8') as f:
fedora32_ping_ip_O_streaming_json = json.loads(f.read())
@ -561,6 +569,12 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(list(jc.parsers.ping_s.parse(self.ubuntu_18_4_ping6_hostname_O_D_p_s.splitlines(), quiet=True)), self.ubuntu_18_4_ping6_hostname_O_D_p_s_streaming_json)
def test_ping_dest_unreachable_ubuntu_22_4(self):
"""
Test 'ping' on Ubuntu 22.4 with destination unreachable message
"""
self.assertEqual(list(jc.parsers.ping_s.parse(self.ubuntu_22_4_ping_dest_unreachable.splitlines(), quiet=True)), [self.ubuntu_22_4_ping_dest_unreachable_streaming_json])
def test_ping_s_ip_O_fedora32(self):
"""
Test 'ping <ip> -O' on fedora32