Skip to content

Commit

Permalink
not4review
Browse files Browse the repository at this point in the history
  • Loading branch information
FengPan-Frank committed Feb 27, 2025
1 parent e06ff6c commit a144d18
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ check_gotest: $(DBCONFG) $(ENVFILE)
sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(GO) test -race -coverprofile=coverage-config.txt -covermode=atomic -v github.com/sonic-net/sonic-gnmi/sonic_db_config
sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(TESTENV) $(GO) test -race -timeout 20m -coverprofile=coverage-gnmi.txt -covermode=atomic -mod=vendor $(BLD_FLAGS) -v github.com/sonic-net/sonic-gnmi/gnmi_server -coverpkg ../...
ifneq ($(ENABLE_DIALOUT_VALUE),0)
sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(TESTENV) $(GO) test -coverprofile=coverage-dialcout.txt -covermode=atomic -mod=vendor $(BLD_FLAGS) -v github.com/sonic-net/sonic-gnmi/dialout/dialout_client
sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(TESTENV) $(GO) test -coverprofile=coverage-dialcout.txt -covermode=atomic -mod=vendor $(BLD_FLAGS) github.com/sonic-net/sonic-gnmi/dialout/dialout_client
endif
sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(GO) test -race -coverprofile=coverage-data.txt -covermode=atomic -mod=vendor -v github.com/sonic-net/sonic-gnmi/sonic_data_client
sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(GO) test -race -coverprofile=coverage-dbus.txt -covermode=atomic -mod=vendor -v github.com/sonic-net/sonic-gnmi/sonic_service_client
Expand Down
7 changes: 5 additions & 2 deletions proto/sonic.pb.go

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

3 changes: 2 additions & 1 deletion proto/sonic.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ enum Target {
CONFIG_DB = 4;
// PFC_WD_DB shares the the same db number with FLEX_COUNTER_DB
PFC_WD_DB = 5;
FLEX_COUNTER_DB = 5;
//FLEX_COUNTER_DB = 5;
STATE_DB = 6;
BMP_STATE_DB = 20;
// For none-DB data
OTHERS = 100;
}
Expand Down
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 a144d18

Please sign in to comment.