Skip to content

Commit 9163f9d

Browse files
andriymoroz-mlnxRodny Molina
authored andcommitted
Add speed and buffer set test (sonic-net#432)
* Add speed and buffer set test Signed-off-by: Andriy Moroz <c_andriym@mellanox.com> * Add some comments to the test Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
1 parent 239bd22 commit 9163f9d

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

tests/test_speed.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""
2+
test_speed.py implements list of tests to check speed set on
3+
interfaces and correct buffer manager behavior on speed change
4+
5+
These tests need to be run in prepared environment and with the
6+
SONiC version compiled for PLATFORM=vs
7+
8+
See README.md for details
9+
"""
10+
from swsscommon import swsscommon
11+
import time
12+
import re
13+
import json
14+
import os
15+
16+
class TestSpeedSet(object):
17+
num_ports = 32
18+
def test_SpeedAndBufferSet(self, dvs):
19+
speed_list = ['50000', '25000', '40000', '10000', '100000']
20+
21+
cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0)
22+
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
23+
cfg_port_table = swsscommon.Table(cdb, "PORT", '|')
24+
cfg_buffer_profile_table = swsscommon.Table(cdb, "BUFFER_PROFILE", '|')
25+
cfg_buffer_pg_table = swsscommon.Table(cdb, "BUFFER_PG", '|')
26+
asic_port_table = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_PORT")
27+
asic_profile_table = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_BUFFER_PROFILE")
28+
29+
buffer_profiles = cfg_buffer_profile_table.getKeys()
30+
expected_buffer_profiles_num = len(buffer_profiles)
31+
# buffers.json used for the test defines 7 static profiles:
32+
# "ingress_lossless_profile"
33+
# "ingress_lossy_profile"
34+
# "egress_lossless_profile"
35+
# "egress_lossy_profile"
36+
# "pg_lossy_profile"
37+
# "q_lossless_profile"
38+
# "q_lossy_profile"
39+
# check if they get the DB
40+
assert expected_buffer_profiles_num == 7
41+
# and if they were successfully created on ASIC
42+
assert len(asic_profile_table.getKeys()) == expected_buffer_profiles_num
43+
44+
for speed in speed_list:
45+
fvs = swsscommon.FieldValuePairs([("speed", speed)])
46+
# set same speed on all ports
47+
for i in range(0, self.num_ports):
48+
cfg_port_table.set("Ethernet%d" % (i*4), fvs)
49+
50+
time.sleep(1) # let configuration settle down
51+
52+
# check the speed was set
53+
asic_port_records = asic_port_table.getKeys()
54+
assert len(asic_port_records) == (self.num_ports + 1) # +CPU port
55+
num_set = 0
56+
for k in asic_port_records:
57+
(status, fvs) = asic_port_table.get(k)
58+
assert status == True
59+
for fv in fvs:
60+
if fv[0] == "SAI_PORT_ATTR_SPEED":
61+
assert fv[1] == speed
62+
num_set += 1
63+
# make sure speed is set for all "num_ports" ports
64+
assert num_set == self.num_ports
65+
66+
# check number of created profiles
67+
expected_buffer_profiles_num += 1 # new speed should add new PG profile
68+
current_buffer_profiles = cfg_buffer_profile_table.getKeys()
69+
assert len(current_buffer_profiles) == expected_buffer_profiles_num
70+
# make sure the same number of profiles are created on ASIC
71+
assert len(asic_profile_table.getKeys()) == expected_buffer_profiles_num
72+
73+
# check new profile name
74+
expected_new_profile_name = "pg_lossless_%s_300m_profile" % speed
75+
assert current_buffer_profiles.index(expected_new_profile_name) > -1
76+
77+
# check correct profile is set for all ports
78+
pg_tables = cfg_buffer_pg_table.getKeys()
79+
for i in range(0, self.num_ports):
80+
expected_pg_table = "Ethernet%d|3-4" % (i*4)
81+
assert pg_tables.index(expected_pg_table) > -1
82+
(status, fvs) = cfg_buffer_pg_table.get(expected_pg_table)
83+
for fv in fvs:
84+
if fv[0] == "profile":
85+
assert fv[1] == "[BUFFER_PROFILE|%s]" % expected_new_profile_name

0 commit comments

Comments
 (0)