Skip to content

Commit a485466

Browse files
authored
fix(tests): add backplane port only in srv6 tests (sonic-net#16669)
What is the motivation for this PR? Backplane port is necessary in our srv6 tests, but it will cause random failure in other tests. When the test packet dst IP matches the IP prefix advertised by the exabgp, the ptf backplane interface will receive the test packet from the neighbor VM. The reason is the routes are advertised by exabgp to VM through the ptf backplane interface. And methods like verify_packet_any_port() not only validate the packet is received by the expected ports, but also validate it's not received by the unexpected ports. How did you do it? Added configuration options in ptf initial to limite the configuration scenarios of backplane ports only in srv6 tests How did you verify/test it? we tested it via daily jenkins run Signed-off-by: linsongnan <linsongnan.lsn@alibaba-inc.com>
1 parent 25e9c4b commit a485466

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

ansible/roles/test/files/ptftests/remote.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_ifaces():
3434
return ifaces
3535

3636

37-
def build_ifaces_map(ifaces):
37+
def build_ifaces_map(ifaces, ptf_config=None):
3838
"""Build interface map for ptf to init dataplane."""
3939
ptf_port_mapping_mode = "use_orig_interface"
4040
constants_file = os.path.join(os.path.dirname(__file__), "constants.yaml")
@@ -44,6 +44,10 @@ def build_ifaces_map(ifaces):
4444
ptf_port_mapping_mode = constants.get(
4545
"PTF_PORT_MAPPING_MODE", ptf_port_mapping_mode)
4646

47+
need_backplane = False
48+
if ptf_config is not None and 'need_backplane' in ptf_config:
49+
need_backplane = ptf_config['need_backplane']
50+
4751
sub_ifaces = []
4852
iface_map = {}
4953
used_index = set()
@@ -63,7 +67,7 @@ def build_ifaces_map(ifaces):
6367
count = 1
6468
while count in used_index:
6569
count = count + 1
66-
if backplane_exist:
70+
if backplane_exist and need_backplane:
6771
iface_map[(0, count)] = "backplane"
6872

6973
if ptf_port_mapping_mode == "use_sub_interface":
@@ -85,6 +89,6 @@ def platform_config_update(config):
8589
@param config The configuration dictionary to use/update
8690
"""
8791

88-
remote_port_map = build_ifaces_map(get_ifaces())
92+
remote_port_map = build_ifaces_map(get_ifaces(), config)
8993
config["port_map"] = remote_port_map.copy()
9094
config["caps_table_idx"] = 0

tests/common/plugins/ptfadapter/__init__.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def get_ifaces(netdev_output):
7474
return ifaces
7575

7676

77-
def get_ifaces_map(ifaces, ptf_port_mapping_mode):
77+
def get_ifaces_map(ifaces, ptf_port_mapping_mode, need_backplane=False):
7878
"""Get interface map."""
7979
sub_ifaces = []
8080
iface_map = {}
@@ -95,7 +95,7 @@ def get_ifaces_map(ifaces, ptf_port_mapping_mode):
9595
count = 1
9696
while count in used_index:
9797
count = count + 1
98-
if backplane_exist:
98+
if backplane_exist and need_backplane:
9999
iface_map[count] = "backplane"
100100

101101
if ptf_port_mapping_mode == "use_sub_interface":
@@ -125,10 +125,14 @@ def ptfadapter(ptfhost, tbinfo, request, duthost):
125125
else:
126126
ptf_port_mapping_mode = 'use_orig_interface'
127127

128+
need_backplane = False
129+
if 'ciscovs-7nodes' in tbinfo['topo']['name']:
130+
need_backplane = True
131+
128132
# get the eth interfaces from PTF and initialize ifaces_map
129133
res = ptfhost.command('cat /proc/net/dev')
130134
ifaces = get_ifaces(res['stdout'])
131-
ifaces_map = get_ifaces_map(ifaces, ptf_port_mapping_mode)
135+
ifaces_map = get_ifaces_map(ifaces, ptf_port_mapping_mode, need_backplane)
132136

133137
def start_ptf_nn_agent():
134138
for i in range(MAX_RETRY_TIME):

tests/iface_loopback_action/conftest.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,14 @@ def orig_ports_configuration(request, duthost, ptfhost, tbinfo):
6161
constants.PTF_PORT_MAPPING_MODE_DEFAULT)
6262
else:
6363
ptf_port_mapping_mode = 'use_orig_interface'
64+
65+
need_backplane = False
66+
if 'ciscovs-7nodes' in tbinfo['topo']['name']:
67+
need_backplane = True
68+
6469
res = ptfhost.command('cat /proc/net/dev')
6570
ptf_ifaces = get_ifaces(res['stdout'])
66-
ptf_ifaces_map = get_ifaces_map(ptf_ifaces, ptf_port_mapping_mode)
71+
ptf_ifaces_map = get_ifaces_map(ptf_ifaces, ptf_port_mapping_mode, need_backplane)
6772
port_dict = get_tested_up_ports(duthost, ptf_ifaces_map, count=PORT_COUNT)
6873
yield port_dict
6974

tests/srv6/test_srv6_basic_sanity.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@
8080
#
8181
# Initialize the testbed
8282
#
83-
def setup_config(duthosts, rand_one_dut_hostname, nbrhosts, ptfhost):
83+
def setup_config(duthosts, rand_one_dut_hostname, nbrhosts, ptfhost, ptfadapter):
84+
85+
logger.info("reinit ptfadapter")
86+
ptfadapter.reinit({'need_backplane': True})
87+
8488
logger.info("Announce routes from CEs")
8589
ptfip = ptfhost.mgmt_ip
8690
nexthop = "10.10.246.254"
@@ -116,8 +120,8 @@ def setup_config(duthosts, rand_one_dut_hostname, nbrhosts, ptfhost):
116120
# Testbed set up and tear down
117121
#
118122
@pytest.fixture(scope="module", autouse=True)
119-
def srv6_config(duthosts, rand_one_dut_hostname, nbrhosts, ptfhost):
120-
setup_config(duthosts, rand_one_dut_hostname, nbrhosts, ptfhost)
123+
def srv6_config(duthosts, rand_one_dut_hostname, nbrhosts, ptfhost, ptfadapter):
124+
setup_config(duthosts, rand_one_dut_hostname, nbrhosts, ptfhost, ptfadapter)
121125

122126

123127
#

0 commit comments

Comments
 (0)