Skip to content

Commit

Permalink
[vstest/subintf] Update vs tests to validate physical port host inter…
Browse files Browse the repository at this point in the history
…face vlan tag attribute (sonic-net#1634)

* Check vlan tag attribute for parent port being physical port

Signed-off-by: Wenda Ni <wonda.ni@gmail.com>
  • Loading branch information
wendani authored Feb 17, 2021
1 parent 459848f commit c49668e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/test_sub_port_intf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
CFG_VLAN_SUB_INTF_TABLE_NAME = "VLAN_SUB_INTERFACE"
CFG_PORT_TABLE_NAME = "PORT"
CFG_LAG_TABLE_NAME = "PORTCHANNEL"
CFG_LAG_MEMBER_TABLE_NAME = "PORTCHANNEL_MEMBER"

STATE_PORT_TABLE_NAME = "PORT_TABLE"
STATE_LAG_TABLE_NAME = "LAG_TABLE"
Expand All @@ -24,6 +25,8 @@
ASIC_NEXT_HOP_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP"
ASIC_NEXT_HOP_GROUP_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP_GROUP"
ASIC_NEXT_HOP_GROUP_MEMBER_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MEMBER"
ASIC_LAG_MEMBER_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER"
ASIC_HOSTIF_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF"

ADMIN_STATUS = "admin_status"

Expand All @@ -36,6 +39,7 @@
class TestSubPortIntf(object):
SUB_PORT_INTERFACE_UNDER_TEST = "Ethernet64.10"
LAG_SUB_PORT_INTERFACE_UNDER_TEST = "PortChannel1.20"
LAG_MEMBERS_UNDER_TEST = ["Ethernet68", "Ethernet72"]

IPV4_ADDR_UNDER_TEST = "10.0.0.33/31"
IPV4_TOME_UNDER_TEST = "10.0.0.33/32"
Expand Down Expand Up @@ -91,6 +95,13 @@ def create_sub_port_intf_profile(self, sub_port_intf_name):

self.config_db.create_entry(CFG_VLAN_SUB_INTF_TABLE_NAME, sub_port_intf_name, fvs)

def add_lag_members(self, lag, members):
fvs = {"NULL": "NULL"}

for member in members:
key = "{}|{}".format(lag, member)
self.config_db.create_entry(CFG_LAG_MEMBER_TABLE_NAME, key, fvs)

def add_sub_port_intf_ip_addr(self, sub_port_intf_name, ip_addr):
fvs = {"NULL": "NULL"}

Expand All @@ -102,6 +113,11 @@ def set_sub_port_intf_admin_status(self, sub_port_intf_name, status):

self.config_db.create_entry(CFG_VLAN_SUB_INTF_TABLE_NAME, sub_port_intf_name, fvs)

def remove_lag_members(self, lag, members):
for member in members:
key = "{}|{}".format(lag, member)
self.config_db.delete_entry(CFG_LAG_MEMBER_TABLE_NAME, key)

def remove_sub_port_intf_profile(self, sub_port_intf_name):
self.config_db.delete_entry(CFG_VLAN_SUB_INTF_TABLE_NAME, sub_port_intf_name)

Expand Down Expand Up @@ -186,13 +202,19 @@ def _test_sub_port_intf_creation(self, dvs, sub_port_intf_name):
vlan_id = substrs[1]
if parent_port.startswith(ETHERNET_PREFIX):
state_tbl_name = STATE_PORT_TABLE_NAME
phy_ports = [parent_port]
else:
assert parent_port.startswith(LAG_PREFIX)
state_tbl_name = STATE_LAG_TABLE_NAME
phy_ports = self.LAG_MEMBERS_UNDER_TEST

old_rif_oids = self.get_oids(ASIC_RIF_TABLE)

self.set_parent_port_admin_status(dvs, parent_port, "up")
# Add lag members to test physical port host interface vlan tag attribute
if parent_port.startswith(LAG_PREFIX):
self.add_lag_members(parent_port, self.LAG_MEMBERS_UNDER_TEST)
self.asic_db.wait_for_n_keys(ASIC_LAG_MEMBER_TABLE, len(self.LAG_MEMBERS_UNDER_TEST))
self.create_sub_port_intf_profile(sub_port_intf_name)

# Verify that sub port interface state ok is pushed to STATE_DB by Intfmgrd
Expand All @@ -218,10 +240,23 @@ def _test_sub_port_intf_creation(self, dvs, sub_port_intf_name):
rif_oid = self.get_newly_created_oid(ASIC_RIF_TABLE, old_rif_oids)
self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict)

