Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure-pipelines/gcov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parameters:

- name: timeout
type: number
default: 180
default: 240

- name: sonic_slave
type: string
Expand Down
6 changes: 5 additions & 1 deletion orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ INCLUDES = -I $(top_srcdir)/lib \
-I pbh \
-I nhg

if GCOV_ENABLED
SUBDIRS = p4orch/tests
endif

CFLAGS_SAI = -I /usr/include/sai

swssdir = $(datadir)/swss
Expand All @@ -18,7 +22,7 @@ dist_swss_DATA = \
pfc_detect_barefoot.lua \
pfc_detect_nephos.lua \
pfc_detect_cisco-8000.lua \
pfc_detect_vs.lua \
pfc_detect_vs.lua \
pfc_restore.lua \
pfc_restore_cisco-8000.lua \
port_rates.lua \
Expand Down
5 changes: 4 additions & 1 deletion orchagent/flex_counter/flex_counter_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ FlexCounterManager::~FlexCounterManager()
flex_counter_table->del(getFlexCounterTableKey(group_name, counter));
}

flex_counter_group_table->del(group_name);
if (flex_counter_group_table != nullptr)
{
flex_counter_group_table->del(group_name);
}

SWSS_LOG_DEBUG("Deleted flex counter group '%s'.", group_name.c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/flexcounterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FlexCounterOrch: public Orch
std::shared_ptr<swss::DBConnector> m_flexCounterDb = nullptr;
std::shared_ptr<swss::ProducerTable> m_flexCounterGroupTable = nullptr;
std::shared_ptr<swss::DBConnector> m_gbflexCounterDb = nullptr;
shared_ptr<ProducerTable> m_gbflexCounterGroupTable = nullptr;
std::shared_ptr<ProducerTable> m_gbflexCounterGroupTable = nullptr;
bool m_port_counter_enabled = false;
bool m_port_buffer_drop_counter_enabled = false;
bool m_hostif_trap_counter_enabled = false;
Expand Down
9 changes: 7 additions & 2 deletions orchagent/p4orch/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ INCLUDES = -I $(top_srcdir) -I $(ORCHAGENT_DIR) -I $(P4ORCH_DIR) -I $(top_srcdir

CFLAGS_SAI = -I /usr/include/sai

bin_PROGRAMS = p4orch_tests p4orch_tests_asan p4orch_tests_tsan p4orch_tests_usan
TESTS = p4orch_tests p4orch_tests_asan p4orch_tests_tsan p4orch_tests_usan

noinst_PROGRAMS = p4orch_tests p4orch_tests_asan p4orch_tests_tsan p4orch_tests_usan

if DEBUG
DBGFLAGS = -ggdb -DDEBUG
Expand All @@ -27,6 +29,7 @@ p4orch_tests_SOURCES = $(ORCHAGENT_DIR)/orch.cpp \
$(ORCHAGENT_DIR)/switchorch.cpp \
$(ORCHAGENT_DIR)/request_parser.cpp \
$(ORCHAGENT_DIR)/flex_counter/flex_counter_manager.cpp \
$(ORCHAGENT_DIR)/flex_counter/flow_counter_handler.cpp \
$(P4ORCH_DIR)/p4oidmapper.cpp \
$(P4ORCH_DIR)/p4orch.cpp \
$(P4ORCH_DIR)/p4orch_util.cpp \
Expand All @@ -39,9 +42,11 @@ p4orch_tests_SOURCES = $(ORCHAGENT_DIR)/orch.cpp \
$(P4ORCH_DIR)/acl_rule_manager.cpp \
$(P4ORCH_DIR)/wcmp_manager.cpp \
$(P4ORCH_DIR)/mirror_session_manager.cpp \
$(top_srcdir)/tests/mock_tests/fake_response_publisher.cpp \
$(top_srcdir)/tests/mock_tests/fake_response_publisher.cpp \
fake_portorch.cpp \
fake_crmorch.cpp \
fake_flexcounterorch.cpp \
fake_flowcounterrouteorch.cpp \
fake_dbconnector.cpp \
fake_producertable.cpp \
fake_consumerstatetable.cpp \
Expand Down
30 changes: 30 additions & 0 deletions orchagent/p4orch/tests/fake_flexcounterorch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "copporch.h"
#include "flexcounterorch.h"

FlexCounterOrch::FlexCounterOrch(swss::DBConnector *db, std::vector<std::string> &tableNames)
: Orch(db, tableNames), m_flexCounterConfigTable(db, CFG_FLEX_COUNTER_TABLE_NAME)
{
}

FlexCounterOrch::~FlexCounterOrch(void)
{
}

void FlexCounterOrch::doTask(Consumer &consumer)
{
}

bool FlexCounterOrch::getPortCountersState() const
{
return true;
}

bool FlexCounterOrch::getPortBufferDropCountersState() const
{
return true;
}

bool FlexCounterOrch::bake()
{
return true;
}
178 changes: 178 additions & 0 deletions orchagent/p4orch/tests/fake_flowcounterrouteorch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#include "copporch.h"
#include "flowcounterrouteorch.h"

extern size_t gMaxBulkSize;
extern sai_route_api_t *sai_route_api;

#define ROUTE_FLOW_COUNTER_POLLING_INTERVAL_MS 10000

FlowCounterRouteOrch::FlowCounterRouteOrch(swss::DBConnector *db, const std::vector<std::string> &tableNames)
: Orch(db, tableNames), mRouteFlowCounterMgr(ROUTE_FLOW_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ,
ROUTE_FLOW_COUNTER_POLLING_INTERVAL_MS, false),
gRouteBulker(sai_route_api, gMaxBulkSize)
{
}

FlowCounterRouteOrch::~FlowCounterRouteOrch(void)
{
}

void FlowCounterRouteOrch::generateRouteFlowStats()
{
}

void FlowCounterRouteOrch::clearRouteFlowStats()
{
}

void FlowCounterRouteOrch::addRoutePattern(const std::string &pattern, size_t)
{
}

void FlowCounterRouteOrch::removeRoutePattern(const std::string &pattern)
{
}

void FlowCounterRouteOrch::onAddMiscRouteEntry(sai_object_id_t vrf_id, const IpPrefix &ip_prefix, bool add_to_cache)
{
}

void FlowCounterRouteOrch::onAddMiscRouteEntry(sai_object_id_t vrf_id, const sai_ip_prefix_t &ip_pfx, bool add_to_cache)
{
}

void FlowCounterRouteOrch::onRemoveMiscRouteEntry(sai_object_id_t vrf_id, const IpPrefix &ip_prefix,
bool remove_from_cache)
{
}

void FlowCounterRouteOrch::onRemoveMiscRouteEntry(sai_object_id_t vrf_id, const sai_ip_prefix_t &ip_pfx,
bool remove_from_cache)
{
}

void FlowCounterRouteOrch::onAddVR(sai_object_id_t vrf_id)
{
}

void FlowCounterRouteOrch::onRemoveVR(sai_object_id_t vrf_id)
{
}

void FlowCounterRouteOrch::handleRouteAdd(sai_object_id_t vrf_id, const IpPrefix &ip_prefix)
{
}

void FlowCounterRouteOrch::handleRouteRemove(sai_object_id_t vrf_id, const IpPrefix &ip_prefix)
{
}

void FlowCounterRouteOrch::processRouteFlowCounterBinding()
{
}

void FlowCounterRouteOrch::doTask(Consumer &consumer)
{
}

void FlowCounterRouteOrch::doTask(SelectableTimer &timer)
{
}

void FlowCounterRouteOrch::initRouteFlowCounterCapability()
{
}

void FlowCounterRouteOrch::removeRoutePattern(const RoutePattern &route_pattern)
{
}

void FlowCounterRouteOrch::removeRouteFlowCounterFromDB(sai_object_id_t vrf_id, const IpPrefix &ip_prefix,
sai_object_id_t counter_oid)
{
}

bool FlowCounterRouteOrch::bindFlowCounter(const RoutePattern &route_pattern, sai_object_id_t vrf_id,
const IpPrefix &ip_prefix)
{
return true;
}

void FlowCounterRouteOrch::unbindFlowCounter(const RoutePattern &route_pattern, sai_object_id_t vrf_id,
const IpPrefix &ip_prefix, sai_object_id_t counter_oid)
{
}

void FlowCounterRouteOrch::pendingUpdateFlexDb(const RoutePattern &route_pattern, const IpPrefix &ip_prefix,
sai_object_id_t counter_oid)
{
}

void FlowCounterRouteOrch::updateRouterFlowCounterCache(const RoutePattern &route_pattern, const IpPrefix &ip_prefix,
sai_object_id_t counter_oid, RouterFlowCounterCache &cache)
{
}

bool FlowCounterRouteOrch::validateRoutePattern(const RoutePattern &route_pattern) const
{
return true;
}

void FlowCounterRouteOrch::onRoutePatternMaxMatchCountChange(RoutePattern &route_pattern, size_t new_max_match_count)
{
}

bool FlowCounterRouteOrch::isRouteAlreadyBound(const RoutePattern &route_pattern, const IpPrefix &ip_prefix) const
{
return true;
}

void FlowCounterRouteOrch::createRouteFlowCounterByPattern(const RoutePattern &route_pattern, size_t currentBoundCount)
{
}

bool FlowCounterRouteOrch::removeRouteFlowCounter(const RoutePattern &route_pattern, sai_object_id_t vrf_id,
const IpPrefix &ip_prefix)
{
return true;
}

void FlowCounterRouteOrch::createRouteFlowCounterFromVnetRoutes(const RoutePattern &route_pattern,
size_t &current_bound_count)
{
}

void FlowCounterRouteOrch::reapRouteFlowCounterByPattern(const RoutePattern &route_pattern, size_t currentBoundCount)
{
}

bool FlowCounterRouteOrch::isRouteFlowCounterEnabled() const
{
return true;
}

void FlowCounterRouteOrch::getRouteFlowCounterNameMapKey(sai_object_id_t vrf_id, const IpPrefix &ip_prefix,
std::string &key)
{
}

size_t FlowCounterRouteOrch::getRouteFlowCounterSizeByPattern(const RoutePattern &route_pattern) const
{
return 0;
}

bool FlowCounterRouteOrch::parseRouteKeyForRoutePattern(const std::string &key, char sep, sai_object_id_t &vrf_id,
IpPrefix &ip_prefix, std::string &vrf_name)
{
return true;
}

bool FlowCounterRouteOrch::getVrfIdByVnetName(const std::string &vnet_name, sai_object_id_t &vrf_id)
{
return true;
}

bool FlowCounterRouteOrch::getVnetNameByVrfId(sai_object_id_t vrf_id, std::string &vnet_name)
{
return true;
}
7 changes: 4 additions & 3 deletions orchagent/p4orch/tests/fake_portorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ bool PortsOrch::removeAclTableGroup(const Port &p)
return true;
}

bool PortsOrch::addSubPort(Port &port, const string &alias, const bool &adminUp, const uint32_t &mtu)
bool PortsOrch::addSubPort(Port &port, const string &alias, const string &vlan, const bool &adminUp,
const uint32_t &mtu)
{
return true;
}
Expand Down Expand Up @@ -400,7 +401,7 @@ void PortsOrch::initializePriorityGroups(Port &port)
{
}

void PortsOrch::initializePortMaximumHeadroom(Port &port)
void PortsOrch::initializePortBufferMaximumParameters(Port &port)
{
}

Expand Down Expand Up @@ -685,7 +686,7 @@ void PortsOrch::voqSyncDelLagMember(Port &lag, Port &port)
{
}

std::unordered_set<std::string> PortsOrch::generateCounterStats(const string &type)
std::unordered_set<std::string> PortsOrch::generateCounterStats(const string &type, bool gearbox)
{
return {};
}
16 changes: 16 additions & 0 deletions orchagent/p4orch/tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern "C"
#include "crmorch.h"
#include "dbconnector.h"
#include "directory.h"
#include "flowcounterrouteorch.h"
#include "mock_sai_virtual_router.h"
#include "p4orch.h"
#include "portsorch.h"
Expand All @@ -37,6 +38,8 @@ sai_object_id_t gUnderlayIfId;

#define DEFAULT_BATCH_SIZE 128
int gBatchSize = DEFAULT_BATCH_SIZE;
#define DEFAULT_MAX_BULK_SIZE 1000
size_t gMaxBulkSize = DEFAULT_MAX_BULK_SIZE;
bool gSairedisRecord = true;
bool gSwssRecord = true;
bool gLogRotate = false;
Expand All @@ -50,6 +53,7 @@ PortsOrch *gPortsOrch;
CrmOrch *gCrmOrch;
P4Orch *gP4Orch;
VRFOrch *gVrfOrch;
FlowCounterRouteOrch *gFlowCounterRouteOrch;
SwitchOrch *gSwitchOrch;
Directory<Orch *> gDirectory;
ofstream gRecordOfs;
Expand All @@ -73,6 +77,8 @@ sai_switch_api_t *sai_switch_api;
sai_mirror_api_t *sai_mirror_api;
sai_udf_api_t *sai_udf_api;
sai_tunnel_api_t *sai_tunnel_api;
sai_my_mac_api_t *sai_my_mac_api;
sai_counter_api_t *sai_counter_api;

namespace
{
Expand Down Expand Up @@ -162,6 +168,9 @@ int main(int argc, char *argv[])
sai_switch_api_t switch_api;
sai_mirror_api_t mirror_api;
sai_udf_api_t udf_api;
sai_my_mac_api_t my_mac_api;
sai_tunnel_api_t tunnel_api;
sai_counter_api_t counter_api;
sai_router_intfs_api = &router_intfs_api;
sai_neighbor_api = &neighbor_api;
sai_next_hop_api = &next_hop_api;
Expand All @@ -174,6 +183,9 @@ int main(int argc, char *argv[])
sai_switch_api = &switch_api;
sai_mirror_api = &mirror_api;
sai_udf_api = &udf_api;
sai_my_mac_api = &my_mac_api;
sai_tunnel_api = &tunnel_api;
sai_counter_api = &counter_api;

swss::DBConnector appl_db("APPL_DB", 0);
swss::DBConnector state_db("STATE_DB", 0);
Expand All @@ -193,6 +205,10 @@ int main(int argc, char *argv[])
gVrfOrch = &vrf_orch;
gDirectory.set(static_cast<VRFOrch *>(&vrf_orch));

FlowCounterRouteOrch flow_counter_route_orch(gConfigDb, std::vector<std::string>{});
gFlowCounterRouteOrch = &flow_counter_route_orch;
gDirectory.set(static_cast<FlowCounterRouteOrch *>(&flow_counter_route_orch));

// Setup ports for all tests.
SetupPorts();
AddVrf();
Expand Down
Loading