diff --git a/configure.ac b/configure.ac index 81ee0a5017..5e5ce44171 100644 --- a/configure.ac +++ b/configure.ac @@ -138,6 +138,7 @@ AC_CONFIG_FILES([ swssconfig/Makefile cfgmgr/Makefile tests/Makefile + orchagent/p4orch/tests/Makefile ]) # If no SAI library is installed, compile with SAIVS and run unit tests diff --git a/orchagent/Makefile.am b/orchagent/Makefile.am index cf789b027f..78b800e1d4 100644 --- a/orchagent/Makefile.am +++ b/orchagent/Makefile.am @@ -87,6 +87,18 @@ orchagent_SOURCES = \ orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp +orchagent_SOURCES += p4orch/p4orch.cpp \ + p4orch/p4orch_util.cpp \ + p4orch/p4oidmapper.cpp \ + p4orch/router_interface_manager.cpp \ + p4orch/neighbor_manager.cpp \ + p4orch/next_hop_manager.cpp \ + p4orch/route_manager.cpp \ + p4orch/acl_util.cpp \ + p4orch/acl_table_manager.cpp \ + p4orch/acl_rule_manager.cpp \ + p4orch/wcmp_manager.cpp \ + p4orch/mirror_session_manager.cpp orchagent_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI) orchagent_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI) diff --git a/orchagent/acltable.h b/orchagent/acltable.h index 44d6ea4dbf..37842883f5 100644 --- a/orchagent/acltable.h +++ b/orchagent/acltable.h @@ -17,6 +17,7 @@ extern "C" { #define STAGE_INGRESS "INGRESS" #define STAGE_EGRESS "EGRESS" +#define STAGE_PRE_INGRESS "PRE_INGRESS" #define TABLE_TYPE_L3 "L3" #define TABLE_TYPE_L3V6 "L3V6" @@ -35,7 +36,8 @@ typedef enum { ACL_STAGE_UNKNOWN, ACL_STAGE_INGRESS, - ACL_STAGE_EGRESS + ACL_STAGE_EGRESS, + ACL_STAGE_PRE_INGRESS } acl_stage_type_t; typedef std::unordered_map acl_stage_type_lookup_t; @@ -59,3 +61,28 @@ typedef enum } acl_table_type_t; typedef std::unordered_map acl_table_type_lookup_t; +typedef std::map acl_stage_lookup_t; +typedef std::map acl_stage_to_switch_attr_lookup_t; + +struct AclTableGroupMember { + sai_object_id_t m_group_oid; + sai_object_id_t m_group_member_oid; + uint32_t m_priority; + AclTableGroupMember() + : m_group_oid(SAI_NULL_OBJECT_ID) + , m_group_member_oid(SAI_NULL_OBJECT_ID) + , m_priority(0) + {} +}; + +static const acl_stage_lookup_t aclStageLookup = { + {STAGE_INGRESS, SAI_ACL_STAGE_INGRESS}, + {STAGE_EGRESS, SAI_ACL_STAGE_EGRESS}, + {STAGE_PRE_INGRESS, SAI_ACL_STAGE_PRE_INGRESS}, +}; + +static const acl_stage_to_switch_attr_lookup_t aclStageToSwitchAttrLookup = { + {SAI_ACL_STAGE_INGRESS, SAI_SWITCH_ATTR_INGRESS_ACL}, + {SAI_ACL_STAGE_EGRESS, SAI_SWITCH_ATTR_EGRESS_ACL}, + {SAI_ACL_STAGE_PRE_INGRESS, SAI_SWITCH_ATTR_PRE_INGRESS_ACL}, +}; \ No newline at end of file diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index b990fa2a2a..200e4df1a2 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -44,6 +44,7 @@ NatOrch *gNatOrch; MlagOrch *gMlagOrch; IsoGrpOrch *gIsoGrpOrch; MACsecOrch *gMacsecOrch; +P4Orch *gP4Orch; BfdOrch *gBfdOrch; Srv6Orch *gSrv6Orch; @@ -87,6 +88,9 @@ bool OrchDaemon::init() SWSS_LOG_ENTER(); string platform = getenv("platform") ? getenv("platform") : ""; + + gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME); + TableConnector stateDbSwitchTable(m_stateDb, "SWITCH_CAPABILITY"); TableConnector app_switch_table(m_applDb, APP_SWITCH_TABLE_NAME); TableConnector conf_asic_sensors(m_configDb, CFG_ASIC_SENSORS_TABLE_NAME); @@ -114,7 +118,6 @@ bool OrchDaemon::init() { APP_MCLAG_FDB_TABLE_NAME, FdbOrch::fdborch_pri} }; - gCrmOrch = new CrmOrch(m_configDb, CFG_CRM_TABLE_NAME); gPortsOrch = new PortsOrch(m_applDb, m_stateDb, ports_tables, m_chassisAppDb); TableConnector stateDbFdb(m_stateDb, STATE_FDB_TABLE_NAME); TableConnector stateMclagDbFdb(m_stateDb, STATE_MCLAG_REMOTE_FDB_TABLE_NAME); @@ -589,6 +592,10 @@ bool OrchDaemon::init() m_orchList.push_back(&CounterCheckOrch::getInstance(m_configDb)); + vector p4rt_tables = {APP_P4RT_TABLE_NAME}; + gP4Orch = new P4Orch(m_applDb, p4rt_tables, vrf_orch, copp_orch); + m_orchList.push_back(gP4Orch); + if (WarmStart::isWarmStart()) { bool suc = warmRestoreAndSyncUp(); diff --git a/orchagent/orchdaemon.h b/orchagent/orchdaemon.h index 4be9b7eb9b..4229cbe8e6 100644 --- a/orchagent/orchdaemon.h +++ b/orchagent/orchdaemon.h @@ -38,6 +38,7 @@ #include "mlagorch.h" #include "muxorch.h" #include "macsecorch.h" +#include "p4orch/p4orch.h" #include "bfdorch.h" #include "srv6orch.h" diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 851200b47c..19c0bb3aef 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -162,6 +162,8 @@ class PortsOrch : public Orch, public Subject bool getPortIPG(sai_object_id_t port_id, uint32_t &ipg); bool setPortIPG(sai_object_id_t port_id, uint32_t ipg); + bool getPortOperStatus(const Port& port, sai_port_oper_status_t& status) const; + private: unique_ptr m_counterTable; unique_ptr
m_counterLagTable; @@ -315,7 +317,6 @@ class PortsOrch : public Orch, public Subject task_process_status setPortInterfaceType(sai_object_id_t id, sai_port_interface_type_t interface_type); task_process_status setPortAdvInterfaceTypes(sai_object_id_t id, std::vector &interface_types); - bool getPortOperStatus(const Port& port, sai_port_oper_status_t& status) const; void updatePortOperStatus(Port &port, sai_port_oper_status_t status); bool getPortOperSpeed(const Port& port, sai_uint32_t& speed) const; @@ -356,4 +357,3 @@ class PortsOrch : public Orch, public Subject }; #endif /* SWSS_PORTSORCH_H */ - diff --git a/orchagent/saihelper.cpp b/orchagent/saihelper.cpp index 90578dc8a9..01e3e75150 100644 --- a/orchagent/saihelper.cpp +++ b/orchagent/saihelper.cpp @@ -57,6 +57,7 @@ sai_qos_map_api_t* sai_qos_map_api; sai_buffer_api_t* sai_buffer_api; sai_acl_api_t* sai_acl_api; sai_hash_api_t* sai_hash_api; +sai_udf_api_t* sai_udf_api; sai_mirror_api_t* sai_mirror_api; sai_fdb_api_t* sai_fdb_api; sai_dtel_api_t* sai_dtel_api; @@ -185,6 +186,7 @@ void initSaiApi() sai_api_query(SAI_API_SCHEDULER_GROUP, (void **)&sai_scheduler_group_api); sai_api_query(SAI_API_ACL, (void **)&sai_acl_api); sai_api_query(SAI_API_HASH, (void **)&sai_hash_api); + sai_api_query(SAI_API_UDF, (void **)&sai_udf_api); sai_api_query(SAI_API_DTEL, (void **)&sai_dtel_api); sai_api_query(SAI_API_SAMPLEPACKET, (void **)&sai_samplepacket_api); sai_api_query(SAI_API_DEBUG_COUNTER, (void **)&sai_debug_counter_api); @@ -221,6 +223,7 @@ void initSaiApi() sai_log_set(SAI_API_SCHEDULER_GROUP, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_ACL, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_HASH, SAI_LOG_LEVEL_NOTICE); + sai_log_set(SAI_API_UDF, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_DTEL, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_SAMPLEPACKET, SAI_LOG_LEVEL_NOTICE); sai_log_set(SAI_API_DEBUG_COUNTER, SAI_LOG_LEVEL_NOTICE); diff --git a/orchagent/switchorch.cpp b/orchagent/switchorch.cpp index 05a36ec87c..2d5ba93c9d 100644 --- a/orchagent/switchorch.cpp +++ b/orchagent/switchorch.cpp @@ -2,17 +2,21 @@ #include #include "switchorch.h" +#include "crmorch.h" #include "converter.h" #include "notifier.h" #include "notificationproducer.h" #include "macaddress.h" +#include "return_code.h" using namespace std; using namespace swss; extern sai_object_id_t gSwitchId; extern sai_switch_api_t *sai_switch_api; +extern sai_acl_api_t* sai_acl_api; extern MacAddress gVxlanMacAddress; +extern CrmOrch *gCrmOrch; const map switch_attribute_map = { @@ -55,6 +59,157 @@ SwitchOrch::SwitchOrch(DBConnector *db, vector& connectors, Tabl querySwitchTpidCapability(); auto executorT = new ExecutableTimer(m_sensorsPollerTimer, this, "ASIC_SENSORS_POLL_TIMER"); Orch::addExecutor(executorT); + initAclGroupsBindToSwitch(); +} + +void SwitchOrch::initAclGroupsBindToSwitch() +{ + // Create an ACL group per stage, INGRESS, EGRESS and PRE_INGRESS + for (auto stage_it : aclStageLookup) { + sai_object_id_t group_oid; + auto status = createAclGroup(fvValue(stage_it), &group_oid); + if (!status.ok()) + { + status.prepend("Failed to create ACL group for stage " + + fvField(stage_it) + ": "); + SWSS_LOG_THROW("%s", status.message().c_str()); + } + SWSS_LOG_NOTICE("Created ACL group for stage %s", + fvField(stage_it).c_str()); + m_aclGroups[fvValue(stage_it)] = group_oid; + status = bindAclGroupToSwitch(fvValue(stage_it), group_oid); + if (!status.ok()) + { + status.prepend("Failed to bind ACL group to stage " + + fvField(stage_it) + ": "); + SWSS_LOG_THROW("%s", status.message().c_str()); + } + } +} + +const std::map& + SwitchOrch::getAclGroupOidsBindingToSwitch() +{ + return m_aclGroups; +} + +ReturnCode SwitchOrch::createAclGroup(const sai_acl_stage_t& group_stage, + sai_object_id_t* acl_grp_oid) +{ + SWSS_LOG_ENTER(); + + std::vector acl_grp_attrs; + sai_attribute_t acl_grp_attr; + acl_grp_attr.id = SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE; + acl_grp_attr.value.s32 = group_stage; + acl_grp_attrs.push_back(acl_grp_attr); + + acl_grp_attr.id = SAI_ACL_TABLE_GROUP_ATTR_TYPE; + acl_grp_attr.value.s32 = SAI_ACL_TABLE_GROUP_TYPE_PARALLEL; + acl_grp_attrs.push_back(acl_grp_attr); + + acl_grp_attr.id = SAI_ACL_TABLE_ATTR_ACL_BIND_POINT_TYPE_LIST; + std::vector bpoint_list; + bpoint_list.push_back(SAI_ACL_BIND_POINT_TYPE_SWITCH); + acl_grp_attr.value.s32list.count = (uint32_t)bpoint_list.size(); + acl_grp_attr.value.s32list.list = bpoint_list.data(); + acl_grp_attrs.push_back(acl_grp_attr); + + CHECK_ERROR_AND_LOG_AND_RETURN( + sai_acl_api->create_acl_table_group(acl_grp_oid, gSwitchId, + (uint32_t)acl_grp_attrs.size(), + acl_grp_attrs.data()), + "Failed to create ACL group for stage " << group_stage); + if (group_stage == SAI_ACL_STAGE_INGRESS || + group_stage == SAI_ACL_STAGE_PRE_INGRESS || + group_stage == SAI_ACL_STAGE_EGRESS) + { + gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP, + (sai_acl_stage_t)group_stage, + SAI_ACL_BIND_POINT_TYPE_SWITCH); + } + SWSS_LOG_INFO("Suceeded to create ACL group %s in stage %d ", + sai_serialize_object_id(*acl_grp_oid).c_str(), group_stage); + return ReturnCode(); +} + +ReturnCode SwitchOrch::bindAclGroupToSwitch( + const sai_acl_stage_t& group_stage, const sai_object_id_t& acl_grp_oid) +{ + SWSS_LOG_ENTER(); + + auto switch_attr_it = aclStageToSwitchAttrLookup.find(group_stage); + if (switch_attr_it == aclStageToSwitchAttrLookup.end()) + { + LOG_ERROR_AND_RETURN(ReturnCode(StatusCode::SWSS_RC_INVALID_PARAM) + << "Failed to set ACL group(" << acl_grp_oid + << ") to the SWITCH bind point at stage " + << group_stage); + } + sai_attribute_t attr; + attr.id = switch_attr_it->second; + attr.value.oid = acl_grp_oid; + auto sai_status = sai_switch_api->set_switch_attribute(gSwitchId, &attr); + if (sai_status != SAI_STATUS_SUCCESS) + { + LOG_ERROR_AND_RETURN( + ReturnCode(sai_status) + << "[SAI] Failed to set_switch_attribute with attribute.id=" << attr.id + << " and acl group oid=" << acl_grp_oid); + } + return ReturnCode(); +} + +ReturnCode SwitchOrch::unbindAclGroupToSwitch( + const sai_acl_stage_t& group_stage) +{ + SWSS_LOG_ENTER(); + + return bindAclGroupToSwitch(group_stage, SAI_NULL_OBJECT_ID); +} + +ReturnCode SwitchOrch::removeAclGroup(const sai_acl_stage_t& group_stage) +{ + SWSS_LOG_ENTER(); + + auto group_it = m_aclGroups.find(group_stage); + if (group_it == m_aclGroups.end()) + { + LOG_ERROR_AND_RETURN( + ReturnCode(SAI_STATUS_INVALID_PARAMETER) + << "Failed to find ACL group by stage '" << group_stage << "'"); + } + CHECK_ERROR_AND_LOG_AND_RETURN( + sai_acl_api->remove_acl_table_group(group_it->second), + "Failed to create ACL group for stage " << group_stage); + if (group_stage == SAI_ACL_STAGE_INGRESS || + group_stage == SAI_ACL_STAGE_PRE_INGRESS || + group_stage == SAI_ACL_STAGE_EGRESS) + { + gCrmOrch->decCrmAclUsedCounter(CrmResourceType::CRM_ACL_GROUP, + (sai_acl_stage_t)group_stage, + SAI_ACL_BIND_POINT_TYPE_SWITCH, + group_it->second); + } + m_aclGroups.erase(group_stage); + SWSS_LOG_NOTICE("Suceeded to remove ACL group %s in stage %d ", + sai_serialize_object_id(group_it->second).c_str(), group_stage); + return ReturnCode(); +} + +ReturnCode SwitchOrch::removeAllAclGroups() +{ + SWSS_LOG_ENTER(); + + for (auto stage_it : aclStageLookup) + { + if (m_aclGroups.find(fvValue(stage_it)) != m_aclGroups.end()) + { + LOG_AND_RETURN_IF_ERROR(unbindAclGroupToSwitch(fvValue(stage_it))); + LOG_AND_RETURN_IF_ERROR(removeAclGroup(fvValue(stage_it))); + } + } + return ReturnCode(); } void SwitchOrch::doCfgSensorsTableTask(Consumer &consumer) diff --git a/orchagent/switchorch.h b/orchagent/switchorch.h index 86181e19df..fc1f35f3db 100644 --- a/orchagent/switchorch.h +++ b/orchagent/switchorch.h @@ -2,6 +2,7 @@ #include "orch.h" #include "timer.h" +#include "acltable.h" #define DEFAULT_ASIC_SENSORS_POLLER_INTERVAL 60 #define ASIC_SENSORS_POLLER_STATUS "ASIC_SENSORS_POLLER_STATUS" @@ -28,6 +29,10 @@ class SwitchOrch : public Orch void restartCheckReply(const std::string &op, const std::string &data, std::vector &values); bool setAgingFDB(uint32_t sec); void set_switch_capability(const std::vector& values); + + // Return reference to ACL group created for each stage and the bind point is + // the switch + const std::map& getAclGroupOidsBindingToSwitch(); private: void doTask(Consumer &consumer); void doTask(swss::SelectableTimer &timer); @@ -37,10 +42,34 @@ class SwitchOrch : public Orch void querySwitchTpidCapability(); sai_status_t setSwitchTunnelVxlanParams(swss::FieldValueTuple &val); + // Initialize the ACL groups bind to Switch + void initAclGroupsBindToSwitch(); + // Create the default ACL group for the given stage, bind point is + // SAI_ACL_BIND_POINT_TYPE_SWITCH and group type is + // SAI_ACL_TABLE_GROUP_TYPE_PARALLEL. + ReturnCode createAclGroup(const sai_acl_stage_t& group_stage, + sai_object_id_t* acl_grp_oid); + + // Bind the ACL group to switch for the given stage. + // Set the SAI_SWITCH_ATTR_{STAGE}_ACL with the group oid. + ReturnCode bindAclGroupToSwitch(const sai_acl_stage_t& group_stage, + const sai_object_id_t& acl_grp_oid); + + // Unbind the ACL group to switch for the given stage. + // Set the SAI_SWITCH_ATTR_{STAGE}_ACL to SAI_NULL_OBJECT_ID + ReturnCode unbindAclGroupToSwitch(const sai_acl_stage_t& group_stage); + + // Remove the ACL group on given stage if reference count is zero. + ReturnCode removeAclGroup(const sai_acl_stage_t& group_stage); + + // Remove all ACL groups on all stages. + ReturnCode removeAllAclGroups(); + swss::NotificationConsumer* m_restartCheckNotificationConsumer; void doTask(swss::NotificationConsumer& consumer); swss::DBConnector *m_db; swss::Table m_switchTable; + std::map m_aclGroups; sai_object_id_t m_switchTunnelId; // ASIC temperature sensors diff --git a/tests/conftest.py b/tests/conftest.py index 0ec6626fe9..51dff22325 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -145,6 +145,7 @@ def _populate_default_asic_db_values(self) -> None: self.default_acl_tables = self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE") self.default_acl_entries = self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ACL_ENTRY") + self.default_acl_groups = self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE_GROUP") self.default_copp_policers = self.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_POLICER") @@ -1208,6 +1209,7 @@ def get_asic_db(self) -> AsicDbValidator: db = DVSDatabase(self.ASIC_DB_ID, self.redis_sock) db.default_acl_tables = self.asicdb.default_acl_tables db.default_acl_entries = self.asicdb.default_acl_entries + db.default_acl_groups = self.asicdb.default_acl_groups db.default_copp_policers = self.asicdb.default_copp_policers db.port_name_map = self.asicdb.portnamemap db.default_vlan_id = self.asicdb.default_vlan_id @@ -1708,7 +1710,8 @@ def dvs_acl(request, dvs) -> DVSAcl: return DVSAcl(dvs.get_asic_db(), dvs.get_config_db(), dvs.get_state_db(), - dvs.get_counters_db()) + dvs.get_counters_db(), + dvs.get_app_db()) @pytest.fixture(scope="class") diff --git a/tests/dvslib/dvs_acl.py b/tests/dvslib/dvs_acl.py index dbf9791b53..b53725b74e 100644 --- a/tests/dvslib/dvs_acl.py +++ b/tests/dvslib/dvs_acl.py @@ -152,7 +152,12 @@ def get_acl_table_group_ids(self, expected: int) -> List[str]: Returns: The list of ACL group IDs in ASIC DB. """ - acl_table_groups = self.asic_db.wait_for_n_keys(self.ADB_ACL_GROUP_TABLE_NAME, expected) + num_keys = len(self.asic_db.default_acl_groups) + expected + keys = self.asic_db.wait_for_n_keys(self.ADB_ACL_GROUP_TABLE_NAME, num_keys) + for k in self.asic_db.default_acl_groups: + assert k in keys + + acl_table_groups = [k for k in keys if k not in self.asic_db.default_acl_groups] return acl_table_groups # FIXME: This method currently assumes only ingress xor egress tables exist. @@ -247,7 +252,7 @@ def verify_acl_table_port_binding( num_tables: The total number of ACL tables in ASIC DB. stage: The stage of the ACL table that was created. """ - acl_table_group_ids = self.asic_db.wait_for_n_keys(self.ADB_ACL_GROUP_TABLE_NAME, len(bind_ports)) + acl_table_group_ids = self.get_acl_table_group_ids(len(bind_ports)) port_groups = [] for port in bind_ports: diff --git a/tests/mock_tests/Makefile.am b/tests/mock_tests/Makefile.am index f1d02898f9..a36055e6d6 100644 --- a/tests/mock_tests/Makefile.am +++ b/tests/mock_tests/Makefile.am @@ -1,5 +1,6 @@ FLEX_CTR_DIR = $(top_srcdir)/orchagent/flex_counter DEBUG_CTR_DIR = $(top_srcdir)/orchagent/debug_counter +P4_ORCH_DIR = $(top_srcdir)/orchagent/p4orch INCLUDES = -I $(FLEX_CTR_DIR) -I $(DEBUG_CTR_DIR) -I $(top_srcdir)/lib @@ -83,6 +84,18 @@ tests_SOURCES = aclorch_ut.cpp \ tests_SOURCES += $(FLEX_CTR_DIR)/flex_counter_manager.cpp $(FLEX_CTR_DIR)/flex_counter_stat_manager.cpp tests_SOURCES += $(DEBUG_CTR_DIR)/debug_counter.cpp $(DEBUG_CTR_DIR)/drop_counter.cpp +tests_SOURCES += $(P4_ORCH_DIR)/p4orch.cpp \ + $(P4_ORCH_DIR)/p4orch_util.cpp \ + $(P4_ORCH_DIR)/p4oidmapper.cpp \ + $(P4_ORCH_DIR)/router_interface_manager.cpp \ + $(P4_ORCH_DIR)/neighbor_manager.cpp \ + $(P4_ORCH_DIR)/next_hop_manager.cpp \ + $(P4_ORCH_DIR)/route_manager.cpp \ + $(P4_ORCH_DIR)/acl_util.cpp \ + $(P4_ORCH_DIR)/acl_table_manager.cpp \ + $(P4_ORCH_DIR)/acl_rule_manager.cpp \ + $(P4_ORCH_DIR)/wcmp_manager.cpp \ + $(P4_ORCH_DIR)/mirror_session_manager.cpp tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) -I$(top_srcdir)/orchagent diff --git a/tests/mock_tests/aclorch_ut.cpp b/tests/mock_tests/aclorch_ut.cpp index d95ae2f87e..4530f8dd97 100644 --- a/tests/mock_tests/aclorch_ut.cpp +++ b/tests/mock_tests/aclorch_ut.cpp @@ -295,6 +295,9 @@ namespace aclorch_test gVirtualRouterId = attr.value.oid; + ASSERT_EQ(gCrmOrch, nullptr); + gCrmOrch = new CrmOrch(m_config_db.get(), CFG_CRM_TABLE_NAME); + TableConnector stateDbSwitchTable(m_state_db.get(), "SWITCH_CAPABILITY"); TableConnector conf_asic_sensors(m_config_db.get(), CFG_ASIC_SENSORS_TABLE_NAME); TableConnector app_switch_table(m_app_db.get(), APP_SWITCH_TABLE_NAME); @@ -322,9 +325,6 @@ namespace aclorch_test ASSERT_EQ(gPortsOrch, nullptr); gPortsOrch = new PortsOrch(m_app_db.get(), m_state_db.get(), ports_tables, m_chassis_app_db.get()); - ASSERT_EQ(gCrmOrch, nullptr); - gCrmOrch = new CrmOrch(m_config_db.get(), CFG_CRM_TABLE_NAME); - ASSERT_EQ(gVrfOrch, nullptr); gVrfOrch = new VRFOrch(m_app_db.get(), APP_VRF_TABLE_NAME, m_state_db.get(), STATE_VRF_OBJECT_TABLE_NAME); diff --git a/tests/mock_tests/mock_orchagent_main.h b/tests/mock_tests/mock_orchagent_main.h index 181ebac889..321f3d15d2 100644 --- a/tests/mock_tests/mock_orchagent_main.h +++ b/tests/mock_tests/mock_orchagent_main.h @@ -61,3 +61,4 @@ extern sai_next_hop_api_t *sai_next_hop_api; extern sai_hostif_api_t *sai_hostif_api; extern sai_buffer_api_t *sai_buffer_api; extern sai_queue_api_t *sai_queue_api; +extern sai_udf_api_t* sai_udf_api; diff --git a/tests/test_acl_mclag.py b/tests/test_acl_mclag.py index fd3b4c75e3..bcd6ba37b7 100644 --- a/tests/test_acl_mclag.py +++ b/tests/test_acl_mclag.py @@ -46,9 +46,9 @@ def get_acl_table_id(self, dvs): else: return None - def verify_acl_group_num(self, expt): + def verify_acl_group_num(self, dvs, expt): atbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE_GROUP") - acl_table_groups = atbl.getKeys() + acl_table_groups = [k for k in atbl.getKeys() if k not in dvs.asicdb.default_acl_groups] assert len(acl_table_groups) == expt for k in acl_table_groups: @@ -88,7 +88,7 @@ def verify_acl_group_member(self, acl_group_ids, acl_table_id): def verify_acl_port_binding(self, dvs, bind_ports): atbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE_GROUP") - acl_table_groups = atbl.getKeys() + acl_table_groups = [k for k in atbl.getKeys() if k not in dvs.asicdb.default_acl_groups] assert len(acl_table_groups) == len(bind_ports) atbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_PORT") @@ -126,11 +126,11 @@ def test_AclTableCreation(self, dvs, testlog): assert acl_table_id is not None # check acl table group in asic db - self.verify_acl_group_num(2) + self.verify_acl_group_num(dvs, 2) # get acl table group ids and verify the id numbers atbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ACL_TABLE_GROUP") - acl_group_ids = atbl.getKeys() + acl_group_ids = [k for k in atbl.getKeys() if k not in dvs.asicdb.default_acl_groups] assert len(acl_group_ids) == 2 # check acl table group member @@ -197,9 +197,9 @@ def test_AclRuleOutPorts(self, dvs, testlog): # check acl in asic db acl_table_id = self.get_acl_table_id(dvs) assert acl_table_id is None - - -# 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 + + +# 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