# Verify physical port host interface vlan tag attribute
fv_dict = {
"SAI_HOSTIF_ATTR_VLAN_TAG": "SAI_HOSTIF_VLAN_TAG_KEEP",
}
for phy_port in phy_ports:
hostif_oid = dvs.asicdb.hostifnamemap[phy_port]
self.check_sub_port_intf_fvs(self.asic_db, ASIC_HOSTIF_TABLE, hostif_oid, fv_dict)

# Remove a sub port interface
self.remove_sub_port_intf_profile(sub_port_intf_name)
self.check_sub_port_intf_profile_removal(rif_oid)

# Remove lag members from lag parent port
if parent_port.startswith(LAG_PREFIX):
self.remove_lag_members(parent_port, self.LAG_MEMBERS_UNDER_TEST)
self.asic_db.wait_for_n_keys(ASIC_LAG_MEMBER_TABLE, 0)

def test_sub_port_intf_creation(self, dvs):
self.connect_dbs(dvs)

Expand Down Expand Up @@ -427,13 +462,19 @@ def _test_sub_port_intf_removal(self, dvs, sub_port_intf_name):
parent_port = substrs[0]
if parent_port.startswith(ETHERNET_PREFIX):
state_tbl_name = STATE_PORT_TABLE_NAME
phy_ports = [parent_port]
else:
assert parent_port.startswith(LAG_PREFIX)
state_tbl_name = STATE_LAG_TABLE_NAME
phy_ports = self.LAG_MEMBERS_UNDER_TEST

old_rif_oids = self.get_oids(ASIC_RIF_TABLE)

self.set_parent_port_admin_status(dvs, parent_port, "up")
# Add lag members to test physical port host interface vlan tag attribute
if parent_port.startswith(LAG_PREFIX):
self.add_lag_members(parent_port, self.LAG_MEMBERS_UNDER_TEST)
self.asic_db.wait_for_n_keys(ASIC_LAG_MEMBER_TABLE, len(self.LAG_MEMBERS_UNDER_TEST))
self.create_sub_port_intf_profile(sub_port_intf_name)

self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST)
Expand Down Expand Up @@ -471,6 +512,19 @@ def _test_sub_port_intf_removal(self, dvs, sub_port_intf_name):
# Verify that sub port router interface entry is removed from ASIC_DB
self.check_sub_port_intf_key_removal(self.asic_db, ASIC_RIF_TABLE, rif_oid)

# Verify physical port host interface vlan tag attribute
fv_dict = {
"SAI_HOSTIF_ATTR_VLAN_TAG": "SAI_HOSTIF_VLAN_TAG_STRIP",
}
for phy_port in phy_ports:
hostif_oid = dvs.asicdb.hostifnamemap[phy_port]
self.check_sub_port_intf_fvs(self.asic_db, ASIC_HOSTIF_TABLE, hostif_oid, fv_dict)

# Remove lag members from lag parent port
if parent_port.startswith(LAG_PREFIX):
self.remove_lag_members(parent_port, self.LAG_MEMBERS_UNDER_TEST)
self.asic_db.wait_for_n_keys(ASIC_LAG_MEMBER_TABLE, 0)

def test_sub_port_intf_removal(self, dvs):
self.connect_dbs(dvs)

Expand Down

0 comments on commit c49668e

Please sign in to comment.