Skip to content

Commit

Permalink
[test_fib] Enable storage backend topologies (sonic-net#3909)
Browse files Browse the repository at this point in the history
Approach
What is the motivation for this PR?
Restore changes of sonic-net#3734 that are removed by sonic-net#3702 .

How did you do it?
How did you verify/test it?
  • Loading branch information
lolyu authored and vmittal-msft committed Sep 28, 2021
1 parent 7c88e76 commit 539ebe3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/common/fixtures/fib_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def get_fib_info(duthost, dut_cfg_facts, duts_mg_facts):

po = asic_cfg_facts.get('PORTCHANNEL', {})
ports = asic_cfg_facts.get('PORT', {})
sub_interfaces = asic_cfg_facts.get('VLAN_SUB_INTERFACE', {})

with open("/tmp/fib/{}/tmp/fib.{}.txt".format(duthost.hostname, timestamp)) as fp:
fib = json.load(fp)
Expand All @@ -135,7 +136,9 @@ def get_fib_info(duthost, dut_cfg_facts, duts_mg_facts):
else:
oports.append([str(duts_mg_facts['minigraph_ptf_indices'][x]) for x in po[ifname]['members']])
else:
if ports.has_key(ifname):
if sub_interfaces.has_key(ifname):
oports.append([str(duts_mg_facts['minigraph_ptf_indices'][ifname.split('.')[0]])])
elif ports.has_key(ifname):
if 'role' in ports[ifname] and ports[ifname]['role'] == 'Int':
skip = True
else:
Expand Down Expand Up @@ -181,8 +184,8 @@ def gen_fib_info_file(ptfhost, fib_info, filename):
ptfhost.copy(src=tmp_fib_info.name, dest=filename)


@pytest.fixture(scope='module')
def fib_info_files(duthosts, ptfhost, duts_running_config_facts, duts_minigraph_facts, tbinfo):
@pytest.fixture(scope='function')
def fib_info_files(duthosts, ptfhost, duts_running_config_facts, duts_minigraph_facts, tbinfo, request):
"""Get FIB info from database and store to text files on PTF host.
For T2 topology, generate a single file to /root/fib_info_all_duts.txt to PTF host.
Expand All @@ -200,11 +203,17 @@ def fib_info_files(duthosts, ptfhost, duts_running_config_facts, duts_minigraph_
list: List of FIB info file names on PTF host.
"""
duts_config_facts = duts_running_config_facts
testname = request.node.name
files = []
if tbinfo['topo']['type'] != "t2":
for dut_index, duthost in enumerate(duthosts):
fib_info = get_fib_info(duthost, duts_config_facts[duthost.hostname], duts_minigraph_facts[duthost.hostname])
filename = '/root/fib_info_dut{}.txt'.format(dut_index)
if 'test_basic_fib' in testname and 'backend' in tbinfo['topo']['name']:
# if it is a storage backend topology(bt0 or bt1) and testcase is test_basic_fib
# add a default route as failover in the prefix matching
fib_info[u'0.0.0.0/0'] = []
fib_info[u'::/0'] = []
filename = '/root/fib_info_dut_{0}_{1}.txt'.format(testname, dut_index)
gen_fib_info_file(ptfhost, fib_info, filename)
files.append(filename)
else:
Expand Down
1 change: 1 addition & 0 deletions tests/fib/test_fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import set_ptf_port_mapping_mode # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import ptf_test_port_map
from tests.ptf_runner import ptf_runner
from tests.common.helpers.assertions import pytest_assert
Expand Down

0 comments on commit 539ebe3

Please sign in to comment.