Skip to content

Commit 127b197

Browse files
Add a test case to verify that BGP packets use queue7 (#8097)
* All control packets including BGP are expected to use Q7, separate from data packet queues * Check for q7 counters is not being done until regression due to sonic-net/sonic-swss#2143 is fixed Signed-off-by: Prabhat Aravind <[email protected]>
1 parent 1289427 commit 127b197

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

docs/testplan/BGP-queue-test-plan.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# BGP-queue test plan
2+
3+
* [Overview](#Overview)
4+
* [Scope](#Scope)
5+
* [Testbed](#Testbed)
6+
* [Setup configuration](#Setup%20configuration)
7+
* [Test cases](#Test%20cases)
8+
9+
## Overview
10+
The purpose is to make sure that BGP control packets use unicast queue 7 by default on all SONiC platforms.
11+
The test expects that basic BGP configuration for the test is pre-configured on SONiC device before test run.
12+
13+
### Scope
14+
The test is targeting a running SONiC system with fully functioning configuration. The purpose of the test is to verify BGP control packets use egress queue 7 on SONiC platforms.
15+
16+
### Testbed
17+
The test could run on any testbed.
18+
19+
## Setup configuration
20+
This test requires BGP neighbors to be configured and established before the test run.
21+
22+
## Test
23+
The test will verify that all BGP packets use unicast queue 7 by default. It is to be noted that if BGP sessions are established over PortChannels, LACP packets will also use the same unicast queue 7, but that does not impact the test functionality.
24+
25+
## Test cases
26+
### Test case test_bgp_queue
27+
#### Test steps
28+
* Clear all queue counters using "sonic-clear counters" command
29+
* Generate a mapping of neighbors to the corresponding interfaces/ports using ARP/NDP entries
30+
* For all "established" BGP sessions, run "show queue counters" on the corresponding port
31+
* Verify that unicast queue 7 counters are non-zero and that unicast queue 0 counters are zero

tests/bgp/test_bgp_queue.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import time
2+
import pytest
3+
import logging
4+
5+
logger = logging.getLogger(__name__)
6+
7+
pytestmark = [
8+
pytest.mark.topology('any'),
9+
pytest.mark.device_type('vs')
10+
]
11+
12+
13+
def clear_queue_counters(duthost):
14+
duthost.shell("sonic-clear queuecounters")
15+
16+
17+
def get_queue_counters(duthost, port, queue):
18+
"""
19+
Return the counter for a given queue in given port
20+
"""
21+
cmd = "show queue counters {}".format(port)
22+
output = duthost.shell(cmd)['stdout_lines']
23+
txq = "UC{}".format(queue)
24+
for line in output:
25+
fields = line.split()
26+
if fields[1] == txq:
27+
return int(fields[2])
28+
return -1
29+
30+
31+
def test_bgp_queues(duthosts, enum_frontend_dut_hostname, enum_asic_index, tbinfo):
32+
duthost = duthosts[enum_frontend_dut_hostname]
33+
clear_queue_counters(duthost)
34+
time.sleep(10)
35+
bgp_facts = duthost.bgp_facts(instance_id=enum_asic_index)['ansible_facts']
36+
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
37+
38+
arp_dict = {}
39+
ndp_dict = {}
40+
processed_intfs = set()
41+
show_arp = duthost.command('show arp')
42+
show_ndp = duthost.command('show ndp')
43+
for arp_entry in show_arp['stdout_lines']:
44+
items = arp_entry.split()
45+
if (len(items) != 4):
46+
continue
47+
ip = items[0]
48+
iface = items[2]
49+
arp_dict[ip] = iface
50+
for ndp_entry in show_ndp['stdout_lines']:
51+
items = ndp_entry.split()
52+
if (len(items) != 5):
53+
continue
54+
ip = items[0]
55+
iface = items[2]
56+
ndp_dict[ip] = iface
57+
58+
for k, v in list(bgp_facts['bgp_neighbors'].items()):
59+
# Only consider established bgp sessions
60+
if v['state'] == 'established':
61+
assert (k in arp_dict.keys() or k in ndp_dict.keys())
62+
if k in arp_dict:
63+
ifname = arp_dict[k].split('.', 1)[0]
64+
else:
65+
ifname = ndp_dict[k].split('.', 1)[0]
66+
if ifname in processed_intfs:
67+
continue
68+
if (ifname.startswith("PortChannel")):
69+
for port in mg_facts['minigraph_portchannels'][ifname]['members']:
70+
logger.info("PortChannel '{}' : port {}".format(ifname, port))
71+
for q in range(0, 7):
72+
assert(get_queue_counters(duthost, port, q) == 0)
73+
else:
74+
logger.info(ifname)
75+
for q in range(0, 7):
76+
assert(get_queue_counters(duthost, ifname, q) == 0)
77+
processed_intfs.add(ifname)

0 commit comments

Comments
 (0)