Skip to content

Commit

Permalink
Refine getDbId() calling to fix build after swss-common change (sonic…
Browse files Browse the repository at this point in the history
…-net#1245)

* Refine getDbId() calling to fix build after swss-common change

* Fix mock tests with multiDB support and config
  • Loading branch information
qiluo-msft authored and abdosi committed Aug 19, 2020
1 parent 1496233 commit 30ddd59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Consumer : public Executor {

int getDbId() const
{
return getConsumerTable()->getDbId();
return getConsumerTable()->getDbConnector()->getDbId();
}

std::string dumpTuple(swss::KeyOpFieldsValuesTuple &tuple);
Expand Down
1 change: 1 addition & 0 deletions tests/mock_tests/mock_dbconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace swss
}

DBConnector::DBConnector(const std::string& dbName, unsigned int timeout, bool isTcpConn)
: m_dbName(dbName)
{
if (swss::SonicDBConfig::isInit() == false)
swss::SonicDBConfig::initialize("./database_config.json");
Expand Down
8 changes: 4 additions & 4 deletions tests/mock_tests/mock_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace swss

bool Table::get(const std::string &key, std::vector<FieldValueTuple> &ovalues)
{
auto table = gDB[getDbId()][getTableName()];
auto table = gDB[m_pipe->getDbId()][getTableName()];
if (table.find(key) == table.end())
{
return false;
Expand All @@ -35,7 +35,7 @@ namespace swss

bool Table::hget(const std::string &key, const std::string &field, std::string &value)
{
auto table = gDB[getDbId()][getTableName()];
auto table = gDB[m_pipe->getDbId()][getTableName()];
if (table.find(key) == table.end())
{
return false;
Expand All @@ -58,14 +58,14 @@ namespace swss
const std::string &op,
const std::string &prefix)
{
auto &table = gDB[getDbId()][getTableName()];
auto &table = gDB[m_pipe->getDbId()][getTableName()];
table[key] = values;
}

void Table::getKeys(std::vector<std::string> &keys)
{
keys.clear();
auto table = gDB[getDbId()][getTableName()];
auto table = gDB[m_pipe->getDbId()][getTableName()];
for (const auto &it : table)
{
keys.push_back(it.first);
Expand Down

0 comments on commit 30ddd59

Please sign in to comment.