Skip to content

Commit

Permalink
Merge branch 'master' into bulk_switchover
Browse files Browse the repository at this point in the history
  • Loading branch information
prsunny authored May 30, 2024
2 parents 7c2bcbb + c7ecd7d commit 11f1674
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 11 deletions.
7 changes: 7 additions & 0 deletions cfgmgr/fabricmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void FabricMgr::doTask(Consumer &consumer)
string monPollThreshRecovery, monPollThreshIsolation;
string isolateStatus;
string alias, lanes;
string enable;
std::vector<FieldValueTuple> field_values;
string value;

Expand All @@ -66,6 +67,12 @@ void FabricMgr::doTask(Consumer &consumer)
monPollThreshIsolation = fvValue(i);
writeConfigToAppDb(key, "monPollThreshIsolation", monPollThreshIsolation);
}
else if (fvField(i) == "monState")
{
SWSS_LOG_INFO("Enable fabric monitoring setting in appl_db.");
enable = fvValue(i);
writeConfigToAppDb(key, "monState", enable);
}
else if (fvField(i) == "alias")
{
alias = fvValue(i);
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/fabricmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FabricMgr : public Orch
private:
Table m_cfgFabricMonitorTable;
Table m_cfgFabricPortTable;
Table m_appFabricMonitorTable;
ProducerStateTable m_appFabricMonitorTable;
ProducerStateTable m_appFabricPortTable;

void doTask(Consumer &consumer);
Expand Down
66 changes: 64 additions & 2 deletions orchagent/fabricportsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,36 @@ FabricPortsOrch::FabricPortsOrch(DBConnector *appl_db, vector<table_name_with_pr

auto debug_executor = new ExecutableTimer(m_debugTimer, this, "FABRIC_DEBUG_POLL");
Orch::addExecutor(debug_executor);
m_debugTimer->start();
bool fabricPortMonitor = checkFabricPortMonState();
if (fabricPortMonitor)
{
m_debugTimer->start();
SWSS_LOG_INFO("Fabric monitor starts at init time");
}
}

bool FabricPortsOrch::checkFabricPortMonState()
{
bool enabled = false;
std::vector<FieldValueTuple> constValues;
bool setCfgVal = m_applMonitorConstTable->get("FABRIC_MONITOR_DATA", constValues);
if (!setCfgVal)
{
return enabled;
}
SWSS_LOG_INFO("FabricPortsOrch::checkFabricPortMonState starts");
for (auto cv : constValues)
{
if (fvField(cv) == "monState")
{
if (fvValue(cv) == "enable")
{
enabled = true;
return enabled;
}
}
}
return enabled;
}

int FabricPortsOrch::getFabricPortList()
Expand Down Expand Up @@ -1188,7 +1217,12 @@ void FabricPortsOrch::doTask()

void FabricPortsOrch::doFabricPortTask(Consumer &consumer)
{
SWSS_LOG_NOTICE("FabricPortsOrch::doFabricPortTask");
if (!checkFabricPortMonState())
{
SWSS_LOG_INFO("doFabricPortTask returns early due to feature disabled");
return;
}
SWSS_LOG_INFO("FabricPortsOrch::doFabricPortTask starts");
auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
Expand Down Expand Up @@ -1350,11 +1384,38 @@ void FabricPortsOrch::doTask(Consumer &consumer)
SWSS_LOG_NOTICE("doTask from FabricPortsOrch");

string table_name = consumer.getTableName();
SWSS_LOG_INFO("Table name: %s", table_name.c_str());

if (table_name == APP_FABRIC_MONITOR_PORT_TABLE_NAME)
{
doFabricPortTask(consumer);
}
if (table_name == APP_FABRIC_MONITOR_DATA_TABLE_NAME)
{
SWSS_LOG_INFO("doTask for APP_FABRIC_MONITOR_DATA_TABLE_NAME");
auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;
for (auto i : kfvFieldsValues(t))
{
if (fvField(i) == "monState")
{
if (fvValue(i) == "enable")
{
m_debugTimer->start();
SWSS_LOG_INFO("debugTimer started");
}
else
{
m_debugTimer->stop();
SWSS_LOG_INFO("debugTimer stopped");
}
}
}
it = consumer.m_toSync.erase(it);
}
}
}

void FabricPortsOrch::doTask(swss::SelectableTimer &timer)
Expand Down Expand Up @@ -1384,6 +1445,7 @@ void FabricPortsOrch::doTask(swss::SelectableTimer &timer)

