mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 18:27:21 +00:00
topotests: fix snmptrap log OID parsing
Replace OID string parsing of snmptrap log files based on odd/even line numbers with regex string search to prevent test failures in cases where log entries don't match assumed order. Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
This commit is contained in:
parent
1bc2fa3584
commit
961667e34f
@ -213,14 +213,15 @@ class SnmpTester(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_notif_bgp4(self, output_file):
|
def get_notif_bgp4(self, output_file):
|
||||||
|
notifs = []
|
||||||
notif_list = []
|
notif_list = []
|
||||||
whitecleanfile = re.sub("\t", " ", output_file)
|
whitecleanfile = re.sub("\t", " ", output_file)
|
||||||
results = whitecleanfile.strip().split("\n")
|
results = whitecleanfile.strip().split("\n")
|
||||||
|
|
||||||
# don't consider SNMP additional messages
|
# don't consider additional SNMP or application messages
|
||||||
notifs_first = [elem for elem in results if not ("SNMP" in elem)]
|
for result in results:
|
||||||
# don't consider additional application messages
|
if re.search(r"(\.([0-9]+))+\s", result):
|
||||||
notifs = [elem for index, elem in enumerate(notifs_first) if index % 2 != 0]
|
notifs.append(result)
|
||||||
|
|
||||||
oid_v4 = r"1\.3\.6\.1\.2\.1\.15"
|
oid_v4 = r"1\.3\.6\.1\.2\.1\.15"
|
||||||
for one_notif in notifs:
|
for one_notif in notifs:
|
||||||
@ -232,14 +233,15 @@ class SnmpTester(object):
|
|||||||
return notif_list
|
return notif_list
|
||||||
|
|
||||||
def get_notif_bgp4v2(self, output_file):
|
def get_notif_bgp4v2(self, output_file):
|
||||||
|
notifs = []
|
||||||
notif_list = []
|
notif_list = []
|
||||||
whitecleanfile = re.sub("\t", " ", output_file)
|
whitecleanfile = re.sub("\t", " ", output_file)
|
||||||
results = whitecleanfile.strip().split("\n")
|
results = whitecleanfile.strip().split("\n")
|
||||||
|
|
||||||
# don't consider SNMP additional messages
|
# don't consider additional SNMP or application messages
|
||||||
notifs_first = [elem for elem in results if not ("SNMP" in elem)]
|
for result in results:
|
||||||
# don't consider additional application messages
|
if re.search(r"(\.([0-9]+))+\s", result):
|
||||||
notifs = [elem for index, elem in enumerate(results) if index % 2 != 0]
|
notifs.append(result)
|
||||||
|
|
||||||
oid_v6 = r"1\.3\.6\.1\.3\.5\.1"
|
oid_v6 = r"1\.3\.6\.1\.3\.5\.1"
|
||||||
for one_notif in notifs:
|
for one_notif in notifs:
|
||||||
|
Loading…
Reference in New Issue
Block a user