Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[portsorch] Handle TRANSCEIVER_INFO table on warm boot #3087

Merged
merged 2 commits into from
Apr 8, 2024
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
1 change: 1 addition & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3391,6 +3391,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);
}
}
}
25 changes: 23 additions & 2 deletions tests/mock_tests/portsorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ namespace portsorch_test
}

};

/*
* Test port flap count
* Test port flap count
*/
TEST_F(PortsOrchTest, PortFlapCount)
{
Expand Down Expand Up @@ -1506,6 +1506,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 @@ -1539,6 +1540,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 @@ -1586,6 +1588,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
Loading