From b0d83f188dc9a6bb6cdb13e83baa8c345956a9d2 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Mon, 21 Oct 2019 23:13:46 +0200 Subject: flowprobe: tests support python3 Type: fix Signed-off-by: Ole Troan Change-Id: I7425147e864467e4f94cee2a82ef74a894339471 --- src/plugins/flowprobe/test/test_flowprobe.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/plugins/flowprobe/test') diff --git a/src/plugins/flowprobe/test/test_flowprobe.py b/src/plugins/flowprobe/test/test_flowprobe.py index 9ffe84b8c2c..307d836e9ed 100644 --- a/src/plugins/flowprobe/test/test_flowprobe.py +++ b/src/plugins/flowprobe/test/test_flowprobe.py @@ -18,6 +18,8 @@ from vpp_pg_interface import CaptureTimeoutError from util import ppp from ipfix import IPFIX, Set, Template, Data, IPFIXDecoder from vpp_ip_route import VppIpRoute, VppRoutePath +from vpp_papi.macaddress import mac_ntop +from socket import inet_ntop class VppCFLOW(VppObject): @@ -438,11 +440,9 @@ class Flowprobe(MethodHolder): # packets self.assertEqual(int(binascii.hexlify(record[2]), 16), 1) # src mac - self.assertEqual(':'.join(re.findall('..', record[56].encode( - 'hex'))), self.pg8.local_mac) + self.assertEqual(mac_ntop(record[56]), self.pg8.local_mac) # dst mac - self.assertEqual(':'.join(re.findall('..', record[80].encode( - 'hex'))), self.pg8.remote_mac) + self.assertEqual(mac_ntop(record[80]), self.pg8.remote_mac) flowTimestamp = int(binascii.hexlify(record[156]), 16) >> 32 # flow start timestamp self.assertAlmostEqual(flowTimestamp, nowUNIX, delta=1) @@ -452,15 +452,11 @@ class Flowprobe(MethodHolder): # ethernet type self.assertEqual(int(binascii.hexlify(record[256]), 16), 8) # src ip - self.assertEqual('.'.join(re.findall('..', record[8].encode( - 'hex'))), - '.'.join('{:02x}'.format(int(n)) for n in - self.pg7.remote_ip4.split('.'))) + self.assertEqual(inet_ntop(socket.AF_INET, record[8]), + self.pg7.remote_ip4) # dst ip - self.assertEqual('.'.join(re.findall('..', record[12].encode( - 'hex'))), - '.'.join('{:02x}'.format(int(n)) for n in - "9.0.0.100".split('.'))) + self.assertEqual(inet_ntop(socket.AF_INET, record[12]), + "9.0.0.100") # protocol (TCP) self.assertEqual(int(binascii.hexlify(record[4]), 16), 6) # src port -- cgit 1.2.3-korg