From 6b63a50c68165f26cfd930a154c77efd97d85ab1 Mon Sep 17 00:00:00 2001 From: ganglv <88995770+ganglyu@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:04:56 +0800 Subject: [PATCH] Update DB connector to use dbkey (#214) Why I did it GNMI is using wrong NewDBConnector API. How I did it Specify dbkey in NewDBConnector API. How to verify it Run unit test and end to end test. --- sonic_data_client/mixed_db_client.go | 2 +- sonic_db_config/db_config_test.go | 4 ++-- testdata/database_config_dpu.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sonic_data_client/mixed_db_client.go b/sonic_data_client/mixed_db_client.go index a47ca7e8..02b2bb94 100644 --- a/sonic_data_client/mixed_db_client.go +++ b/sonic_data_client/mixed_db_client.go @@ -501,7 +501,7 @@ func NewMixedDbClient(paths []*gnmipb.Path, prefix *gnmipb.Path, origin string, // If target is DPU_APPL_DB, this is multiple database, create DB connector for DPU // If target is original APPL_DB, create DB connector for backward compatibility if target == DPU_APPL_DB_NAME || target == APPL_DB_NAME { - client.applDB = swsscommon.NewDBConnector(target, SWSS_TIMEOUT, false) + client.applDB = swsscommon.NewDBConnector(target, SWSS_TIMEOUT, false, dbkey) } client.target = target client.dbkey = dbkey diff --git a/sonic_db_config/db_config_test.go b/sonic_db_config/db_config_test.go index 1bad1de1..0d26548b 100644 --- a/sonic_db_config/db_config_test.go +++ b/sonic_db_config/db_config_test.go @@ -210,8 +210,8 @@ func TestGetDbMultiInstance(t *testing.T) { }) t.Run("Sock", func(t *testing.T) { sock_path, _ := GetDbSockByDBKey("CONFIG_DB", dbkey) - if sock_path != "/var/run/redis0/redis.sock" { - t.Fatalf(`Sock("") = %q, want "/var/run/redis0/redis.sock", error`, sock_path) + if sock_path != "/var/run/redis/redis.sock" { + t.Fatalf(`Sock("") = %q, want "/var/run/redis/redis.sock", error`, sock_path) } }) t.Run("AllInstances", func(t *testing.T) { diff --git a/testdata/database_config_dpu.json b/testdata/database_config_dpu.json index 96ec3d79..7b11da31 100644 --- a/testdata/database_config_dpu.json +++ b/testdata/database_config_dpu.json @@ -3,7 +3,7 @@ "redis":{ "hostname" : "127.0.0.1", "port" : 6379, - "unix_socket_path" : "/var/run/redis0/redis.sock" + "unix_socket_path" : "/var/run/redis/redis.sock" } }, "DATABASES" : {