diff --git a/tests/fixtures/ubuntu-22.04/ping-dest-unreachable-streaming.json b/tests/fixtures/ubuntu-22.04/ping-dest-unreachable-streaming.json new file mode 100644 index 00000000..16aae853 --- /dev/null +++ b/tests/fixtures/ubuntu-22.04/ping-dest-unreachable-streaming.json @@ -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} diff --git a/tests/fixtures/ubuntu-22.04/ping-dest-unreachable.json b/tests/fixtures/ubuntu-22.04/ping-dest-unreachable.json new file mode 100644 index 00000000..e13a2c85 --- /dev/null +++ b/tests/fixtures/ubuntu-22.04/ping-dest-unreachable.json @@ -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":[]} diff --git a/tests/fixtures/ubuntu-22.04/ping-dest-unreachable.out b/tests/fixtures/ubuntu-22.04/ping-dest-unreachable.out new file mode 100644 index 00000000..56c970ab --- /dev/null +++ b/tests/fixtures/ubuntu-22.04/ping-dest-unreachable.out @@ -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 diff --git a/tests/test_ping.py b/tests/test_ping.py index 340437c1..ae56d40c 100644 --- a/tests/test_ping.py +++ b/tests/test_ping.py @@ -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 -O' on fedora32 diff --git a/tests/test_ping_s.py b/tests/test_ping_s.py index 76a9bc3f..37d6702a 100644 --- a/tests/test_ping_s.py +++ b/tests/test_ping_s.py @@ -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 -O' on fedora32