1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-17 01:32:37 +02:00

update traceroute, tracepath, and uname tests

This commit is contained in:
Kelly Brazil
2020-07-27 16:47:41 -07:00
parent 5baa6cc865
commit a5f97febd3
10 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1 @@
{"pmtu": 1500, "forward_hops": null, "return_hops": null, "hops": [{"ttl": 1, "guess": true, "host": "[LOCALHOST]", "reply_ms": null, "pmtu": 1500, "asymmetric_difference": null, "reached": false}, {"ttl": 1, "guess": false, "host": "dsldevice.attlocal.net", "reply_ms": 4.063, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 1, "guess": false, "host": "dsldevice.attlocal.net", "reply_ms": 6.368, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 2, "guess": false, "host": "76-220-24-1.lightspeed.sntcca.sbcglobal.net", "reply_ms": 24.092, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 3, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 4, "guess": false, "host": "12.242.117.16", "reply_ms": 161.527, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 5, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 6, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 3, "guess": false, "host": "71.148.149.0", "reply_ms": 12000.559, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 3, "guess": false, "host": "71.148.149.0", "reply_ms": 11967.523, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 3, "guess": false, "host": "71.148.149.0", "reply_ms": 11829.634, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 10, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 11, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 12, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 13, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 14, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 15, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 16, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 17, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 18, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 19, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 20, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 21, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 22, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 23, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 24, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 25, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 26, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 27, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 28, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 29, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 30, "guess": false, "host": null, "reply_ms": null, "pmtu": null, "asymmetric_difference": null, "reached": false}]}

View File

@ -0,0 +1 @@
{"pmtu": 1480, "forward_hops": 2, "return_hops": 2, "hops": [{"ttl": 1, "guess": true, "host": "[LOCALHOST]", "reply_ms": null, "pmtu": 1500, "asymmetric_difference": null, "reached": false}, {"ttl": 1, "guess": false, "host": "dust.inr.ac.ru", "reply_ms": 0.411, "pmtu": null, "asymmetric_difference": null, "reached": false}, {"ttl": 2, "guess": false, "host": "dust.inr.ac.ru", "reply_ms": 0.39, "pmtu": 1480, "asymmetric_difference": 1, "reached": false}, {"ttl": 2, "guess": false, "host": "3ffe:2400:0:109::2", "reply_ms": 463.514, "pmtu": null, "asymmetric_difference": null, "reached": true}]}

View File

@ -0,0 +1 @@
{"destination_ip": "8.8.8.8", "destination_name": "8.8.8.8", "hops": [{"hop": 1, "probes": [{"annotation": null, "asn": null, "ip": "192.168.1.254", "name": "dsldevice.attlocal.net", "rtt": 3.263}, {"annotation": null, "asn": null, "ip": "192.168.1.254", "name": "dsldevice.attlocal.net", "rtt": 4.146}, {"annotation": null, "asn": null, "ip": "192.168.1.254", "name": "dsldevice.attlocal.net", "rtt": 4.273}]}, {"hop": 2, "probes": [{"annotation": null, "asn": null, "ip": "76.220.24.1", "name": "76-220-24-1.lightspeed.sntcca.sbcglobal.net", "rtt": 20.839}, {"annotation": null, "asn": null, "ip": "76.220.24.1", "name": "76-220-24-1.lightspeed.sntcca.sbcglobal.net", "rtt": 23.434}, {"annotation": null, "asn": null, "ip": "76.220.24.1", "name": "76-220-24-1.lightspeed.sntcca.sbcglobal.net", "rtt": 22.032}]}, {"hop": 3, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 4, "probes": [{"annotation": null, "asn": null, "ip": "12.122.149.186", "name": "12.122.149.186", "rtt": 33.17}, {"annotation": null, "asn": null, "ip": "12.122.149.186", "name": "12.122.149.186", "rtt": 26.593}, {"annotation": null, "asn": null, "ip": "12.122.149.186", "name": "12.122.149.186", "rtt": 32.851}]}, {"hop": 5, "probes": [{"annotation": null, "asn": null, "ip": "12.122.3.70", "name": "sffca22crs.ip.att.net", "rtt": 26.045}, {"annotation": null, "asn": null, "ip": "12.122.3.70", "name": "sffca22crs.ip.att.net", "rtt": 29.235}, {"annotation": null, "asn": null, "ip": "12.122.3.70", "name": "sffca22crs.ip.att.net", "rtt": 28.28}]}, {"hop": 6, "probes": [{"annotation": null, "asn": null, "ip": "12.122.163.61", "name": "12.122.163.61", "rtt": 25.3}, {"annotation": null, "asn": null, "ip": "12.122.163.61", "name": "12.122.163.61", "rtt": 24.156}, {"annotation": null, "asn": null, "ip": "12.122.163.61", "name": "12.122.163.61", "rtt": 24.849}]}, {"hop": 7, "probes": [{"annotation": null, "asn": null, "ip": "12.255.10.226", "name": "12.255.10.226", "rtt": 25.375}, {"annotation": null, "asn": null, "ip": "12.255.10.224", "name": "12.255.10.224", "rtt": 24.011}, {"annotation": null, "asn": null, "ip": "12.255.10.224", "name": "12.255.10.224", "rtt": 25.322}]}, {"hop": 8, "probes": [{"annotation": null, "asn": null, "ip": "108.170.243.1", "name": "108.170.243.1", "rtt": 29.376}]}, {"hop": 9, "probes": [{"annotation": null, "asn": null, "ip": "8.8.8.8", "name": "dns.google", "rtt": 23.228}, {"annotation": null, "asn": null, "ip": "209.85.252.251", "name": "209.85.252.251", "rtt": 24.548}, {"annotation": null, "asn": null, "ip": "108.170.237.23", "name": "108.170.237.23", "rtt": 24.332}]}]}

