Skip to content

Commit

Permalink
Fix config save error for non-hash key. (#485)
Browse files Browse the repository at this point in the history
swss-common: Fix config save error for non-hash key

- Fixing #467
- Cleanup #465
  • Loading branch information
mint570 authored May 11, 2021
1 parent 42b394d commit 73d0e2d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 2 additions & 6 deletions common/configdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ int ConfigDBPipeConnector_Native::_get_config(DBConnector& client, RedisTransact
pipe.multi();
for (auto const& key: keys)
{
if (key == INIT_INDICATOR)
size_t pos = key.find(m_table_name_separator);
if (pos == string::npos)
{
continue;
}
Expand All @@ -413,11 +414,6 @@ int ConfigDBPipeConnector_Native::_get_config(DBConnector& client, RedisTransact

for (auto const& key: keys)
{
if (key == INIT_INDICATOR)
{
continue;
}

size_t pos = key.find(m_table_name_separator);
string table_name = key.substr(0, pos);
string row;
Expand Down
19 changes: 19 additions & 0 deletions tests/test_redis_ut.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,25 @@ def test_ConfigDBPipeConnector():
allconfig = config_db.get_config()
assert len(allconfig) == 0

def test_ConfigDBPipeConnectorSeparator():
db = swsscommon.DBConnector("CONFIG_DB", 0, True)
config_db = ConfigDBPipeConnector()
config_db.db_connect("CONFIG_DB", False, False)
config_db.get_redis_client(config_db.CONFIG_DB).flushdb()
config_db.set_entry("TEST_PORT", "Ethernet222", {"alias": "etp2x"})
db.set("ItemWithoutSeparator", "item11")
allconfig = config_db.get_config()
assert "TEST_PORT" in allconfig
assert "ItemWithoutSeparator" not in allconfig

alltable = config_db.get_table("*")
assert "Ethernet222" in alltable

config_db.delete_table("TEST_PORT")
db.delete("ItemWithoutSeparator")
allconfig = config_db.get_config()
assert len(allconfig) == 0

def test_ConfigDBScan():
config_db = ConfigDBPipeConnector()
config_db.connect(wait_for_init=False)
Expand Down

0 comments on commit 73d0e2d

Please sign in to comment.