diff --git a/.gitignore b/.gitignore index e115801e48..3643e2b8fb 100644 --- a/.gitignore +++ b/.gitignore @@ -96,4 +96,4 @@ tests/tests.log tests/tests.trs tests/mock_tests/**/*log tests/mock_tests/**/*trs -orchagent/p4orch/tests/p4orch_tests +orchagent/p4orch/tests/p4orch_tests \ No newline at end of file diff --git a/cfgmgr/portmgr.cpp b/cfgmgr/portmgr.cpp index e3ac0e8590..1f45ab48af 100644 --- a/cfgmgr/portmgr.cpp +++ b/cfgmgr/portmgr.cpp @@ -7,6 +7,7 @@ #include "exec.h" #include "shellcmd.h" #include +#include using namespace std; using namespace swss; @@ -83,6 +84,47 @@ bool PortMgr::setPortAdminStatus(const string &alias, const bool up) return true; } + +bool PortMgr::setPortDHCPMitigationRate(const string &alias, const string &dhcp_rate_limit) +{ + // If dhcp_rate_limit is not configured (empty string), do nothing + if (dhcp_rate_limit.empty()) + { + //SWSS_LOG_DEBUG("DHCP rate limit not configured for port %s, skipping TC configuration", alias.c_str()); + return true; + } + + stringstream cmd; + string res, cmd_str; + int ret; + + if (dhcp_rate_limit != "0") + { + int byte_rate = stoi(dhcp_rate_limit) * PACKET_SIZE; + cmd << TC_CMD << " qdisc add dev " << shellquote(alias) << " handle ffff: ingress" << " && " \ + << TC_CMD << " filter add dev " << shellquote(alias) << " protocol ip parent ffff: prio 1 u32 match ip protocol 17 0xff match ip dport 67 0xffff police rate " << to_string(byte_rate) << "bps burst " << to_string(byte_rate) << "b conform-exceed drop"; + cmd_str = cmd.str(); + ret = swss::exec(cmd_str, res); + } + else + { + // tc qdisc del dev handle ffff: ingress + cmd << TC_CMD << " qdisc del dev " << shellquote(alias) << " handle ffff: ingress"; + cmd_str = cmd.str(); + ret = swss::exec(cmd_str, res); + } + + if (!ret) + { + return true; + } + else + { + throw runtime_error(cmd_str + " : " + res); + } +} + + bool PortMgr::isPortStateOk(const string &alias) { vector temp; @@ -162,18 +204,20 @@ void PortMgr::doTask(Consumer &consumer) */ bool portOk = isPortStateOk(alias); - string admin_status, mtu; + string admin_status, mtu, dhcp_rate_limit; std::vector field_values; bool configured = (m_portList.find(alias) != m_portList.end()); /* If this is the first time we set port settings - * assign default admin status and mtu + * assign default admin status and mtu and dhcp_rate_limit */ if (!configured) { admin_status = DEFAULT_ADMIN_STATUS_STR; mtu = DEFAULT_MTU_STR; + dhcp_rate_limit = DEFAULT_DHCP_RATE_LIMIT_STR; + m_portList.insert(alias); } @@ -182,7 +226,7 @@ void PortMgr::doTask(Consumer &consumer) it++; continue; } - + bool dhcp_configured = false; for (auto i : kfvFieldsValues(t)) { if (fvField(i) == "mtu") @@ -192,7 +236,14 @@ void PortMgr::doTask(Consumer &consumer) else if (fvField(i) == "admin_status") { admin_status = fvValue(i); + } + else if (fvField(i) == "dhcp_rate_limit") + { + dhcp_rate_limit = fvValue(i); + dhcp_configured = true; // Mark that dhcp_rate_limit was explicitly configured + } + else { field_values.emplace_back(i); @@ -213,11 +264,16 @@ void PortMgr::doTask(Consumer &consumer) writeConfigToAppDb(alias, field_values); } + + if (!portOk) { SWSS_LOG_INFO("Port %s is not ready, pending...", alias.c_str()); - /* Retry setting these params after the netdev is created */ + + writeConfigToAppDb(alias, "mtu", mtu); + writeConfigToAppDb(alias, "admin_status", admin_status); + field_values.clear(); field_values.emplace_back("mtu", mtu); field_values.emplace_back("admin_status", admin_status); @@ -237,6 +293,12 @@ void PortMgr::doTask(Consumer &consumer) setPortAdminStatus(alias, admin_status == "up"); SWSS_LOG_NOTICE("Configure %s admin status to %s", alias.c_str(), admin_status.c_str()); } + + if (dhcp_configured) + { + setPortDHCPMitigationRate(alias, dhcp_rate_limit); + SWSS_LOG_NOTICE("Configure %s DHCP rate limit to %s", alias.c_str(), dhcp_rate_limit.c_str()); + } } else if (op == DEL_COMMAND) { @@ -263,4 +325,4 @@ bool PortMgr::writeConfigToAppDb(const std::string &alias, std::vector &field_values); bool setPortMtu(const std::string &alias, const std::string &mtu); bool setPortAdminStatus(const std::string &alias, const bool up); + bool setPortDHCPMitigationRate(const std::string &alias, const std::string &dhcp_rate_limit); bool isPortStateOk(const std::string &alias); }; -} +} \ No newline at end of file diff --git a/cfgmgr/portmgrd.cpp b/cfgmgr/portmgrd.cpp index 4d04b42d38..1cc842ba32 100644 --- a/cfgmgr/portmgrd.cpp +++ b/cfgmgr/portmgrd.cpp @@ -35,8 +35,8 @@ int main(int argc, char **argv) PortMgr portmgr(&cfgDb, &appDb, &stateDb, cfg_port_tables); vector cfgOrchList = {&portmgr}; - swss::Select s; + for (Orch *o : cfgOrchList) { s.addSelectables(o->getSelectables()); @@ -68,4 +68,4 @@ int main(int argc, char **argv) SWSS_LOG_ERROR("Runtime error: %s", e.what()); } return -1; -} +} \ No newline at end of file diff --git a/cfgmgr/shellcmd.h b/cfgmgr/shellcmd.h index 31fd7e3270..1d26eb9239 100644 --- a/cfgmgr/shellcmd.h +++ b/cfgmgr/shellcmd.h @@ -14,6 +14,7 @@ #define TEAMDCTL_CMD "/usr/bin/teamdctl" #define IPTABLES_CMD "/sbin/iptables" #define CONNTRACK_CMD "/usr/sbin/conntrack" +#define TC_CMD "/sbin/tc" #define EXEC_WITH_ERROR_THROW(cmd, res) ({ \ int ret = swss::exec(cmd, res); \ @@ -29,4 +30,4 @@ static inline std::string shellquote(const std::string& str) return "\"" + std::regex_replace(str, re, "\\$1") + "\""; } -#endif /* __SHELLCMD__ */ +#endif /* __SHELLCMD__ */ \ No newline at end of file diff --git a/orchagent/port.h b/orchagent/port.h index d53cf3d2ab..bdd3cb23c4 100644 --- a/orchagent/port.h +++ b/orchagent/port.h @@ -273,4 +273,4 @@ class Port } -#endif /* SWSS_PORT_H */ +#endif /* SWSS_PORT_H */ \ No newline at end of file diff --git a/orchagent/port/porthlpr.cpp b/orchagent/port/porthlpr.cpp index 9da05ee249..af8a1fe20c 100644 --- a/orchagent/port/porthlpr.cpp +++ b/orchagent/port/porthlpr.cpp @@ -1224,6 +1224,7 @@ bool PortHelper::parsePortConfig(PortConfig &port) const return false; } } + else if (field == PORT_DAMPING_ALGO) { if (!this->parsePortLinkEventDampingAlgorithm(port, field, value)) @@ -1266,6 +1267,7 @@ bool PortHelper::parsePortConfig(PortConfig &port) const return false; } } + else if (field == PORT_MODE) { /* Placeholder to prevent warning. Not needed to be parsed here. @@ -1312,4 +1314,4 @@ bool PortHelper::validatePortConfig(PortConfig &port) const } return true; -} +} \ No newline at end of file diff --git a/orchagent/port/portschema.h b/orchagent/port/portschema.h index 63df8bfdc1..a06608f815 100644 --- a/orchagent/port/portschema.h +++ b/orchagent/port/portschema.h @@ -102,4 +102,5 @@ #define PORT_REUSE_THRESHOLD "reuse_threshold" #define PORT_FLAP_PENALTY "flap_penalty" #define PORT_MODE "mode" +#define PORT_MODE "mode" #define PORT_UNRELIABLE_LOS "unreliable_los" diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 3cbf4a9f1c..00c0038f56 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -497,7 +497,7 @@ static bool isPathTracingSupported() SWSS_LOG_INFO("Querying OBJECT_TYPE_LIST is not supported on this platform"); return false; } - else + else { SWSS_LOG_ERROR( "Failed to get a list of supported switch capabilities. Error=%d", status @@ -6515,7 +6515,7 @@ bool PortsOrch::removeBridgePort(Port &port) hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_STRIP], port.m_alias.c_str()); return false; } - + /* Remove STP ports before bridge port deletion*/ gStpOrch->removeStpPorts(port); @@ -8346,7 +8346,7 @@ void PortsOrch::generateWredPortCounterMap() /**** * Func Name : addWredQueueFlexCounters -* Parameters : queueStateVector +* Parameters : queueStateVector * Returns : void * Description: Top level API to Set WRED flex counters for Queues **/ @@ -8416,9 +8416,9 @@ void PortsOrch::addWredQueueFlexCountersPerPort(const Port& port, FlexCounterQue } /**** * Func Name : addWredQueueFlexCountersPerPortPerQueueIndex -* Parameters : port, queueIndex, is_voq +* Parameters : port, queueIndex, is_voq * Returns : void -* Description: Sets the Stats list to be polled by the flexcounter +* Description: Sets the Stats list to be polled by the flexcounter **/ void PortsOrch::addWredQueueFlexCountersPerPortPerQueueIndex(const Port& port, size_t queueIndex, bool voq, sai_queue_type_t queueType) @@ -10421,4 +10421,4 @@ void PortsOrch::doTask(swss::SelectableTimer &timer) { m_port_state_poller->stop(); } -} +} \ No newline at end of file diff --git a/portsyncd/linksync.cpp b/portsyncd/linksync.cpp index 4c00d366e7..109c535c19 100644 --- a/portsyncd/linksync.cpp +++ b/portsyncd/linksync.cpp @@ -209,4 +209,4 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj) { SWSS_LOG_NOTICE("Cannot find %s in port table", key.c_str()); } -} +} \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index d67044799b..3920227749 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2086,4 +2086,4 @@ def dpb_setup_fixture(dvs): else: dvs.vct.restart() yield - remove_dpb_config_file(dvs) + remove_dpb_config_file(dvs) \ No newline at end of file diff --git a/tests/dvslib/dvs_common.py b/tests/dvslib/dvs_common.py index 0d81b4cf2e..f1d82b0be8 100644 --- a/tests/dvslib/dvs_common.py +++ b/tests/dvslib/dvs_common.py @@ -59,4 +59,4 @@ def wait_for_result( message = failure_message or f"Operation timed out after {polling_config.timeout} seconds with result {result}" assert False, message - return (False, result) + return (False, result) \ No newline at end of file diff --git a/tests/dvslib/dvs_database.py b/tests/dvslib/dvs_database.py index 6724698289..51aa235d27 100644 --- a/tests/dvslib/dvs_database.py +++ b/tests/dvslib/dvs_database.py @@ -378,7 +378,7 @@ def wait_for_n_keys( self, table_name: str, num_keys: int, - wait_at_least_n_keys: bool = False, + wait_at_least_n_keys: bool = False, polling_config: PollingConfig = PollingConfig(), failure_message: str = None, ) -> List[str]: @@ -495,4 +495,4 @@ def _disable_strict_polling(polling_config: PollingConfig) -> PollingConfig: disabled_config = PollingConfig( polling_config.polling_interval, polling_config.timeout, False ) - return disabled_config + return disabled_config \ No newline at end of file diff --git a/tests/mock_tests/portmgr_ut.cpp b/tests/mock_tests/portmgr_ut.cpp index b7b83590bd..ec5a61246d 100644 --- a/tests/mock_tests/portmgr_ut.cpp +++ b/tests/mock_tests/portmgr_ut.cpp @@ -43,7 +43,6 @@ namespace portmgr_ut Table cfg_port_table(m_config_db.get(), CFG_PORT_TABLE_NAME); // Port is not ready, verify that doTask does not handle port configuration - cfg_port_table.set("Ethernet0", { {"speed", "100000"}, {"index", "1"} @@ -54,6 +53,8 @@ namespace portmgr_ut ASSERT_TRUE(mockCallArgs.empty()); std::vector values; app_port_table.get("Ethernet0", values); + + // Verify default values auto value_opt = swss::fvsGetValue(values, "mtu", true); ASSERT_TRUE(value_opt); ASSERT_EQ(DEFAULT_MTU_STR, value_opt.get()); @@ -67,11 +68,13 @@ namespace portmgr_ut ASSERT_TRUE(value_opt); ASSERT_EQ("1", value_opt.get()); - // Set port state to ok, verify that doTask handle port configuration + // Set port state to ok, verify that doTask handles port configuration state_port_table.set("Ethernet0", { {"state", "ok"} }); m_portMgr->doTask(); + + // Only MTU and admin status should be configured (DHCP rate limit is empty by default) ASSERT_EQ(size_t(2), mockCallArgs.size()); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" mtu \"9100\"", mockCallArgs[0]); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" down", mockCallArgs[1]); @@ -86,8 +89,38 @@ namespace portmgr_ut value_opt = swss::fvsGetValue(values, "admin_status", true); ASSERT_TRUE(value_opt); ASSERT_EQ("up", value_opt.get()); - } + // Test explicit DHCP rate limit configuration + mockCallArgs.clear(); + cfg_port_table.set("Ethernet0", { + {"dhcp_rate_limit", "100"} + }); + m_portMgr->addExistingData(&cfg_port_table); + m_portMgr->doTask(); + + // Verify the TC commands for DHCP rate limiting + ASSERT_EQ(size_t(2), mockCallArgs.size()); + + string expected_cmd = "/sbin/tc qdisc add dev \"Ethernet0\" handle ffff: ingress && " + "/sbin/tc filter add dev \"Ethernet0\" protocol ip parent ffff: prio 1 u32 " + "match ip protocol 17 0xff match ip dport 67 0xffff " + "police rate 40600bps burst 40600b conform-exceed drop"; + ASSERT_EQ(expected_cmd, mockCallArgs[1]); + + // Verify the value was written to APP_DB + app_port_table.get("Ethernet0", values); + value_opt = swss::fvsGetValue(values, "dhcp_rate_limit", true); + mockCallArgs.clear(); + cfg_port_table.set("Ethernet0", { + {"dhcp_rate_limit", "0"} + }); + m_portMgr->addExistingData(&cfg_port_table); + m_portMgr->doTask(); + + ASSERT_EQ(size_t(2), mockCallArgs.size()); + ASSERT_EQ("/sbin/tc qdisc del dev \"Ethernet0\" handle ffff: ingress", mockCallArgs[1]); + } + TEST_F(PortMgrTest, ConfigureDuringRetry) { Table state_port_table(m_state_db.get(), STATE_PORT_TABLE_NAME); @@ -109,6 +142,7 @@ namespace portmgr_ut {"index", "1"}, {"mtu", "1518"}, {"admin_status", "up"} + }); m_portMgr->addExistingData(&cfg_port_table); @@ -122,6 +156,7 @@ namespace portmgr_ut ASSERT_EQ(size_t(2), mockCallArgs.size()); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" mtu \"1518\"", mockCallArgs[0]); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" up", mockCallArgs[1]); + } TEST_F(PortMgrTest, ConfigurePortPTDefaultTimestampTemplate) @@ -201,4 +236,4 @@ namespace portmgr_ut ASSERT_TRUE(value_opt); ASSERT_EQ("template2", value_opt.get()); } -} +} \ No newline at end of file diff --git a/tests/mock_tests/portsyncd/portsyncd_ut.cpp b/tests/mock_tests/portsyncd/portsyncd_ut.cpp index 93575f68bc..c447912341 100644 --- a/tests/mock_tests/portsyncd/portsyncd_ut.cpp +++ b/tests/mock_tests/portsyncd/portsyncd_ut.cpp @@ -305,4 +305,4 @@ namespace portsyncd_ut std::vector ovalues; ASSERT_EQ(sync.m_statePortTable.get("Ethernet0", ovalues), false); } -} +} \ No newline at end of file diff --git a/tests/test_drop_counters.py b/tests/test_drop_counters.py index cd089be917..379ce3e2a9 100644 --- a/tests/test_drop_counters.py +++ b/tests/test_drop_counters.py @@ -659,26 +659,26 @@ def test_removeInvalidDropReason(self, dvs, testlog): # Cleanup for the next test. self.delete_drop_counter(name) self.remove_drop_reason(name, reason1) - + def getPortOid(self, dvs, port_name): port_name_map = swsscommon.Table(self.counters_db, "COUNTERS_PORT_NAME_MAP") status, returned_value = port_name_map.hget("", port_name); assert status == True return returned_value - + def test_add_remove_port(self, dvs, testlog): """ - This test verifies that debug counters are removed when we remove a port + This test verifies that debug counters are removed when we remove a port and debug counters are added each time we add ports (if debug counter is enabled) """ self.setup_db(dvs) - + # save port info cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0) tbl = swsscommon.Table(cdb, PORT_TABLE_NAME) - (status, fvs) = tbl.get(PORT) + (status, fvs) = tbl.get(PORT) assert status == True - + # get counter oid oid = self.getPortOid(dvs, PORT) @@ -686,26 +686,26 @@ def test_add_remove_port(self, dvs, testlog): flex_counter_table = swsscommon.Table(self.flex_db, FLEX_COUNTER_TABLE) status, fields = flex_counter_table.get(oid) assert len(fields) == 0 - + # add debug counters name1 = 'DEBUG_0' reason1 = 'L3_ANY' name2 = 'DEBUG_1' reason2 = 'L2_ANY' - + self.create_drop_counter(name1, PORT_INGRESS_DROPS) self.add_drop_reason(name1, reason1) - + self.create_drop_counter(name2, PORT_EGRESS_DROPS) self.add_drop_reason(name2, reason2) time.sleep(3) - + # verifies debug counter exist for port flex_counter_table = swsscommon.Table(self.flex_db, FLEX_COUNTER_TABLE) status, fields = flex_counter_table.get(oid) assert status == True assert len(fields) == 1 - + # remove port and wait until it was removed from ASIC DB self.dvs_port.remove_port(PORT) dvs.get_asic_db().wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_PORT", oid) @@ -713,23 +713,23 @@ def test_add_remove_port(self, dvs, testlog): # verify that debug counter were removed status, fields = flex_counter_table.get(oid) assert len(fields) == 0 - + # add port and wait until the port is added on asic db num_of_keys_without_port = len(dvs.get_asic_db().get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT")) tbl.set(PORT, fvs) dvs.get_asic_db().wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_keys_without_port + 1) dvs.get_counters_db().wait_for_fields("COUNTERS_PORT_NAME_MAP", "", [PORT]) - + # verifies that debug counters were added for port oid = self.getPortOid(dvs, PORT) status, fields = flex_counter_table.get(oid) assert status == True assert len(fields) == 1 - + # Cleanup for the next test. self.delete_drop_counter(name1) self.remove_drop_reason(name1, reason1) - + self.delete_drop_counter(name2) self.remove_drop_reason(name2, reason2) @@ -788,4 +788,4 @@ def test_createAndDeleteMultipleCounters(self, dvs, testlog): # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying def test_nonflaky_dummy(): - pass + pass \ No newline at end of file diff --git a/tests/test_fgnhg.py b/tests/test_fgnhg.py index 3cb7e8f1fc..76225272bf 100644 --- a/tests/test_fgnhg.py +++ b/tests/test_fgnhg.py @@ -1610,4 +1610,4 @@ def test_fgnhg_matchmode_nexthop_multi_route(self, dvs, testlog): # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying def test_nonflaky_dummy(): - pass + pass \ No newline at end of file diff --git a/tests/test_interface.py b/tests/test_interface.py index 4c453710d9..0f4ebf18ac 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -2321,7 +2321,7 @@ def loopback_action_test(self, iface, action): def test_interfaceLoopbackActionDrop(self, dvs, testlog): self.setup_db(dvs) self.loopback_action_test("Ethernet8", "drop") - + def test_interfaceLoopbackActionForward(self, dvs, testlog): self.setup_db(dvs) self.loopback_action_test("Ethernet8", "forward") @@ -2329,7 +2329,7 @@ def test_interfaceLoopbackActionForward(self, dvs, testlog): def test_subInterfaceLoopbackActionDrop(self, dvs, testlog): self.setup_db(dvs) self.loopback_action_test("Ethernet8.1", "drop") - + def test_subInterfaceLoopbackActionForward(self, dvs, testlog): self.setup_db(dvs) self.loopback_action_test("Ethernet8.1", "forward") @@ -2339,7 +2339,7 @@ def test_vlanInterfaceLoopbackActionDrop(self, dvs, testlog): self.create_vlan("10") self.loopback_action_test("Vlan10", "drop") self.remove_vlan("10") - + def test_vlanInterfaceLoopbackActionForward(self, dvs, testlog): self.setup_db(dvs) self.create_vlan("20") @@ -2351,7 +2351,7 @@ def test_portChannelInterfaceLoopbackActionDrop(self, dvs, testlog): self.create_port_channel("PortChannel009") self.loopback_action_test("PortChannel009", "drop") self.remove_port_channel("PortChannel009") - + def test_portChannelInterfaceLoopbackActionForward(self, dvs, testlog): self.setup_db(dvs) self.create_port_channel("PortChannel010") @@ -2361,4 +2361,4 @@ def test_portChannelInterfaceLoopbackActionForward(self, dvs, testlog): # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying def test_nonflaky_dummy(): - pass + pass \ No newline at end of file diff --git a/tests/test_port_add_remove.py b/tests/test_port_add_remove.py index 54cd6599c9..c0cba6de21 100644 --- a/tests/test_port_add_remove.py +++ b/tests/test_port_add_remove.py @@ -23,7 +23,7 @@ def dynamic_buffer(dvs): @pytest.mark.usefixtures('dvs_port_manager') -@pytest.mark.usefixtures("dynamic_buffer") +@pytest.mark.usefixtures("dynamic_buffer") class TestPortAddRemove(object): def set_mmu(self,dvs): @@ -74,7 +74,7 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): # Shutdown interface dvs.port_admin_set(PORT_A, 'down') - + # try to remove this port config_db.delete_entry('PORT', PORT_A) num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", @@ -84,7 +84,7 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): # verify that the port was removed properly since all buffer configuration was removed also assert len(num) == num_of_ports - 1 - # set back the port + # set back the port config_db.update_entry("PORT", PORT_A, port_info) # verify that the port has been readded @@ -136,9 +136,9 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): # verify that the port wasn't removed since we still have buffer cfg assert len(num) == num_of_ports - 1 - # set back the port as it is required for next test + # set back the port as it is required for next test config_db.update_entry("PORT", PORT_A, port_info) - + @pytest.mark.parametrize("scenario", ["one_port", "all_ports"]) @@ -153,7 +153,7 @@ def test_add_remove_all_the_ports(self, dvs, testlog, scenario): # get the number of ports before removal num_of_ports = len(asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT")) - + # remove buffer pg cfg for the port if scenario == "all_ports": ports = config_db.get_keys('PORT') @@ -162,7 +162,7 @@ def test_add_remove_all_the_ports(self, dvs, testlog, scenario): else: assert False - # delete all PGs and QUEUEs from the relevant ports + # delete all PGs and QUEUEs from the relevant ports pgs = config_db.get_keys('BUFFER_PG') queues = config_db.get_keys('BUFFER_QUEUE') @@ -189,13 +189,13 @@ def test_add_remove_all_the_ports(self, dvs, testlog, scenario): for key in ports: config_db.delete_entry('PORT',key) app_db.wait_for_deleted_entry("PORT_TABLE", key) - + # verify remove port num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_ports-len(ports)) assert len(num) == num_of_ports-len(ports) - + # add port """ DELETE_CREATE_ITERATIONS defines the number of iteration of delete and create to ports, @@ -206,38 +206,38 @@ def test_add_remove_all_the_ports(self, dvs, testlog, scenario): config_db.update_entry("PORT", key, ports_info[key]) app_db.wait_for_entry('PORT_TABLE',key) - # verify add port + # verify add port num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_ports) assert len(num) == num_of_ports - - time.sleep((i%2)+1) - + + time.sleep((i%2)+1) + # run ping dvs.setup_db() dvs.create_vlan("6") dvs.create_vlan_member("6", PORT_A) dvs.create_vlan_member("6", PORT_B) - + port_entry_a = state_db.get_entry("PORT_TABLE",PORT_A) port_entry_b = state_db.get_entry("PORT_TABLE",PORT_B) port_admin_a = port_entry_a['admin_status'] port_admin_b = port_entry_b['admin_status'] - + dvs.set_interface_status("Vlan6", "up") dvs.add_ip_address("Vlan6", "6.6.6.1/24") dvs.set_interface_status(PORT_A, "up") dvs.set_interface_status(PORT_B, "up") - + dvs.servers[16].runcmd("ifconfig eth0 6.6.6.6/24 up") dvs.servers[16].runcmd("ip route add default via 6.6.6.1") dvs.servers[17].runcmd("ifconfig eth0 6.6.6.7/24 up") dvs.servers[17].runcmd("ip route add default via 6.6.6.1") - + time.sleep(2) - + rc = dvs.servers[16].runcmd("ping -c 1 6.6.6.7") assert rc == 0 @@ -522,4 +522,4 @@ def test_add_remove_neg_admin_status(self, testlog): self.verify_add_remove(qualifiers) qualifiers = { "admin_status": "invalid" } - self.verify_add_remove(qualifiers) + self.verify_add_remove(qualifiers) \ No newline at end of file diff --git a/tests/test_port_config.py b/tests/test_port_config.py index b6f51e4e86..0dcff6fa26 100644 --- a/tests/test_port_config.py +++ b/tests/test_port_config.py @@ -232,4 +232,4 @@ def _access_function(): # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying def test_nonflaky_dummy(): - pass + pass \ No newline at end of file diff --git a/tests/test_sub_port_intf.py b/tests/test_sub_port_intf.py index 9ff8ad63e6..8b07418ec0 100644 --- a/tests/test_sub_port_intf.py +++ b/tests/test_sub_port_intf.py @@ -122,7 +122,7 @@ def get_subintf_longname(self, port_name): return "PortChannel"+intf_index+VLAN_SUB_INTERFACE_SEPARATOR+sub_intf_idx else: return str(port_name) - + def get_port_longname(self, port_name): if port_name is None: return None @@ -1182,10 +1182,10 @@ def _test_sub_port_intf_removal(self, dvs, sub_port_intf_name, removal_seq_test= "SAI_ROUTER_INTERFACE_ATTR_PORT_ID": parent_port_oid, } rif_oid = self.get_newly_created_oid(ASIC_RIF_TABLE, old_rif_oids) - #If subintf mtu deleted, it inherits from parent + #If subintf mtu deleted, it inherits from parent if vrf_name == self.VRF_UNDER_TEST or vrf_name == self.VNET_UNDER_TEST: if parent_port.startswith(ETHERNET_PREFIX): - fv_dict["SAI_ROUTER_INTERFACE_ATTR_MTU"] = ETHERNET_PORT_DEFAULT_MTU + fv_dict["SAI_ROUTER_INTERFACE_ATTR_MTU"] = ETHERNET_PORT_DEFAULT_MTU self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) else: rif_oid = self.get_newly_created_oid(ASIC_RIF_TABLE, old_rif_oids) @@ -1724,4 +1724,4 @@ def test_sub_port_intf_oper_down_with_pending_neigh_route_tasks(self, dvs): # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying def test_nonflaky_dummy(): - pass + pass \ No newline at end of file diff --git a/tests/test_warm_reboot.py b/tests/test_warm_reboot.py index afa4a62a02..7adf0f0bf8 100644 --- a/tests/test_warm_reboot.py +++ b/tests/test_warm_reboot.py @@ -2478,4 +2478,4 @@ def test_TunnelMgrdWarmRestart(self, dvs): # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying def test_nonflaky_dummy(): - pass + pass \ No newline at end of file