Skip to content

Commit

Permalink
not4review
Browse files Browse the repository at this point in the history
  • Loading branch information
FengPan-Frank committed Feb 20, 2025
1 parent e06ff6c commit ffdcd40
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions proto/sonic.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions sonic_db_config/db_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,37 @@ func TestGetDb(t *testing.T) {
})
}

func TestGetBMPDb(t *testing.T) {
ns, _ := GetDbDefaultNamespace()
t.Run("Id", func(t *testing.T) {
db_id, _ := GetDbId("BMP_STATE_DB", ns)
if db_id != 20 {
t.Fatalf(`Id("") = %d, want 20, error`, db_id)
}
})
t.Run("Sock", func(t *testing.T) {
sock_path, _ := GetDbSock("BMP_STATE_DB", ns)
if sock_path != "/var/run/redis/redis.sock" {
t.Fatalf(`Sock("") = %q, want "/var/run/redis/redis.sock", error`, sock_path)
}
})
t.Run("AllNamespaces", func(t *testing.T) {
ns_list, _ := GetDbAllNamespaces()
if len(ns_list) != 1 {
t.Fatalf(`AllNamespaces("") = %q, want "1", error`, len(ns_list))
}
if ns_list[0] != ns {
t.Fatalf(`AllNamespaces("") = %q, want default, error`, ns_list[0])
}
})
t.Run("TcpAddr", func(t *testing.T) {
tcp_addr, _ := GetDbTcpAddr("BMP_STATE_DB", ns)
if tcp_addr != "127.0.0.1:6379" {
t.Fatalf(`TcpAddr("") = %q, want 127.0.0.1:6379, error`, tcp_addr)
}
})
}

func TestGetDbMultiNs(t *testing.T) {
Init()
err := test_utils.SetupMultiNamespace()
Expand Down
5 changes: 5 additions & 0 deletions testdata/database_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
"id" : 7,
"separator": "|",
"instance" : "redis"
},
"BMP_STATE_DB": {
"id": 20,
"separator": "|",
"instance": "redis"
}
},
"VERSION" : "1.0"
Expand Down

0 comments on commit ffdcd40

Please sign in to comment.