Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liuh-80 committed Aug 30, 2023
1 parent 90ed89f commit e04a24c
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 17 deletions.
32 changes: 16 additions & 16 deletions tests/cli_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ TEST(sonic_db_cli, test_cli_multi_ns_cmd)
char *args[7];
args[0] = "sonic-db-cli";
args[1] = "-n";
args[2] = "asic0";
args[2] = "asic2";
args[3] = "TEST_DB";

// set key to test DB
Expand Down Expand Up @@ -409,7 +409,7 @@ TEST(sonic_db_cli, test_cli_unix_socket_cmd)
args[0] = "sonic-db-cli";
args[1] = "-s";
args[2] = "-n";
args[3] = "asic0";
args[3] = "asic2";
args[4] = "TEST_DB";

// set key to test DB
Expand All @@ -431,7 +431,7 @@ TEST(sonic_db_cli, test_cli_eval_cmd)
char *args[11];
args[0] = "sonic-db-cli";
args[1] = "-n";
args[2] = "asic0";
args[2] = "asic2";
args[3] = "TEST_DB";

// run eval command: EVAL "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}" 2 k1 k2 v1 v2
Expand All @@ -450,33 +450,33 @@ TEST(sonic_db_cli, test_parallel_cmd) {
char *args[7];
args[0] = "sonic-db-cli";
args[1] = "-n";
args[2] = "asic0";
args[2] = "asic2";
args[4] = "SAVE";

auto db_names = swss::SonicDBConfig::getDbList("asic0");
auto db_names = swss::SonicDBConfig::getDbList("asic2");
for (auto& db_name : db_names)
{
generateTestData("asic0", const_cast<char*>(db_name.c_str()));
generateTestData("asic2", const_cast<char*>(db_name.c_str()));
}
db_names = swss::SonicDBConfig::getDbList("asic1");
db_names = swss::SonicDBConfig::getDbList("asic3");
for (auto& db_name : db_names)
{
generateTestData("asic1", const_cast<char*>(db_name.c_str()));
generateTestData("asic3", const_cast<char*>(db_name.c_str()));
}

// save 2 DBs and get save DB performance
auto begin_time = clock();
db_names = swss::SonicDBConfig::getDbList("asic0");
args[2] = "asic0";
db_names = swss::SonicDBConfig::getDbList("asic2");
args[2] = "asic2";
for (auto& db_name : db_names)
{
args[3] = const_cast<char*>(db_name.c_str());
optind = 0;
sonic_db_cli(5, args);
}

db_names = swss::SonicDBConfig::getDbList("asic1");
args[2] = "asic1";
db_names = swss::SonicDBConfig::getDbList("asic3");
args[2] = "asic3";
for (auto& db_name : db_names)
{
args[3] = const_cast<char*>(db_name.c_str());
Expand All @@ -487,15 +487,15 @@ TEST(sonic_db_cli, test_parallel_cmd) {
auto sequential_time = float( clock () - begin_time );

// prepare data
db_names = swss::SonicDBConfig::getDbList("asic0");
db_names = swss::SonicDBConfig::getDbList("asic2");
for (auto& db_name : db_names)
{
generateTestData("asic0", const_cast<char*>(db_name.c_str()));
generateTestData("asic2", const_cast<char*>(db_name.c_str()));
}
db_names = swss::SonicDBConfig::getDbList("asic1");
db_names = swss::SonicDBConfig::getDbList("asic3");
for (auto& db_name : db_names)
{
generateTestData("asic0", const_cast<char*>(db_name.c_str()));
generateTestData("asic3", const_cast<char*>(db_name.c_str()));
}

// save 2 DBs in parallel, and get save DB performance
Expand Down
2 changes: 1 addition & 1 deletion tests/redis_multi_db_ut_config/database_config0.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"redis":{
"hostname" : "127.0.0.1",
"port": 6379,
"unix_socket_path": "/var/run/redis/redis.sock"
"unix_socket_path": "/var/run/redis0/redis.sock"
}
},
"DATABASES" : {
Expand Down
97 changes: 97 additions & 0 deletions tests/redis_multi_db_ut_config/database_config2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"INSTANCES": {
"redis":{
"hostname" : "127.0.0.1",
"port": 6379,
"unix_socket_path": "/var/run/redis/redis.sock"
}
},
"DATABASES" : {
"APPL_DB" : {
"id" : 0,
"separator": ":",
"instance" : "redis"
},
"ASIC_DB" : {
"id" : 1,
"separator": ":",
"instance" : "redis"
},
"COUNTERS_DB" : {
"id" : 2,
"separator": ":",
"instance" : "redis"
},
"LOGLEVEL_DB" : {
"id" : 3,
"separator": ":",
"instance" : "redis"
},
"CONFIG_DB" : {
"id" : 4,
"separator": "|",
"instance" : "redis"
},
"PFC_WD_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
},
"FLEX_COUNTER_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
},
"STATE_DB" : {
"id" : 6,
"separator": "|",
"instance" : "redis"
},
"SNMP_OVERLAY_DB" : {
"id" : 7,
"separator": "|",
"instance" : "redis"
},
"RESTAPI_DB": {
"id": 8,
"separator": "|",
"instance": "redis"
},
"GB_ASIC_DB": {
"id": 9,
"separator": ":",
"instance": "redis"
},
"GB_COUNTERS_DB": {
"id": 10,
"separator": ":",
"instance": "redis"
},
"GB_FLEX_COUNTER_DB": {
"id": 11,
"separator": ":",
"instance": "redis"
},
"PROFILE_DB" : {
"id" : 12,
"separator": "|",
"instance" : "redis"
},
"STATE_DB2" : {
"id" : 13,
"separator": "|",
"instance" : "redis"
},
"APPL_STATE_DB" : {
"id" : 14,
"separator": ":",
"instance" : "redis"
},
"TEST_DB" : {
"id" : 15,
"separator": ":",
"instance" : "redis"
}
},
"VERSION" : "1.0"
}
97 changes: 97 additions & 0 deletions tests/redis_multi_db_ut_config/database_config3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"INSTANCES": {
"redis":{
"hostname" : "127.0.0.1",
"port": 6379,
"unix_socket_path": "/var/run/redis/redis.sock"
}
},
"DATABASES" : {
"APPL_DB" : {
"id" : 0,
"separator": ":",
"instance" : "redis"
},
"ASIC_DB" : {
"id" : 1,
"separator": ":",
"instance" : "redis"
},
"COUNTERS_DB" : {
"id" : 2,
"separator": ":",
"instance" : "redis"
},
"LOGLEVEL_DB" : {
"id" : 3,
"separator": ":",
"instance" : "redis"
},
"CONFIG_DB" : {
"id" : 4,
"separator": "|",
"instance" : "redis"
},
"PFC_WD_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
},
"FLEX_COUNTER_DB" : {
"id" : 5,
"separator": ":",
"instance" : "redis"
},
"STATE_DB" : {
"id" : 6,
"separator": "|",
"instance" : "redis"
},
"SNMP_OVERLAY_DB" : {
"id" : 7,
"separator": "|",
"instance" : "redis"
},
"RESTAPI_DB": {
"id": 8,
"separator": "|",
"instance": "redis"
},
"GB_ASIC_DB": {
"id": 9,
"separator": ":",
"instance": "redis"
},
"GB_COUNTERS_DB": {
"id": 10,
"separator": ":",
"instance": "redis"
},
"GB_FLEX_COUNTER_DB": {
"id": 11,
"separator": ":",
"instance": "redis"
},
"PROFILE_DB" : {
"id" : 12,
"separator": "|",
"instance" : "redis"
},
"STATE_DB2" : {
"id" : 13,
"separator": "|",
"instance" : "redis"
},
"APPL_STATE_DB" : {
"id" : 14,
"separator": ":",
"instance" : "redis"
},
"TEST_DB" : {
"id" : 15,
"separator": ":",
"instance" : "redis"
}
},
"VERSION" : "1.0"
}
8 changes: 8 additions & 0 deletions tests/redis_multi_db_ut_config/database_global.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
{
"namespace" : "asic1",
"include" : "../redis_multi_db_ut_config/database_config1.json"
},
{
"namespace" : "asic2",
"include" : "../redis_multi_db_ut_config/database_config2.json"
},
{
"namespace" : "asic3",
"include" : "../redis_multi_db_ut_config/database_config3.json"
}
],
"VERSION" : "1.0"
Expand Down

0 comments on commit e04a24c

Please sign in to comment.