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

[MultiDB]: throwing exception when database_config.json doesn't exist #319

Merged
merged 6 commits into from
Dec 4, 2019
Merged
Changes from 2 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
12 changes: 7 additions & 5 deletions common/dbconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,44 @@ void SonicDBConfig::initialize(const string &file)
{
throw runtime_error("Sonic database config file syntax error >> " + string(e.what()));
}
} else {
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else { [](start = 4, length = 8)

follow code format nearby #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

throw runtime_error("Sonic database config file doesn't exist at " + file);
}
}

string SonicDBConfig::getDbInst(const string &dbName)
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDbInst [](start = 22, length = 9)

Add a unit test case for non existing dbName #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE. Added all five API test cases.

{
if (!m_init)
initialize();
return m_db_info[dbName].first;
return m_db_info.at(dbName).first;
}

int SonicDBConfig::getDbId(const string &dbName)
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDbId [](start = 19, length = 7)

Add a unit test case for non existing dbName #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE. Added all five API test cases.

{
if (!m_init)
initialize();
return m_db_info[dbName].second;
return m_db_info.at(dbName).second;
}

string SonicDBConfig::getDbSock(const string &dbName)
{
if (!m_init)
initialize();
return m_inst_info[getDbInst(dbName)].first;
return m_inst_info.at(getDbInst(dbName)).first;
}

string SonicDBConfig::getDbHostname(const string &dbName)
{
if (!m_init)
initialize();
return m_inst_info[getDbInst(dbName)].second.first;
return m_inst_info.at(getDbInst(dbName)).second.first;
}

int SonicDBConfig::getDbPort(const string &dbName)
{
if (!m_init)
initialize();
return m_inst_info[getDbInst(dbName)].second.second;
return m_inst_info.at(getDbInst(dbName)).second.second;
}

constexpr const char *SonicDBConfig::DEFAULT_SONIC_DB_CONFIG_FILE;
Expand Down