Skip to content

Commit 2159aeb

Browse files
[pbh edit flow] add pbh edit flow validation to test (#5263)
Added pbh edit flow validation to the test test_inner_hashing.py. Also added: 1) warmboot finalizer checker to pbh tests with WR. 2)removed acl dependency in WR lag test Signed-off-by: Anton <antonh@nvidia.com>
1 parent 699a189 commit 2159aeb

File tree

4 files changed

+179
-23
lines changed

4 files changed

+179
-23
lines changed

tests/ecmp/inner_hashing/conftest.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
VXLAN_PORT = 13330
3030
DUT_VXLAN_PORT_JSON_FILE = '/tmp/vxlan.switch.json'
3131

32+
ACL_DEPENDENCY_TABLES = ["EVERFLOW","EVERFLOWV6"]
33+
3234
T0_VLAN = "1000"
3335
IP_VERSIONS_LIST = ["ipv4", "ipv6"]
3436
OUTER_ENCAP_FORMATS = ["vxlan", "nvgre"]
@@ -275,6 +277,21 @@ def inner_ipver(request):
275277
return request.param
276278

277279

280+
@pytest.fixture(scope="module")
281+
def remove_lag_acl_dependency(duthost):
282+
duthost.command("cp /etc/sonic/config_db.json /etc/sonic/config_db.json.back")
283+
284+
for acl_table in ACL_DEPENDENCY_TABLES:
285+
duthost.command("sudo config acl remove table {}".format(acl_table))
286+
287+
yield
288+
289+
duthost.shell("cat /etc/sonic/config_db.json.back | jq 'with_entries(select(.key==\"ACL_TABLE\"))' > /tmp/acl.json")
290+
duthost.command("sudo config load -y /tmp/acl.json")
291+
duthost.command("sudo config save -y")
292+
duthost.command("rm -f /etc/sonic/config_db.json.back")
293+
294+
278295
@pytest.fixture(scope="module")
279296
def config_pbh_table_lag(duthost, lag_port_map):
280297
logging.info("Create PBH table: {}".format(TABLE_NAME))
@@ -458,3 +475,105 @@ def remove_lag_config(duthost, lag_port_map, lag_ip_map):
458475
duthost.shell('sudo config portchannel member del {} {}'.format(lag_port, port_name))
459476
duthost.shell('sudo config portchannel del {}'.format(lag_port))
460477
duthost.shell('sudo config vlan member add {} {} --untagged'.format(T0_VLAN, port_name))
478+
479+
480+
@pytest.fixture(scope="function")
481+
def update_rule(duthost, outer_ipver, inner_ipver):
482+
'''
483+
This function will update the rules: original, according to given outer/inner IP ver, and its mirrored rule
484+
(ipv4 -> ipv6 and vice versa).
485+
The rules will perform each other's actions.
486+
For example, when given the ipv4-ipv4 rule:
487+
Before:
488+
RULE MATCH
489+
vxlan_ipv4_ipv4 ether_type: 0x0800
490+
ip_protocol: 0x11
491+
l4_dst_port: 0x3412
492+
inner_ether_type: 0x0800
493+
494+
vxlan_ipv6_ipv6 ether_type: 0x86dd
495+
ipv6_next_header: 0x11
496+
l4_dst_port: 0x3412
497+
inner_ether_type: 0x86dd
498+
After:
499+
vxlan_ipv4_ipv4 ether_type: 0x86dd
500+
ipv6_next_header: 0x11
501+
l4_dst_port: 0x3412
502+
inner_ether_type: 0x86dd
503+
504+
vxlan_ipv6_ipv6 ether_type: 0x0800
505+
ip_protocol: 0x11
506+
l4_dst_port: 0x3412
507+
inner_ether_type: 0x0800
508+
'''
509+
510+
def update_rule_del(outer_ipver, inner_ipver, option):
511+
rule_name = encap_format + '_{}_{}'.format(outer_ipver, inner_ipver)
512+
cmd = 'config pbh rule update field del {} {} --{}'.format(TABLE_NAME, rule_name, option)
513+
duthost.command(cmd)
514+
515+
def update_rule_set(outer_ipver, inner_ipver, set_dict):
516+
rule_name = encap_format + '_{}_{}'.format(outer_ipver, inner_ipver)
517+
cmd = 'config pbh rule update field set {} {}'.format(TABLE_NAME, rule_name)
518+
for option, value in set_dict.items():
519+
cmd += ' --{} {}'.format(option, value)
520+
duthost.command(cmd)
521+
522+
# define original and swapped keys and values
523+
if outer_ipver == "ipv4":
524+
swapped_outer_ipver = "ipv6"
525+
ether_type = V4_ETHER_TYPE
526+
swapped_ether_type = V6_ETHER_TYPE
527+
prot = 'ip-protocol'
528+
swapped_prot = 'ipv6-next-header'
529+
else:
530+
swapped_outer_ipver = "ipv4"
531+
ether_type = V6_ETHER_TYPE
532+
swapped_ether_type = V4_ETHER_TYPE
533+
prot = 'ipv6-next-header'
534+
swapped_prot = 'ip-protocol'
535+
536+
if inner_ipver == "ipv4":
537+
inner_ether_type = V4_ETHER_TYPE
538+
swapped_inner_ether_type = V6_ETHER_TYPE
539+
swapped_inner_ipver = "ipv6"
540+
else:
541+
inner_ether_type = V6_ETHER_TYPE
542+
swapped_inner_ether_type = V4_ETHER_TYPE
543+
swapped_inner_ipver = "ipv4"
544+
545+
update_set_dict = {prot: '',
546+
'ether-type': ether_type,
547+
'inner-ether-type': inner_ether_type}
548+
swapped_update_set_dict = {swapped_prot: '',
549+
'ether-type': swapped_ether_type,
550+
'inner-ether-type': swapped_inner_ether_type}
551+
552+
logging.info(" Update Rules. Swap the configuration of {}_{} and {}_{} rules"
553+
.format(outer_ipver, inner_ipver, swapped_outer_ipver, swapped_inner_ipver))
554+
for encap_format in OUTER_ENCAP_FORMATS:
555+
prot_value = VXLAN_IP_PROTOCOL if encap_format == 'vxlan' else NVGRE_IP_PROTOCOL
556+
557+
update_set_dict.update({prot: prot_value})
558+
swapped_update_set_dict.update({swapped_prot: prot_value})
559+
560+
update_rule_del(outer_ipver, inner_ipver, prot)
561+
update_rule_set(outer_ipver, inner_ipver, swapped_update_set_dict)
562+
563+
update_rule_del(swapped_outer_ipver, swapped_inner_ipver, swapped_prot)
564+
update_rule_set(swapped_outer_ipver, swapped_inner_ipver, update_set_dict)
565+
566+
yield
567+
568+
logging.info(" Restore Updated Rules ")
569+
for encap_format in OUTER_ENCAP_FORMATS:
570+
prot_value = VXLAN_IP_PROTOCOL if encap_format == 'vxlan' else NVGRE_IP_PROTOCOL
571+
572+
update_set_dict.update({prot: prot_value})
573+
swapped_update_set_dict.update({swapped_prot: prot_value})
574+
575+
update_rule_del(outer_ipver, inner_ipver, swapped_prot)
576+
update_rule_set(outer_ipver, inner_ipver, update_set_dict)
577+
578+
update_rule_del(swapped_outer_ipver, swapped_inner_ipver, prot)
579+
update_rule_set(swapped_outer_ipver, swapped_inner_ipver, swapped_update_set_dict)

