Skip to content

Commit

Permalink
[202311][portsorch] Handle TRANSCEIVER_INFO table on warm boot (#3107)
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <[email protected]>
  • Loading branch information
stepanblyschak authored Apr 18, 2024
1 parent 8fd34c1 commit 5eadb79
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3367,6 +3367,7 @@ bool PortsOrch::bake()
addExistingData(APP_LAG_MEMBER_TABLE_NAME);
addExistingData(APP_VLAN_TABLE_NAME);
addExistingData(APP_VLAN_MEMBER_TABLE_NAME);
addExistingData(STATE_TRANSCEIVER_INFO_TABLE_NAME);

return true;
}
Expand Down
1 change: 1 addition & 0 deletions tests/mock_tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ tests_SOURCES = aclorch_ut.cpp \
mock_orchagent_main.cpp \
mock_dbconnector.cpp \
mock_consumerstatetable.cpp \
mock_subscriberstatetable.cpp \
common/mock_shell_command.cpp \
mock_table.cpp \
mock_hiredis.cpp \
Expand Down
30 changes: 30 additions & 0 deletions tests/mock_tests/mock_subscriberstatetable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "subscriberstatetable.h"

namespace swss
{
SubscriberStateTable::SubscriberStateTable(DBConnector *db, const std::string &tableName, int popBatchSize, int pri) :
ConsumerTableBase(db, tableName, popBatchSize, pri),
m_table(db, tableName)
{
}

void SubscriberStateTable::pops(std::deque<KeyOpFieldsValuesTuple> &vkco, const std::string& /*prefix*/)
{
std::vector<std::string> keys;
m_table.getKeys(keys);
for (const auto &key: keys)
{
KeyOpFieldsValuesTuple kco;

kfvKey(kco) = key;
kfvOp(kco) = SET_COMMAND;

if (!m_table.get(key, kfvFieldsValues(kco)))
{
continue;
}
m_table.del(key);
vkco.push_back(kco);
}
}
}
21 changes: 21 additions & 0 deletions tests/mock_tests/portsorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,7 @@ namespace portsorch_test
Table pgTable = Table(m_app_db.get(), APP_BUFFER_PG_TABLE_NAME);
Table profileTable = Table(m_app_db.get(), APP_BUFFER_PROFILE_TABLE_NAME);
Table poolTable = Table(m_app_db.get(), APP_BUFFER_POOL_TABLE_NAME);
Table transceieverInfoTable = Table(m_state_db.get(), STATE_TRANSCEIVER_INFO_TABLE_NAME);

// Get SAI default ports to populate DB

Expand Down Expand Up @@ -1444,6 +1445,7 @@ namespace portsorch_test
for (const auto &it : ports)
{
portTable.set(it.first, it.second);
transceieverInfoTable.set(it.first, {});
}

// Set PortConfigDone, PortInitDone
Expand Down Expand Up @@ -1491,6 +1493,25 @@ namespace portsorch_test

gBufferOrch->dumpPendingTasks(ts);
ASSERT_TRUE(ts.empty());

// Verify port configuration
vector<sai_object_id_t> port_list;
port_list.resize(ports.size());
sai_attribute_t attr;
sai_status_t status;
attr.id = SAI_SWITCH_ATTR_PORT_LIST;
attr.value.objlist.count = static_cast<uint32_t>(port_list.size());
attr.value.objlist.list = port_list.data();
status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr);
ASSERT_EQ(status, SAI_STATUS_SUCCESS);

for (uint32_t i = 0; i < port_list.size(); i++)
{
attr.id = SAI_PORT_ATTR_HOST_TX_SIGNAL_ENABLE;
status = sai_port_api->get_port_attribute(port_list[i], 1, &attr);
ASSERT_EQ(status, SAI_STATUS_SUCCESS);
ASSERT_TRUE(attr.value.booldata);
}
}

TEST_F(PortsOrchTest, PfcDlrHandlerCallingDlrInitAttribute)
Expand Down

0 comments on commit 5eadb79

Please sign in to comment.