From d6236b519f2fc8db58b37a69dad2fda20c27127e Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Fri, 3 Apr 2020 02:25:57 -0700 Subject: [PATCH] [sub intf] Use m_lag_id to be the parent port object id when parent port is LAG (#1235) Fix to Azure/sonic-buildimage#4142 Add vs test on lag sub interface based on unconventional lag naming "PortChannel1.20" to fit the interface name within 15 characters Signed-off-by: Wenda Ni wonda.ni@gmail.com --- orchagent/portsorch.cpp | 16 ++- tests/test_sub_port_intf.py | 189 ++++++++++++++++++++++++------------ 2 files changed, 142 insertions(+), 63 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 4eadcf34f9e3..e98bff1ed871 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -588,7 +588,7 @@ bool PortsOrch::addSubPort(Port &port, const string &alias, const bool &adminUp, } if (vlan_id > MAX_VALID_VLAN_ID) { - SWSS_LOG_ERROR("sub interface %s Port object creation: invalid VLAN id %u", alias.c_str(), vlan_id); + SWSS_LOG_ERROR("sub interface %s Port object creation failed: invalid VLAN id %u", alias.c_str(), vlan_id); return false; } @@ -614,7 +614,19 @@ bool PortsOrch::addSubPort(Port &port, const string &alias, const bool &adminUp, p.m_mtu = parentPort.m_mtu; } - p.m_parent_port_id = parentPort.m_port_id; + switch (parentPort.m_type) + { + case Port::PHY: + p.m_parent_port_id = parentPort.m_port_id; + break; + case Port::LAG: + p.m_parent_port_id = parentPort.m_lag_id; + break; + default: + SWSS_LOG_ERROR("Sub interface %s Port object creation failed: \ + parent port %s of invalid type (must be physical port or LAG)", alias.c_str(), parentAlias.c_str()); + return false; + } p.m_vlan_info.vlan_id = vlan_id; parentPort.m_child_ports.insert(p.m_alias); diff --git a/tests/test_sub_port_intf.py b/tests/test_sub_port_intf.py index 1a4f6cef54d4..91ff9967ab85 100644 --- a/tests/test_sub_port_intf.py +++ b/tests/test_sub_port_intf.py @@ -6,8 +6,10 @@ CFG_VLAN_SUB_INTF_TABLE_NAME = "VLAN_SUB_INTERFACE" CFG_PORT_TABLE_NAME = "PORT" +CFG_LAG_TABLE_NAME = "PORTCHANNEL" STATE_PORT_TABLE_NAME = "PORT_TABLE" +STATE_LAG_TABLE_NAME = "LAG_TABLE" STATE_INTERFACE_TABLE_NAME = "INTERFACE_TABLE" APP_INTF_TABLE_NAME = "INTF_TABLE" @@ -17,10 +19,15 @@ ADMIN_STATUS = "admin_status" +ETHERNET_PREFIX = "Ethernet" +LAG_PREFIX = "PortChannel" + +VLAN_SUB_INTERFACE_SEPARATOR = "." + class TestSubPortIntf(object): - PHYSICAL_PORT_UNDER_TEST = "Ethernet64" SUB_PORT_INTERFACE_UNDER_TEST = "Ethernet64.10" + LAG_SUB_PORT_INTERFACE_UNDER_TEST = "PortChannel1.20" IPV4_ADDR_UNDER_TEST = "10.0.0.33/31" IPV4_TOME_UNDER_TEST = "10.0.0.33/32" @@ -36,12 +43,22 @@ def connect_dbs(self, dvs): self.appl_db = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0) self.asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) - def set_parent_port_admin_status(self, port_name, status): + def set_parent_port_admin_status(self, dvs, port_name, status): fvs = swsscommon.FieldValuePairs([(ADMIN_STATUS, status)]) - tbl = swsscommon.Table(self.config_db, CFG_PORT_TABLE_NAME) + if port_name.startswith(ETHERNET_PREFIX): + tbl_name = CFG_PORT_TABLE_NAME + else: + assert port_name.startswith(LAG_PREFIX) + tbl_name = CFG_LAG_TABLE_NAME + tbl = swsscommon.Table(self.config_db, tbl_name) tbl.set(port_name, fvs) + time.sleep(1) + # follow the treatment in TestSubPortIntf::set_admin_status + if tbl_name == CFG_LAG_TABLE_NAME: + dvs.runcmd("bash -c 'echo " + ("1" if status == "up" else "0") + \ + " > /sys/class/net/" + port_name + "/carrier'") time.sleep(1) def create_sub_port_intf_profile(self, sub_port_intf_name): @@ -72,7 +89,7 @@ def remove_sub_port_intf_profile(self, sub_port_intf_name): tbl = swsscommon.Table(self.config_db, CFG_VLAN_SUB_INTF_TABLE_NAME) tbl._del(sub_port_intf_name) - time.sleep(1) + time.sleep(2) def remove_sub_port_intf_ip_addr(self, sub_port_intf_name, ip_addr): tbl = swsscommon.Table(self.config_db, CFG_VLAN_SUB_INTF_TABLE_NAME) @@ -146,30 +163,37 @@ def check_sub_port_intf_route_entries_removal(self, removed_route_entries): route_entry = json.loads(raw_route_entry) assert route_entry["dest"] not in removed_route_entries - def test_sub_port_intf_creation(self, dvs): - self.connect_dbs(dvs) + def _test_sub_port_intf_creation(self, dvs, sub_port_intf_name): + substrs = sub_port_intf_name.split(VLAN_SUB_INTERFACE_SEPARATOR) + parent_port = substrs[0] + vlan_id = substrs[1] + if parent_port.startswith(ETHERNET_PREFIX): + state_tbl_name = STATE_PORT_TABLE_NAME + else: + assert parent_port.startswith(LAG_PREFIX) + state_tbl_name = STATE_LAG_TABLE_NAME old_rif_oids = self.get_oids(ASIC_RIF_TABLE) - self.set_parent_port_admin_status(self.PHYSICAL_PORT_UNDER_TEST, "up") - self.create_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.set_parent_port_admin_status(dvs, parent_port, "up") + self.create_sub_port_intf_profile(sub_port_intf_name) # Verify that sub port interface state ok is pushed to STATE_DB by Intfmgrd fv_dict = { "state": "ok", } - self.check_sub_port_intf_fvs(self.state_db, STATE_PORT_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST, fv_dict) + self.check_sub_port_intf_fvs(self.state_db, state_tbl_name, sub_port_intf_name, fv_dict) # Verify that sub port interface configuration is synced to APPL_DB INTF_TABLE by Intfmgrd fv_dict = { ADMIN_STATUS: "up", } - self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST, fv_dict) + self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, sub_port_intf_name, fv_dict) # Verify that a sub port router interface entry is created in ASIC_DB fv_dict = { "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_SUB_PORT", - "SAI_ROUTER_INTERFACE_ATTR_OUTER_VLAN_ID": "10", + "SAI_ROUTER_INTERFACE_ATTR_OUTER_VLAN_ID": "{}".format(vlan_id), "SAI_ROUTER_INTERFACE_ATTR_ADMIN_V4_STATE": "true", "SAI_ROUTER_INTERFACE_ATTR_ADMIN_V6_STATE": "true", "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100", @@ -178,18 +202,26 @@ def test_sub_port_intf_creation(self, dvs): self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) # Remove a sub port interface - self.remove_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.remove_sub_port_intf_profile(sub_port_intf_name) - def test_sub_port_intf_add_ip_addrs(self, dvs): + def test_sub_port_intf_creation(self, dvs): self.connect_dbs(dvs) + self._test_sub_port_intf_creation(dvs, self.SUB_PORT_INTERFACE_UNDER_TEST) + self._test_sub_port_intf_creation(dvs, self.LAG_SUB_PORT_INTERFACE_UNDER_TEST) + + def _test_sub_port_intf_add_ip_addrs(self, dvs, sub_port_intf_name): + substrs = sub_port_intf_name.split(VLAN_SUB_INTERFACE_SEPARATOR) + parent_port = substrs[0] + vlan_id = substrs[1] + old_rif_oids = self.get_oids(ASIC_RIF_TABLE) - self.set_parent_port_admin_status(self.PHYSICAL_PORT_UNDER_TEST, "up") - self.create_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.set_parent_port_admin_status(dvs, parent_port, "up") + self.create_sub_port_intf_profile(sub_port_intf_name) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) rif_oid = self.get_newly_created_oid(ASIC_RIF_TABLE, old_rif_oids) @@ -198,9 +230,9 @@ def test_sub_port_intf_add_ip_addrs(self, dvs): "state": "ok", } self.check_sub_port_intf_fvs(self.state_db, STATE_INTERFACE_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + "|" + self.IPV4_ADDR_UNDER_TEST, fv_dict) + sub_port_intf_name + "|" + self.IPV4_ADDR_UNDER_TEST, fv_dict) self.check_sub_port_intf_fvs(self.state_db, STATE_INTERFACE_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + "|" + self.IPV6_ADDR_UNDER_TEST, fv_dict) + sub_port_intf_name + "|" + self.IPV6_ADDR_UNDER_TEST, fv_dict) # Verify that ip address configuration is synced to APPL_DB INTF_TABLE by Intfmgrd fv_dict = { @@ -208,10 +240,10 @@ def test_sub_port_intf_add_ip_addrs(self, dvs): "family": "IPv4", } self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + ":" + self.IPV4_ADDR_UNDER_TEST, fv_dict) + sub_port_intf_name + ":" + self.IPV4_ADDR_UNDER_TEST, fv_dict) fv_dict["family"] = "IPv6" self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + ":" + self.IPV6_ADDR_UNDER_TEST, fv_dict) + sub_port_intf_name + ":" + self.IPV6_ADDR_UNDER_TEST, fv_dict) # Verify that an IPv4 ip2me route entry is created in ASIC_DB # Verify that an IPv4 subnet route entry is created in ASIC_DB @@ -220,26 +252,34 @@ def test_sub_port_intf_add_ip_addrs(self, dvs): self.check_sub_port_intf_route_entries() # Remove IP addresses - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) # Remove a sub port interface - self.remove_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.remove_sub_port_intf_profile(sub_port_intf_name) - def test_sub_port_intf_admin_status_change(self, dvs): + def test_sub_port_intf_add_ip_addrs(self, dvs): self.connect_dbs(dvs) + self._test_sub_port_intf_add_ip_addrs(dvs, self.SUB_PORT_INTERFACE_UNDER_TEST) + self._test_sub_port_intf_add_ip_addrs(dvs, self.LAG_SUB_PORT_INTERFACE_UNDER_TEST) + + def _test_sub_port_intf_admin_status_change(self, dvs, sub_port_intf_name): + substrs = sub_port_intf_name.split(VLAN_SUB_INTERFACE_SEPARATOR) + parent_port = substrs[0] + vlan_id = substrs[1] + old_rif_oids = self.get_oids(ASIC_RIF_TABLE) - self.set_parent_port_admin_status(self.PHYSICAL_PORT_UNDER_TEST, "up") - self.create_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.set_parent_port_admin_status(dvs, parent_port, "up") + self.create_sub_port_intf_profile(sub_port_intf_name) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) fv_dict = { ADMIN_STATUS: "up", } - self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST, fv_dict) + self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, sub_port_intf_name, fv_dict) fv_dict = { "SAI_ROUTER_INTERFACE_ATTR_ADMIN_V4_STATE": "true", @@ -250,13 +290,13 @@ def test_sub_port_intf_admin_status_change(self, dvs): self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) # Change sub port interface admin status to down - self.set_sub_port_intf_admin_status(self.SUB_PORT_INTERFACE_UNDER_TEST, "down") + self.set_sub_port_intf_admin_status(sub_port_intf_name, "down") # Verify that sub port interface admin status change is synced to APPL_DB INTF_TABLE by Intfmgrd fv_dict = { ADMIN_STATUS: "down", } - self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST, fv_dict) + self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, sub_port_intf_name, fv_dict) # Verify that sub port router interface entry in ASIC_DB has the updated admin status fv_dict = { @@ -268,13 +308,13 @@ def test_sub_port_intf_admin_status_change(self, dvs): self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) # Change sub port interface admin status to up - self.set_sub_port_intf_admin_status(self.SUB_PORT_INTERFACE_UNDER_TEST, "up") + self.set_sub_port_intf_admin_status(sub_port_intf_name, "up") # Verify that sub port interface admin status change is synced to APPL_DB INTF_TABLE by Intfmgrd fv_dict = { ADMIN_STATUS: "up", } - self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST, fv_dict) + self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, sub_port_intf_name, fv_dict) # Verify that sub port router interface entry in ASIC_DB has the updated admin status fv_dict = { @@ -286,34 +326,42 @@ def test_sub_port_intf_admin_status_change(self, dvs): self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) # Remove IP addresses - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) # Remove a sub port interface - self.remove_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.remove_sub_port_intf_profile(sub_port_intf_name) - def test_sub_port_intf_remove_ip_addrs(self, dvs): + def test_sub_port_intf_admin_status_change(self, dvs): self.connect_dbs(dvs) + self._test_sub_port_intf_admin_status_change(dvs, self.SUB_PORT_INTERFACE_UNDER_TEST) + self._test_sub_port_intf_admin_status_change(dvs, self.LAG_SUB_PORT_INTERFACE_UNDER_TEST) + + def _test_sub_port_intf_remove_ip_addrs(self, dvs, sub_port_intf_name): + substrs = sub_port_intf_name.split(VLAN_SUB_INTERFACE_SEPARATOR) + parent_port = substrs[0] + vlan_id = substrs[1] + old_rif_oids = self.get_oids(ASIC_RIF_TABLE) - self.set_parent_port_admin_status(self.PHYSICAL_PORT_UNDER_TEST, "up") - self.create_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.set_parent_port_admin_status(dvs, parent_port, "up") + self.create_sub_port_intf_profile(sub_port_intf_name) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) rif_oid = self.get_newly_created_oid(ASIC_RIF_TABLE, old_rif_oids) # Remove IPv4 address - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) # Verify that IPv4 address state ok is removed from STATE_DB INTERFACE_TABLE by Intfmgrd self.check_sub_port_intf_key_removal(self.state_db, STATE_INTERFACE_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + "|" + self.IPV4_ADDR_UNDER_TEST) + sub_port_intf_name + "|" + self.IPV4_ADDR_UNDER_TEST) # Verify that IPv4 address configuration is removed from APPL_DB INTF_TABLE by Intfmgrd self.check_sub_port_intf_key_removal(self.appl_db, APP_INTF_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + ":" + self.IPV4_ADDR_UNDER_TEST) + sub_port_intf_name + ":" + self.IPV4_ADDR_UNDER_TEST) # Verify that IPv4 subnet route entry is removed from ASIC_DB # Verify that IPv4 ip2me route entry is removed from ASIC_DB @@ -321,15 +369,15 @@ def test_sub_port_intf_remove_ip_addrs(self, dvs): self.check_sub_port_intf_route_entries_removal(removed_route_entries) # Remove IPv6 address - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) # Verify that IPv6 address state ok is removed from STATE_DB INTERFACE_TABLE by Intfmgrd self.check_sub_port_intf_key_removal(self.state_db, STATE_INTERFACE_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + "|" + self.IPV6_ADDR_UNDER_TEST) + sub_port_intf_name + "|" + self.IPV6_ADDR_UNDER_TEST) # Verify that IPv6 address configuration is removed from APPL_DB INTF_TABLE by Intfmgrd self.check_sub_port_intf_key_removal(self.appl_db, APP_INTF_TABLE_NAME, \ - self.SUB_PORT_INTERFACE_UNDER_TEST + ":" + self.IPV6_ADDR_UNDER_TEST) + sub_port_intf_name + ":" + self.IPV6_ADDR_UNDER_TEST) # Verify that IPv6 subnet route entry is removed from ASIC_DB # Verify that IPv6 ip2me route entry is removed from ASIC_DB @@ -340,43 +388,62 @@ def test_sub_port_intf_remove_ip_addrs(self, dvs): self.check_sub_port_intf_key_existence(self.asic_db, ASIC_RIF_TABLE, rif_oid) # Remove a sub port interface - self.remove_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.remove_sub_port_intf_profile(sub_port_intf_name) - def test_sub_port_intf_removal(self, dvs): + def test_sub_port_intf_remove_ip_addrs(self, dvs): self.connect_dbs(dvs) + self._test_sub_port_intf_remove_ip_addrs(dvs, self.SUB_PORT_INTERFACE_UNDER_TEST) + self._test_sub_port_intf_remove_ip_addrs(dvs, self.LAG_SUB_PORT_INTERFACE_UNDER_TEST) + + def _test_sub_port_intf_removal(self, dvs, sub_port_intf_name): + substrs = sub_port_intf_name.split(VLAN_SUB_INTERFACE_SEPARATOR) + parent_port = substrs[0] + vlan_id = substrs[1] + if parent_port.startswith(ETHERNET_PREFIX): + state_tbl_name = STATE_PORT_TABLE_NAME + else: + assert parent_port.startswith(LAG_PREFIX) + state_tbl_name = STATE_LAG_TABLE_NAME + old_rif_oids = self.get_oids(ASIC_RIF_TABLE) - self.set_parent_port_admin_status(self.PHYSICAL_PORT_UNDER_TEST, "up") - self.create_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.set_parent_port_admin_status(dvs, parent_port, "up") + self.create_sub_port_intf_profile(sub_port_intf_name) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) - self.add_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) + self.add_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) rif_oid = self.get_newly_created_oid(ASIC_RIF_TABLE, old_rif_oids) fv_dict = { "state": "ok", } - self.check_sub_port_intf_fvs(self.state_db, STATE_PORT_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST, fv_dict) + self.check_sub_port_intf_fvs(self.state_db, state_tbl_name, sub_port_intf_name, fv_dict) fv_dict = { ADMIN_STATUS: "up", } - self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST, fv_dict) + self.check_sub_port_intf_fvs(self.appl_db, APP_INTF_TABLE_NAME, sub_port_intf_name, fv_dict) # Remove IP addresses - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV4_ADDR_UNDER_TEST) - self.remove_sub_port_intf_ip_addr(self.SUB_PORT_INTERFACE_UNDER_TEST, self.IPV6_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV4_ADDR_UNDER_TEST) + self.remove_sub_port_intf_ip_addr(sub_port_intf_name, self.IPV6_ADDR_UNDER_TEST) # Remove a sub port interface - self.remove_sub_port_intf_profile(self.SUB_PORT_INTERFACE_UNDER_TEST) + self.remove_sub_port_intf_profile(sub_port_intf_name) # Verify that sub port interface state ok is removed from STATE_DB by Intfmgrd - self.check_sub_port_intf_key_removal(self.state_db, STATE_PORT_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST) + self.check_sub_port_intf_key_removal(self.state_db, state_tbl_name, sub_port_intf_name) # Verify that sub port interface configuration is removed from APPL_DB INTF_TABLE by Intfmgrd - self.check_sub_port_intf_key_removal(self.appl_db, APP_INTF_TABLE_NAME, self.SUB_PORT_INTERFACE_UNDER_TEST) + self.check_sub_port_intf_key_removal(self.appl_db, APP_INTF_TABLE_NAME, 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) + + def test_sub_port_intf_removal(self, dvs): + self.connect_dbs(dvs) + + self._test_sub_port_intf_removal(dvs, self.SUB_PORT_INTERFACE_UNDER_TEST) + self._test_sub_port_intf_removal(dvs, self.LAG_SUB_PORT_INTERFACE_UNDER_TEST)