14
tests/fixtures/freebsd12/traceroute.out vendored Normal file
View File

@ -0,0 +1,14 @@
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 40 byte packets
1 dsldevice.attlocal.net (192.168.1.254) 3.263 ms 4.146 ms 4.273 ms
2 76-220-24-1.lightspeed.sntcca.sbcglobal.net (76.220.24.1) 20.839 ms 23.434 ms 22.032 ms
3 * * *
4 12.122.149.186 (12.122.149.186) 33.170 ms 26.593 ms 32.851 ms
5 sffca22crs.ip.att.net (12.122.3.70) 26.045 ms 29.235 ms 28.280 ms
6 12.122.163.61 (12.122.163.61) 25.300 ms 24.156 ms 24.849 ms
7 12.255.10.226 (12.255.10.226) 25.375 ms
12.255.10.224 (12.255.10.224) 24.011 ms 25.322 ms
8 * 108.170.243.1 (108.170.243.1) 29.376 ms *
9 dns.google (8.8.8.8) 23.228 ms
209.85.252.251 (209.85.252.251) 24.548 ms
108.170.237.23 (108.170.237.23) 24.332 ms

View File

@ -0,0 +1 @@
{"destination_ip": "2a04:4e42::323", "destination_name": "turner-tls.map.fastly.net", "hops": [{"hop": 1, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 2, "probes": [{"annotation": null, "asn": null, "ip": "2001:506:6000:11b:71:156:212:143", "name": null, "rtt": 27.603}, {"annotation": null, "asn": null, "ip": "2001:506:6000:11b:71:156:212:143", "name": null, "rtt": 28.659}, {"annotation": null, "asn": null, "ip": "2001:506:6000:11b:71:156:212:143", "name": null, "rtt": 33.235}]}, {"hop": 3, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 4, "probes": [{"annotation": null, "asn": null, "ip": "2001:1890:ff:ff08:12:242:117:16", "name": null, "rtt": 36.731}, {"annotation": null, "asn": null, "ip": "2001:1890:ff:ff08:12:242:117:16", "name": null, "rtt": 28.875}, {"annotation": null, "asn": null, "ip": "2001:1890:ff:ff08:12:242:117:16", "name": null, "rtt": 28.959}]}, {"hop": 5, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 6, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 7, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 8, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 9, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 10, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 11, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 12, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 13, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 14, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 15, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 16, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 17, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 18, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 19, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 20, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 21, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 22, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 23, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 24, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 25, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 26, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 27, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 28, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 29, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 30, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}, {"hop": 31, "probes": [{"annotation": null, "asn": null, "ip": null, "name": null, "rtt": null}]}]}

