Skip to content

Commit

Permalink
Updating LossyQueueVoq test for Cisco-8111 platform (#9323)
Browse files Browse the repository at this point in the history
* Updating LossyQueueVoq test for Cisco-8111 platform

* Fixing pre-commit error

* fixing pre-commit issue
  • Loading branch information
jsanghra authored Nov 21, 2023
1 parent 29035c3 commit 3e7561f
Showing 1 changed file with 24 additions and 58 deletions.
82 changes: 24 additions & 58 deletions tests/saitests/py3/sai_qos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
simple_arp_packet,
send_packet,
simple_tcp_packet,
simple_udp_packet,
simple_qinq_tcp_packet,
simple_ip_packet,
simple_ipv4ip_packet,
Expand Down Expand Up @@ -3746,36 +3745,6 @@ def setUp(self):
self.packet_length = 64
self.ttl = 64

def _build_testing_pkt(self, udp_dport):
return simple_udp_packet(pktlen=self.packet_length,
eth_dst=self.dst_port_mac,
eth_src=self.src_port_mac,
ip_src=self.src_port_ip,
ip_dst=self.dst_port_ip,
ip_tos=((self.dscp << 2) | self.ecn),
udp_sport=1024,
udp_dport=udp_dport,
ip_ecn=self.ecn,
ip_ttl=self.ttl)

def _get_rx_port(self, src_port_id, pkt):
masked_exp_pkt = Mask(pkt, ignore_extra_bytes=True)
masked_exp_pkt.set_do_not_care_scapy(scapy.Ether, "dst")
masked_exp_pkt.set_do_not_care_scapy(scapy.Ether, "src")
masked_exp_pkt.set_do_not_care_scapy(scapy.IP, "chksum")
masked_exp_pkt.set_do_not_care_scapy(scapy.IP, "ttl")
masked_exp_pkt.set_do_not_care_scapy(scapy.IP, "len")

send_packet(self, src_port_id, pkt, 1)

result = self.dataplane.poll(
device_number=0, exp_pkt=masked_exp_pkt, timeout=3)
if isinstance(result, self.dataplane.PollFailure):
self.fail("Expected packet was not received. Received on port:{} {}".format(
result.port, result.format()))

return result.port

def runTest(self):
print("dst_port_id: {}, src_port_id: {}".format(
self.dst_port_id, self.src_port_id), file=sys.stderr)
Expand All @@ -3784,20 +3753,15 @@ def runTest(self):
self.sonic_version)

# craft first udp packet with unique udp_dport for traffic to go through different flows
flow_1_udp = 2048
pkt = self._build_testing_pkt(flow_1_udp)
self.dst_port_id = self._get_rx_port(self.src_port_id, pkt)

# find out udp ports which use the same dst port in port-channel
udp_ports = []
max_iters = 50
for i in range(max_iters):
flow_2_udp = flow_1_udp + (10 * i)
pkt2 = self._build_testing_pkt(flow_2_udp)
dst_port_id_2 = self._get_rx_port(self.src_port_id, pkt2)
if dst_port_id_2 == self.dst_port_id:
udp_ports.append(flow_2_udp)
print("Found udp_ports {}".format(udp_ports), file=sys.stderr)
src_details = []
src_details.append((int(self.src_port_id),
self.src_port_ip,
self.dataplane.get_mac(0, int(self.src_port_id))))

pkt_list = get_multiple_flows(self, self.dst_port_mac, self.dst_port_id,
self.dst_port_ip, None, self.dscp, self.ecn,
self.ttl,
self.packet_length, src_details, 20)[int(self.src_port_id)]

xmit_counters_base, _ = sai_thrift_read_port_counters(self.dst_client, self.asic_type,
port_list['dst'][self.dst_port_id])
Expand All @@ -3811,14 +3775,16 @@ def runTest(self):

self.sai_thrift_port_tx_disable(self.dst_client, self.asic_type, [self.dst_port_id])

