forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the pfcwd test cases according to the new implement of the pfc…
…wd. (sonic-net#12733) Update the pfcwd test cases according to the new implement of the pfcwd After the feature is completed, it criteria to trigger the pfcwd is much more strict than previous on Nvidia platform, So adjust the test case to properly trigger the pfcwd. The solution is to send background traffic during the pfc frame is sent from the fanout.
- Loading branch information
Showing
7 changed files
with
226 additions
and
46 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
ansible/roles/test/files/ptftests/py3/pfc_wd_background_traffic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import ptf | ||
import logging | ||
from ptf.base_tests import BaseTest | ||
import time | ||
from ptf.testutils import test_params_get, simple_ip_packet, send_packet | ||
|
||
|
||
class PfcWdBackgroundTrafficTest(BaseTest): | ||
def __init__(self): | ||
BaseTest.__init__(self) | ||
self.test_params = test_params_get() | ||
|
||
def setUp(self): | ||
self.dataplane = ptf.dataplane_instance | ||
self.router_mac = self.test_params['router_mac'] | ||
self.pkt_count = int(self.test_params['pkt_count']) | ||
self.src_ports = self.test_params['src_ports'] | ||
self.dst_ports = self.test_params['dst_ports'] | ||
self.src_ips = self.test_params['src_ips'] | ||
self.dst_ips = self.test_params['dst_ips'] | ||
self.queues = self.test_params['queues'] if 'queues' in self.test_params else [3, 4] | ||
self.bidirection = self.test_params['bidirection'] if 'bidirection' in self.test_params else True | ||
|
||
def runTest(self): | ||
ttl = 64 | ||
pkts_dict = {} | ||
if len(self.dst_ports) > len(self.src_ports): | ||
self.src_ports.append(self.src_ports[0]) | ||
self.src_ips.append(self.src_ips[0]) | ||
for i in range(len(self.src_ports)): | ||
src_port = int(self.src_ports[i]) | ||
dst_port = int(self.dst_ports[i]) | ||
if src_port not in pkts_dict: | ||
pkts_dict[src_port] = [] | ||
if dst_port not in pkts_dict: | ||
pkts_dict[dst_port] = [] | ||
src_mac = self.dataplane.get_mac(0, src_port) | ||
dst_mac = self.dataplane.get_mac(0, dst_port) | ||
for queue in self.queues: | ||
print(f"traffic from {src_port} to {dst_port}: {queue} ") | ||
logging.info(f"traffic from {src_port} to {dst_port}: {queue} ") | ||
pkt = simple_ip_packet( | ||
eth_src=src_mac, | ||
eth_dst=self.router_mac, | ||
ip_src=self.src_ips[i], | ||
ip_dst=self.dst_ips[i], | ||
ip_dscp=queue, | ||
ip_ecn=0, | ||
ip_ttl=ttl | ||
) | ||
pkts_dict[src_port].append(pkt) | ||
if self.bidirection: | ||
print(f"traffic from {dst_port} to {src_port}: {queue} ") | ||
logging.info(f"traffic from {dst_port} to {src_port}: {queue} ") | ||
pkt = simple_ip_packet( | ||
eth_src=dst_mac, | ||
eth_dst=self.router_mac, | ||
ip_src=self.dst_ips[i], | ||
ip_dst=self.src_ips[i], | ||
ip_dscp=queue, | ||
ip_ecn=0, | ||
ip_ttl=ttl | ||
) | ||
pkts_dict[dst_port].append(pkt) | ||
|
||
start = time.time() | ||
logging.info("Start to send the background traffic") | ||
print("Start to send the background traffic") | ||
timeout = 500 | ||
while True: | ||
for port, pkts in pkts_dict.items(): | ||
for pkt in pkts: | ||
send_packet(self, port, pkt, self.pkt_count) | ||
|
||
now = time.time() | ||
if now - start > timeout: | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.