if (m_getFabricPortListDone)
{
SWSS_LOG_INFO("Fabric monitor enabled");
updateFabricDebugCounters();
updateFabricCapacity();
updateFabricRate();
Expand Down
1 change: 1 addition & 0 deletions orchagent/fabricportsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class FabricPortsOrch : public Orch, public Subject
void updateFabricPortState();
void updateFabricDebugCounters();
void updateFabricCapacity();
bool checkFabricPortMonState();
void updateFabricRate();

void doTask() override;
Expand Down
7 changes: 5 additions & 2 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using namespace swss;
#define PFC_WD_POLL_MSECS 100

#define APP_FABRIC_MONITOR_PORT_TABLE_NAME "FABRIC_PORT_TABLE"
#define APP_FABRIC_MONITOR_DATA_TABLE_NAME "FABRIC_MONITOR_TABLE"

/* orchagent heart beat message interval */
#define HEART_BEAT_INTERVAL_MSECS 10 * 1000
Expand Down Expand Up @@ -527,7 +528,8 @@ bool OrchDaemon::init()
// register APP_FABRIC_MONITOR_PORT_TABLE_NAME table
const int fabric_portsorch_base_pri = 30;
vector<table_name_with_pri_t> fabric_port_tables = {
{ APP_FABRIC_MONITOR_PORT_TABLE_NAME, fabric_portsorch_base_pri }
{ APP_FABRIC_MONITOR_PORT_TABLE_NAME, fabric_portsorch_base_pri },
{ APP_FABRIC_MONITOR_DATA_TABLE_NAME, fabric_portsorch_base_pri }
};
gFabricPortsOrch = new FabricPortsOrch(m_applDb, fabric_port_tables, m_fabricPortStatEnabled, m_fabricQueueStatEnabled);
m_orchList.push_back(gFabricPortsOrch);
Expand Down Expand Up @@ -1088,7 +1090,8 @@ bool FabricOrchDaemon::init()

const int fabric_portsorch_base_pri = 30;
vector<table_name_with_pri_t> fabric_port_tables = {
{ APP_FABRIC_MONITOR_PORT_TABLE_NAME, fabric_portsorch_base_pri }
{ APP_FABRIC_MONITOR_PORT_TABLE_NAME, fabric_portsorch_base_pri },
{ APP_FABRIC_MONITOR_DATA_TABLE_NAME, fabric_portsorch_base_pri }
};
gFabricPortsOrch = new FabricPortsOrch(m_applDb, fabric_port_tables);
addOrchList(gFabricPortsOrch);
Expand Down
7 changes: 5 additions & 2 deletions tests/test_fabric_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def test_voq_switch_fabric_capacity(self, vst):
cfg_switch_type = metatbl.get("switch_type")
if cfg_switch_type == "fabric":

max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
adb = dvs.get_app_db()
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'}, polling_config=max_poll)

# get state_db infor
sdb = dvs.get_state_db()
# There are 16 fabric ports in the test environment.
Expand All @@ -30,8 +35,6 @@ def test_voq_switch_fabric_capacity(self, vst):
cdb_port = "Fabric"+str(portNum)
sdb_port = "PORT"+str(portNum)

max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)

# setup test environment
sdb.update_entry("FABRIC_PORT_TABLE", sdb_port, {"TEST": "TEST"})

Expand Down
11 changes: 9 additions & 2 deletions tests/test_fabric_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ def test_voq_switch_fabric_link(self, vst):
cfg_switch_type = metatbl.get("switch_type")
if cfg_switch_type == "fabric":

# get config_db information
# get app_db/config_db information
cdb = dvs.get_config_db()
adb = dvs.get_app_db()

# check if the fabric montior toggle working
cdb.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'disable'})
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'disable'})

cdb.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'})

# set config_db to isolateStatus: True
cdb.update_entry("FABRIC_PORT", "Fabric1", {"isolateStatus": "True"})
cdb.wait_for_field_match("FABRIC_PORT", "Fabric1", {"isolateStatus": "True"})

# check if appl_db value changes to isolateStatus: True
adb = dvs.get_app_db()
adb.wait_for_field_match("FABRIC_PORT_TABLE", "Fabric1", {"isolateStatus": "True"})

# cleanup
Expand Down
6 changes: 5 additions & 1 deletion tests/test_fabric_port_isolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def test_voq_switch_fabric_link(self, vst):
cfg_switch_type = metatbl.get("switch_type")
if cfg_switch_type == "fabric":

max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
adb = dvs.get_app_db()
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'}, polling_config=max_poll)

# get state_db infor
sdb = dvs.get_state_db()
# key
Expand All @@ -30,7 +35,6 @@ def test_voq_switch_fabric_link(self, vst):
port = "PORT"+str(portNum)
# wait for link monitoring algorithm skips init pollings
sdb.update_entry("FABRIC_PORT_TABLE", port, {"TEST": "TEST"})
max_poll = PollingConfig(polling_interval=60, timeout=1200, strict=True)
if sdb.get_entry("FABRIC_PORT_TABLE", port)['STATUS'] == 'up':
try:
# clean up the system for the testing port.
Expand Down
5 changes: 4 additions & 1 deletion tests/test_fabric_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def test_voq_switch_fabric_rate(self, vst):
cfg_switch_type = metatbl.get("switch_type")
if cfg_switch_type == "fabric":

max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
adb = dvs.get_app_db()
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'}, polling_config=max_poll)
# get state_db infor
sdb = dvs.get_state_db()

Expand All @@ -31,7 +35,6 @@ def test_voq_switch_fabric_rate(self, vst):
portNum = random.randint(1, 16)
sdb_port = "PORT"+str(portNum)

max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
tx_rate = sdb.get_entry("FABRIC_PORT_TABLE", sdb_port)['OLD_TX_DATA']
sdb.update_entry("FABRIC_PORT_TABLE", sdb_port, {"TEST": "TEST"})
sdb.wait_for_field_negative_match("FABRIC_PORT_TABLE", sdb_port, {'OLD_TX_DATA': tx_rate}, polling_config=max_poll)
Expand Down

0 comments on commit 11f1674

Please sign in to comment.