View File

@ -0,0 +1,34 @@
traceroute6: Warning: turner-tls.map.fastly.net has multiple addresses; using 2a04:4e42::323
traceroute6 to turner-tls.map.fastly.net (2a04:4e42::323) from 2600:1700:bab0:d40:250:56ff:fe26:c5b4, 64 hops max, 20 byte packets
1 * * *
2 2001:506:6000:11b:71:156:212:143 27.603 ms 28.659 ms 33.235 ms
3 * * *
4 2001:1890:ff:ff08:12:242:117:16 36.731 ms 28.875 ms 28.959 ms
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *
18 * * *
19 * * *
20 * * *
21 * * *
22 * * *
23 * * *
24 * * *
25 * * *
26 * * *
27 * * *
28 * * *
29 * * *
30 * * *
31 * * *

1
tests/fixtures/osx-10.14.6/uname.out vendored Normal file
View File

@ -0,0 +1 @@
Darwin

46
tests/test_tracepath.py Normal file
View File

@ -0,0 +1,46 @@
import os
import unittest
import json
import jc.parsers.tracepath
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
def setUp(self):
# input
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/tracepath.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_tracepath = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/tracepath6.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_tracepath6 = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/tracepath.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_tracepath_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/tracepath6.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_tracepath6_json = json.loads(f.read())
def test_tracepath_nodata(self):
"""
Test 'tracepath' with no data
"""
self.assertEqual(jc.parsers.tracepath.parse('', quiet=True), {})
def test_tracepath_centos_7_7(self):
"""
Test 'tracepath' on Centos 7.7
"""
self.assertEqual(jc.parsers.tracepath.parse(self.centos_7_7_tracepath, quiet=True), self.centos_7_7_tracepath_json)
def test_tracepath6_centos_7_7(self):
"""
Test 'tracepath6' on Centos 7.7
"""
self.assertEqual(jc.parsers.tracepath.parse(self.centos_7_7_tracepath6, quiet=True), self.centos_7_7_tracepath6_json)
if __name__ == '__main__':
unittest.main()

View File

@ -34,6 +34,12 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/traceroute6.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_traceroute6 = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/traceroute.out'), 'r', encoding='utf-8') as f:
self.freebsd12_traceroute = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/traceroute6.out'), 'r', encoding='utf-8') as f:
self.freebsd12_traceroute6 = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/traceroute1.out'), 'r', encoding='utf-8') as f:
self.generic_traceroute1 = f.read()
@ -80,6 +86,12 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/traceroute6.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_traceroute6_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/traceroute.json'), 'r', encoding='utf-8') as f:
self.freebsd12_traceroute_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/traceroute6.json'), 'r', encoding='utf-8') as f:
self.freebsd12_traceroute6_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/traceroute1.json'), 'r', encoding='utf-8') as f:
self.generic_traceroute1_json = json.loads(f.read())
@ -158,6 +170,18 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.traceroute.parse(self.osx_10_14_6_traceroute6, quiet=True), self.osx_10_14_6_traceroute6_json)
def test_traceroute_freebsd12(self):
"""
Test 'traceroute' on freebsd12
"""
self.assertEqual(jc.parsers.traceroute.parse(self.freebsd12_traceroute, quiet=True), self.freebsd12_traceroute_json)
def test_traceroute6_freebsd12(self):
"""
Test 'traceroute6' on freebsd12
"""
self.assertEqual(jc.parsers.traceroute.parse(self.freebsd12_traceroute6, quiet=True), self.freebsd12_traceroute6_json)
def test_traceroute1_generic(self):
"""
Test 'traceroute'

View File

@ -22,6 +22,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/uname-a.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_uname_a = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/uname.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_uname = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/uname-a.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_uname_a_json = json.loads(f.read())
@ -41,6 +44,12 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.uname.parse('', quiet=True), {})
def test_uname_no_a(self):
"""
Test 'uname' without -a option. Should generate a ParseError exception
"""
self.assertRaises(jc.parsers.uname.ParseError, jc.parsers.uname.parse, self.osx_10_14_6_uname)
def test_uname_centos_7_7(self):
"""
Test 'uname -a' on Centos 7.7