tests/ecmp/inner_hashing/test_inner_hashing.py

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
import logging
66
import pytest
77
import allure
8+
import random
89

910
from datetime import datetime
1011
from retry.api import retry_call
1112
from tests.ptf_runner import ptf_runner
1213
from tests.ecmp.inner_hashing.conftest import get_src_dst_ip_range, FIB_INFO_FILE_DST,\
13-
VXLAN_PORT, PTF_QLEN, check_pbh_counters, OUTER_ENCAP_FORMATS, NVGRE_TNI
14+
VXLAN_PORT, PTF_QLEN, check_pbh_counters, OUTER_ENCAP_FORMATS, NVGRE_TNI, IP_VERSIONS_LIST
1415

1516
logger = logging.getLogger(__name__)
1617

@@ -19,6 +20,9 @@
1920
pytest.mark.asic('mellanox')
2021
]
2122

23+
update_outer_ipver = random.choice(IP_VERSIONS_LIST)
24+
update_inner_ipver = random.choice(IP_VERSIONS_LIST)
25+
2226

2327
@pytest.mark.dynamic_config
2428
class TestDynamicInnerHashing():
@@ -31,7 +35,7 @@ def setup_dynamic_pbh(self, request):
3135
request.getfixturevalue("config_hash")
3236
request.getfixturevalue("config_rules")
3337

