Skip to content

Commit

Permalink
migrate dir_bcast_test and fdb scripts to python3 (#5540)
Browse files Browse the repository at this point in the history
Description of PR
Summary:
migrate the following scripts to python3, this PR can't be merged until #5534 is merged which has dependency of ptf_runner.py

ansible/roles/test/files/ptftests/dir_bcast_test.py
ansible/roles/test/files/ptftests/fdb.py
ansible/roles/test/files/ptftests/fdb_mac_expire_test.py
ansible/roles/test/files/ptftests/fdb_test.py


Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
  • Loading branch information
ZhaohuiS authored May 18, 2022
1 parent a4c8edb commit 2c6d38a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ def setUp(self):
self.router_mac = self.test_params['router_mac']
self.setUpVlan(self.test_params['vlan_info'])
if self.test_params['testbed_type'] == 't0':
self.src_ports = range(1, 25) + range(28, 32)
self.src_ports = list(range(1, 25)) + list(range(28, 32))
if self.test_params['testbed_type'] == 't0-52':
self.src_ports = range(0, 52)
self.src_ports = list(range(0, 52))
if self.test_params['testbed_type'] == 't0-56':
self.src_ports = range(0, 2) + range(4, 6) + range(8, 10) + range(12, 18) + range(20, 22) + \
range(24, 26) + range(28, 30) + range(32, 34) + range(36, 38) + range(40, 46) + \
range(48, 50) + range(52, 54)
self.src_ports = list(range(0, 2)) + list(range(4, 6)) + list(range(8, 10)) + list(range(12, 18)) + list(range(20, 22)) + \
list(range(24, 26)) + list(range(28, 30)) + list(range(32, 34)) + list(range(36, 38)) + list(range(40, 46)) + \
list(range(48, 50)) + list(range(52, 54))
if self.test_params['testbed_type'] == 't0-64':
self.src_ports = range(0, 2) + range(4, 18) + range(20, 33) + range(36, 43) + range(48, 49) + range(52, 59)
self.src_ports = list(range(0, 2)) + list(range(4, 18)) + list(range(20, 33)) + list(range(36, 43)) + list(range(48, 49)) + list(range(52, 59))
if self.test_params['testbed_type'] == 't0-116':
self.src_ports = range(24, 32)
self.src_ports = list(range(24, 32))
if self.test_params['testbed_type'] == 't0-120':
self.src_ports = [48, 49, 54, 55, 60, 61, 66, 67]

Expand All @@ -79,7 +79,7 @@ def setUpVlan(self, file_path):
with open(file_path, 'r') as f:
for line in f.readlines():
entry = line.split(' ', 1)
prefix = ip_network(unicode(entry[0]))
prefix = ip_network(str(entry[0]))
if prefix.version != 4:
continue
self._vlan_dict[prefix] = [int(i) for i in entry[1].split()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, file_path):
for line in f.readlines():
if pattern.match(line): continue
entry = line.split(' ', 1)
prefix = ip_network(unicode(entry[0]))
prefix = ip_network(str(entry[0]))
self._vlan_dict[prefix] = [int(i) for i in entry[1].split()]

def insert(self, mac, member):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ def runTest(self):
self.populateFdb()
if self.refresh_type == REFRESH_DEST_MAC:
self.refreshFdbWithInvalidPackets()
return
#--------------------------------------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def shell(self, cmds):
def setUp(self):
self.dataplane = ptf.dataplane_instance
self.fdb = fdb.Fdb(self.test_params['fdb_info'])
self.vlan_ip = ip_address(unicode(self.test_params['vlan_ip']))
self.vlan_ip = ip_address(str(self.test_params['vlan_ip']))
self.dummy_mac_prefix = self.test_params["dummy_mac_prefix"]
self.dummy_mac_number = int(self.test_params["dummy_mac_number"])
self.dummy_mac_table = {}
Expand Down
4 changes: 2 additions & 2 deletions tests/fdb/test_fdb_mac_expire.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def __runPtfTest(self, ptfhost, testCase='', testParams={}):
"""
logger.info("Running PTF test case '{0}' on '{1}'".format(testCase, ptfhost.hostname))
ptfhost.shell(argv=[
"ptf",
"/root/env-python3/bin/ptf",
"--test-dir",
"ptftests",
"ptftests/py3",
testCase,
"--platform-dir",
"ptftests",
Expand Down
3 changes: 2 additions & 1 deletion tests/ipfwd/test_dir_bcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ def test_dir_bcast(duthosts, rand_one_dut_hostname, ptfhost, tbinfo):
'dir_bcast_test.BcastTest',
'/root/ptftests',
params=params,
log_file=log_file)
log_file=log_file,
is_python3=True)

0 comments on commit 2c6d38a

Please sign in to comment.