Skip to content

Commit

Permalink
Add speed and buffer set test
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
  • Loading branch information
andriymoroz-mlnx committed Jan 18, 2018
1 parent 13cb785 commit 97206b1
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/test_speed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from swsscommon import swsscommon
import time
import re
import json
import os

class TestSpeedSet(object):
num_ports = 32
def test_SpeedAndBufferSet(self, dvs):
speed_list = ['50000', '25000', '40000', '10000', '100000']

cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
cfg_port_table = swsscommon.Table(cdb, "PORT", '|')
cfg_buffer_profile_table = swsscommon.Table(cdb, "BUFFER_PROFILE", '|')
cfg_buffer_pg_table = swsscommon.Table(cdb, "BUFFER_PG", '|')
asic_port_table = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_PORT")
asic_profile_table = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_BUFFER_PROFILE")

buffer_profiles = cfg_buffer_profile_table.getKeys()
expected_buffer_profiles_num = len(buffer_profiles)
assert expected_buffer_profiles_num == 7
assert len(asic_profile_table.getKeys()) == expected_buffer_profiles_num

for speed in speed_list:
fvs = swsscommon.FieldValuePairs([("speed", speed)])
# set same speed on all ports
for i in range(0, self.num_ports):
cfg_port_table.set("Ethernet%d" % (i*4), fvs)

time.sleep(1) # let configuration settle down

# check the speed was set
asic_port_records = asic_port_table.getKeys()
assert len(asic_port_records) == (self.num_ports + 1) # +CPU port
num_set = 0
for k in asic_port_records:
(status, fvs) = asic_port_table.get(k)
assert status == True
for fv in fvs:
if fv[0] == "SAI_PORT_ATTR_SPEED":
assert fv[1] == speed
num_set += 1
# make sure speed is set for all "num_ports" ports
assert num_set == self.num_ports

# check number of created profiles
expected_buffer_profiles_num += 1 # new speed should add new PG profile
current_buffer_profiles = cfg_buffer_profile_table.getKeys()
assert len(current_buffer_profiles) == expected_buffer_profiles_num
# make sure the same number of profiles are created on ASIC
assert len(asic_profile_table.getKeys()) == expected_buffer_profiles_num

# check new profile name
expected_new_profile_name = "pg_lossless_%s_300m_profile" % speed
assert current_buffer_profiles.index(expected_new_profile_name) > -1

# check correct profile is set for all ports
pg_tables = cfg_buffer_pg_table.getKeys()
for i in range(0, self.num_ports):
expected_pg_table = "Ethernet%d|3-4" % (i*4)
assert pg_tables.index(expected_pg_table) > -1
(status, fvs) = cfg_buffer_pg_table.get(expected_pg_table)
for fv in fvs:
if fv[0] == "profile":
assert fv[1] == "[BUFFER_PROFILE|%s]" % expected_new_profile_name



0 comments on commit 97206b1

Please sign in to comment.