34-
def test_inner_hashing(self, hash_keys, ptfhost, outer_ipver, inner_ipver, router_mac, vlan_ptf_ports, symmetric_hashing, duthost):
38+
def test_inner_hashing(self, request, hash_keys, ptfhost, outer_ipver, inner_ipver, router_mac, vlan_ptf_ports, symmetric_hashing, duthost):
3539
logging.info("Executing dynamic inner hash test for outer {} and inner {} with symmetric_hashing set to {}"
3640
.format(outer_ipver, inner_ipver, str(symmetric_hashing)))
3741
with allure.step('Run ptf test InnerHashTest'):
@@ -45,32 +49,64 @@ def test_inner_hashing(self, hash_keys, ptfhost, outer_ipver, inner_ipver, route
4549
balancing_test_times = 150
4650
balancing_range = 0.3
4751

52+
ptf_params = {"fib_info": FIB_INFO_FILE_DST,
53+
"router_mac": router_mac,
54+
"src_ports": vlan_ptf_ports,
55+
"hash_keys": hash_keys,
56+
"vxlan_port": VXLAN_PORT,
57+
"inner_src_ip_range": ",".join(inner_src_ip_range),
58+
"inner_dst_ip_range": ",".join(inner_dst_ip_range),
59+
"outer_src_ip_range": ",".join(outer_src_ip_range),
60+
"outer_dst_ip_range": ",".join(outer_dst_ip_range),
61+
"balancing_test_times": balancing_test_times,
62+
"balancing_range": balancing_range,
63+
"outer_encap_formats": OUTER_ENCAP_FORMATS,
64+
"nvgre_tni": NVGRE_TNI,
65+
"symmetric_hashing": symmetric_hashing}
66+
67+
duthost.shell("sonic-clear pbh statistics")
4868
ptf_runner(ptfhost,
4969
"ptftests",
5070
"inner_hash_test.InnerHashTest",
5171
platform_dir="ptftests",
52-
params={"fib_info": FIB_INFO_FILE_DST,
53-
"router_mac": router_mac,
54-
"src_ports": vlan_ptf_ports,
55-
"hash_keys": hash_keys,
56-
"vxlan_port": VXLAN_PORT,
57-
"inner_src_ip_range": ",".join(inner_src_ip_range),
58-
"inner_dst_ip_range": ",".join(inner_dst_ip_range),
59-
"outer_src_ip_range": ",".join(outer_src_ip_range),
60-
"outer_dst_ip_range": ",".join(outer_dst_ip_range),
61-
"balancing_test_times": balancing_test_times,
62-
"balancing_range": balancing_range,
63-
"outer_encap_formats": OUTER_ENCAP_FORMATS,
64-
"nvgre_tni": NVGRE_TNI,
65-
"symmetric_hashing": symmetric_hashing},
72+
params=ptf_params,
6673
log_file=log_file,
6774
qlen=PTF_QLEN,
6875
socket_recv_size=16384)
6976

70-
retry_call(check_pbh_counters,
71-
fargs=[duthost, outer_ipver, inner_ipver, balancing_test_times, symmetric_hashing, hash_keys],
72-
tries=5,
73-
delay=5)
77+
retry_call(check_pbh_counters,
78+
fargs=[duthost, outer_ipver, inner_ipver, balancing_test_times, symmetric_hashing, hash_keys],
79+
tries=5,
80+
delay=5)
81+
82+
if update_outer_ipver == outer_ipver and update_inner_ipver == inner_ipver:
83+
logging.info("Validate dynamic inner hash Edit Flow for outer {} and inner {} ip versions with"
84+
" symmetric_hashing set to {}".format(outer_ipver, inner_ipver, str(symmetric_hashing)))
85+
86+
swapped_outer_ipver = "ipv6" if outer_ipver == "ipv4" else "ipv4"
87+
swapped_inner_ipver = "ipv6" if inner_ipver == "ipv4" else "ipv4"
88+
with allure.step('Swap configuration of rules {}_{} with {}_{}'.format(outer_ipver,
89+
inner_ipver,
90+
swapped_outer_ipver,
91+
swapped_inner_ipver)):
92+
request.getfixturevalue("update_rule")
93+
94+
with allure.step('Run again the ptf test InnerHashTest after updating the rules'):
95+
duthost.shell("sonic-clear pbh statistics")
96+
ptf_runner(ptfhost,
97+
"ptftests",
98+
"inner_hash_test.InnerHashTest",
99+
platform_dir="ptftests",
100+
params=ptf_params,
101+
log_file=log_file,
102+
qlen=PTF_QLEN,
103+
socket_recv_size=16384)
104+
105+
retry_call(check_pbh_counters,
106+
fargs=[duthost, swapped_outer_ipver, swapped_inner_ipver,
107+
balancing_test_times, symmetric_hashing, hash_keys],
108+
tries=5,
109+
delay=5)
74110

75111

76112
@pytest.mark.static_config

tests/ecmp/inner_hashing/test_wr_inner_hashing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_inner_hashing(self, duthost, hash_keys, ptfhost, outer_ipver, inner_ipv
4747
balancing_test_times = 200
4848
balancing_range = 0.3
4949

50-
reboot_thr = threading.Thread(target=reboot, args=(duthost, localhost, 'warm',))
50+
reboot_thr = threading.Thread(target=reboot, args=(duthost, localhost, 'warm', 10, 0, 0, True, True,))
5151
reboot_thr.start()
5252

5353
ptf_runner(ptfhost,
@@ -88,7 +88,7 @@ def test_inner_hashing(self, duthost, hash_keys, ptfhost, outer_ipver, inner_ipv
8888
outer_src_ip_range, outer_dst_ip_range = get_src_dst_ip_range(outer_ipver)
8989
inner_src_ip_range, inner_dst_ip_range = get_src_dst_ip_range(inner_ipver)
9090

91-
reboot_thr = threading.Thread(target=reboot, args=(duthost, localhost, 'warm',))
91+
reboot_thr = threading.Thread(target=reboot, args=(duthost, localhost, 'warm', 10, 0, 0, True, True,))
9292
reboot_thr.start()
9393

9494
ptf_runner(ptfhost,

tests/ecmp/inner_hashing/test_wr_inner_hashing_lag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TestWRDynamicInnerHashingLag():
2323
@pytest.fixture(scope="class", autouse=True)
2424
def setup_dynamic_pbh(self, request):
2525
with allure.step('Add required LAG config'):
26+
request.getfixturevalue("remove_lag_acl_dependency")
2627
request.getfixturevalue("config_lag_ports")
2728
with allure.step('Config Dynamic PBH'):
2829
request.getfixturevalue("config_pbh_table_lag")
@@ -48,7 +49,7 @@ def test_inner_hashing(self, duthost, hash_keys, ptfhost, outer_ipver, inner_ipv
4849
balancing_test_times = 200
4950
balancing_range = 0.3
5051

51-
reboot_thr = threading.Thread(target=reboot, args=(duthost, localhost, 'warm',))
52+
reboot_thr = threading.Thread(target=reboot, args=(duthost, localhost, 'warm', 10, 0, 0, True, True,))
5253
reboot_thr.start()
5354

5455
ptf_runner(ptfhost,

0 commit comments

Comments
 (0)