diff --git a/sonic_data_client/client_test.go b/sonic_data_client/client_test.go index 6f864faf..031a84ff 100644 --- a/sonic_data_client/client_test.go +++ b/sonic_data_client/client_test.go @@ -309,28 +309,20 @@ func TestJsonRemoveNegative(t *testing.T) { } } -func TestParseTarget(t *testing.T) { +func TestParseDatabase(t *testing.T) { var test_paths []*gnmipb.Path var err error - _, err = ParseTarget("test", test_paths) - if err != nil { - t.Errorf("ParseTarget failed for empty path: %v", err) - } - - test_target := "TEST_DB" - path, err := xpath.ToGNMIPath("sonic-db:" + test_target + "/VLAN") + test_target := "APPL_DB" + test_inst := "dpu0" + path, err := xpath.ToGNMIPath("sonic-db:" + test_target + "/" + test_inst + "/VLAN") test_paths = append(test_paths, path) - target, err := ParseTarget("", test_paths) + target, inst, err := ParseDatabase(nil, test_paths) if err != nil { - t.Errorf("ParseTarget failed to get target: %v", err) + t.Errorf("ParseDatabase failed to get target: %v", err) } - if target != test_target { - t.Errorf("ParseTarget return wrong target: %v", target) - } - target, err = ParseTarget("INVALID_DB", test_paths) - if err == nil { - t.Errorf("ParseTarget should fail for conflict") + if target != test_target || inst != test_inst { + t.Errorf("ParseDatabase return wrong target: %v", target) } } @@ -386,7 +378,7 @@ func ReceiveFromZmq(consumer swsscommon.ZmqConsumerStateTable) (bool) { func TestZmqReconnect(t *testing.T) { // create ZMQ server - db := swsscommon.NewDBConnector(APPL_DB_NAME, SWSS_TIMEOUT, false) + db := swsscommon.NewDBConnector(PREV_APPL_DB_NAME, SWSS_TIMEOUT, false) zmqServer := swsscommon.NewZmqServer("tcp://*:1234") var TEST_TABLE string = "DASH_ROUTE" consumer := swsscommon.NewZmqConsumerStateTable(db, TEST_TABLE, zmqServer) @@ -394,7 +386,7 @@ func TestZmqReconnect(t *testing.T) { // create ZMQ client side zmqAddress := "tcp://127.0.0.1:1234" client := MixedDbClient { - applDB : swsscommon.NewDBConnector(APPL_DB_NAME, SWSS_TIMEOUT, false), + applDB : swsscommon.NewDBConnector(PREV_APPL_DB_NAME, SWSS_TIMEOUT, false), tableMap : map[string]swsscommon.ProducerStateTable{}, zmqClient : swsscommon.NewZmqClient(zmqAddress), } diff --git a/sonic_data_client/mixed_db_client.go b/sonic_data_client/mixed_db_client.go index f7666289..6ec1a306 100644 --- a/sonic_data_client/mixed_db_client.go +++ b/sonic_data_client/mixed_db_client.go @@ -30,6 +30,7 @@ import ( const REDIS_SOCK string = "/var/run/redis/redis.sock" const APPL_DB_NAME string = "DPU_APPL_DB" +const PREV_APPL_DB_NAME string = "APPL_DB" const DASH_TABLE_PREFIX string = "DASH_" const SWSS_TIMEOUT uint = 0 const MAX_RETRY_COUNT uint = 5 @@ -1137,7 +1138,7 @@ func (c *MixedDbClient) Set(delete []*gnmipb.Path, replace []*gnmipb.Update, upd return c.SetConfigDB(delete, replace, update) } else if c.target == APPL_DB_NAME { return c.SetDB(delete, replace, update) - } else if c.target == "APPL_DB" { + } else if c.target == PREV_APPL_DB_NAME { // Backward compatible return c.SetDB(delete, replace, update) }