-
Notifications
You must be signed in to change notification settings - Fork 265
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
Conversation
… and using at() to get map entry
@kcudnik @qiluo The exception part. @qiluo-msft BTW , we need to make a agreement on whether adding db config file into build docker by default to make progress on next step. Kamil and I thought it is OK. |
common/dbconnector.cpp
Outdated
@@ -53,42 +53,44 @@ void SonicDBConfig::initialize(const string &file) | |||
{ | |||
throw runtime_error("Sonic database config file syntax error >> " + string(e.what())); | |||
} | |||
} else { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
@@ -53,42 +53,44 @@ void SonicDBConfig::initialize(const string &file) | |||
{ | |||
throw runtime_error("Sonic database config file syntax error >> " + string(e.what())); | |||
} | |||
} else { | |||
throw runtime_error("Sonic database config file doesn't exist at " + file); | |||
} | |||
} | |||
|
|||
string SonicDBConfig::getDbInst(const string &dbName) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
} | ||
} | ||
|
||
string SonicDBConfig::getDbInst(const string &dbName) | ||
{ | ||
if (!m_init) | ||
initialize(); | ||
return m_db_info[dbName].first; | ||
return m_db_info.at(dbName).first; | ||
} | ||
|
||
int SonicDBConfig::getDbId(const string &dbName) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comments
for each throw can you also add swss_log_error message to make mark in syslog if on someplace someone will forget to catch/log catched exception? |
Capture Logs When exception Thrown
UT tests:
|
Yes. Added. |
tests/redis_multi_db_ut.cpp
Outdated
EXPECT_FALSE(SonicDBConfig::isInit()); | ||
|
||
|
||
// load nonesist config file, should throw exception with file NO exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonesist [](start = 12, length = 8)
nonexisting_file #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor issue.
FIXED |
…#319) * [MultiDB]: throwing exception when database_config.json doesn't exist and using at() to get map entry * update file name * address code format * add UT and logs * fix typo
Signed-off-by: Dong Zhang d.zhang@alibaba-inc.com