# First input packet of the list for src_port_id
first_pkt = pkt_list[0][0]
try:
# send packets to begin egress drop on flow1, requires sending the "single"
# flow packet count to cause a drop with 1 flow.
assert fill_leakout_plus_one(self, self.src_port_id, self.dst_port_id, pkt,
assert fill_leakout_plus_one(self, self.src_port_id, self.dst_port_id, first_pkt,
int(self.test_params['pg']), self.asic_type), \
"Failed to fill leakout on dest port {}".format(
self.dst_port_id)
send_packet(self, self.src_port_id, pkt,
send_packet(self, self.src_port_id, first_pkt,
self.pkts_num_trig_egr_drp)
time.sleep(2)
# Verify egress drop
Expand All @@ -3830,10 +3796,10 @@ def runTest(self):
self.dst_port_id)
xmit_counters_base = xmit_counters
# Find a separate flow that uses alternate queue
for flow_2_udp in udp_ports:
pkt2 = self._build_testing_pkt(flow_2_udp)
for index, (second_pkt, _, _) in enumerate(pkt_list):
# Start out with i=0 to match flow_1 to confirm drop
xmit_counters_base = xmit_counters
send_packet(self, self.src_port_id, pkt2, 1)
send_packet(self, self.src_port_id, second_pkt, 1)
time.sleep(2)
xmit_counters, _ = sai_thrift_read_port_counters(self.dst_client, self.asic_type,
port_list['dst'][self.dst_port_id])
Expand All @@ -3842,15 +3808,15 @@ def runTest(self):
"Egress drop counters were different at port {}, counts: {}".format(
self.dst_port_id, drop_counts)
drop_count = drop_counts[0]
if flow_2_udp == flow_1_udp:
if second_pkt == first_pkt:
assert drop_count == 1, "Failed to reproduce drop to detect alternate flow"
else:
assert drop_count in [0, 1], \
"Unexpected drop count when sending a single packet, drops {}".format(
drop_count)
if drop_count == 0:
print("Second flow detected on udp_dport {} in mode '{}'".format(
flow_2_udp, self.flow_config), file=sys.stderr)
print("Second flow detected on packet index {} in mode '{}'".format(
index, self.flow_config), file=sys.stderr)
assert self.flow_config == "separate", \
"Identified a second flow despite being in mode '{}'"\
.format(self.flow_config)
Expand All @@ -3870,7 +3836,7 @@ def runTest(self):
port_list['src'][self.src_port_id])
xmit_counters_base, _ = sai_thrift_read_port_counters(self.dst_client, self.asic_type,
port_list['dst'][self.dst_port_id])
assert fill_leakout_plus_one(self, self.src_port_id, self.dst_port_id, pkt,
assert fill_leakout_plus_one(self, self.src_port_id, self.dst_port_id, second_pkt,
int(self.test_params['pg']), self.asic_type), \
"Failed to fill leakout on dest port {}".format(
self.dst_port_id)
Expand All @@ -3884,8 +3850,8 @@ def runTest(self):
multi_flow_drop_pkt_count - 1 - margin
print("Sending {} packets on each of 2 streams to approach drop".format(
short_of_drop_npkts), file=sys.stderr)
send_packet(self, self.src_port_id, pkt, short_of_drop_npkts)
send_packet(self, self.src_port_id, pkt2, short_of_drop_npkts)
send_packet(self, self.src_port_id, first_pkt, short_of_drop_npkts)
send_packet(self, self.src_port_id, second_pkt, short_of_drop_npkts)
# allow enough time for counters to update
time.sleep(2)
recv_counters, _ = sai_thrift_read_port_counters(self.src_client, self.asic_type,
Expand All @@ -3910,8 +3876,8 @@ def runTest(self):
npkts = 1 + 2 * margin
print("Sending {} packets on 2 streams to trigger drop".format(
npkts), file=sys.stderr)
send_packet(self, self.src_port_id, pkt, npkts)
send_packet(self, self.src_port_id, pkt2, npkts)
send_packet(self, self.src_port_id, first_pkt, npkts)
send_packet(self, self.src_port_id, second_pkt, npkts)
# allow enough time for counters to update
time.sleep(2)
recv_counters, _ = sai_thrift_read_port_counters(
Expand Down

0 comments on commit 3e7561f

Please sign in to comment.