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 d84d519
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ $(ENVFILE):
tools/test/env.sh | grep -v DB_CONFIG_PATH | tee $@

check_gotest: $(DBCONFG) $(ENVFILE)
sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(GO) test -race -coverprofile=coverage-telemetry.txt -covermode=atomic -mod=vendor -v github.com/sonic-net/sonic-gnmi/telemetry
#sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(GO) test -race -coverprofile=coverage-telemetry.txt -covermode=atomic -mod=vendor -v github.com/sonic-net/sonic-gnmi/telemetry
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) -v 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
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 @@ -353,6 +353,37 @@ func TestGetDbMultiInstance(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 != 4 {
t.Fatalf(`Id("") = %d, want 4, error`, db_id)
}
})
t.Run("Sock", func(t *testing.T) {
sock_path, _ := GetDbSock("BMP_STATE_DB", ns)
if sock_path != "/var/run/redis/redis_bmp.sock" {
t.Fatalf(`Sock("") = %q, want "/var/run/redis/redis_bmp.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:6400" {
t.Fatalf(`TcpAddr("") = %q, want 127.0.0.1:6400, error`, tcp_addr)
}
})
}

func TestMain(m *testing.M) {
defer test_utils.MemLeakCheck()
m.Run()
Expand Down
10 changes: 10 additions & 0 deletions testdata/database_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"hostname" : "127.0.0.1",
"port" : 6379,
"unix_socket_path" : "/var/run/redis/redis.sock"
},
"redis_bmp": {
"hostname": "127.0.0.1",
"port": 6400,
"unix_socket_path": "/var/run/redis/redis_bmp.sock"
}
},
"DATABASES" : {
Expand Down Expand Up @@ -46,6 +51,11 @@
"id" : 7,
"separator": "|",
"instance" : "redis"
},
"BMP_STATE_DB": {
"id": 20,
"separator": "|",
"instance": "redis_bmp"
}
},
"VERSION" : "1.0"
Expand Down
10 changes: 10 additions & 0 deletions testdata/database_config_asic0.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"hostname" : "127.0.0.1",
"port" : 6379,
"unix_socket_path" : "/var/run/redis0/redis.sock"
},
"redis_bmp": {
"hostname": "127.0.0.1",
"port": 6400,
"unix_socket_path": "/var/run/redis0/redis_bmp.sock"
}
},
"DATABASES" : {
Expand Down Expand Up @@ -46,6 +51,11 @@
"id" : 7,
"separator": "|",
"instance" : "redis"
},
"BMP_STATE_DB": {
"id": 20,
"separator": "|",
"instance": "redis_bmp"
}
},
"VERSION" : "1.0"
Expand Down
10 changes: 10 additions & 0 deletions testdata/database_config_dpu.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"hostname" : "127.0.0.1",
"port" : 6379,
"unix_socket_path" : "/var/run/redis/redis.sock"
},
"redis_bmp": {
"hostname": "127.0.0.1",
"port": 6400,
"unix_socket_path": "/var/run/redis/redis_bmp.sock"
}
},
"DATABASES" : {
Expand Down Expand Up @@ -67,6 +72,11 @@
"id" : 18,
"separator": ":",
"instance" : "redis"
},
"BMP_STATE_DB": {
"id": 20,
"separator": "|",
"instance": "redis_bmp"
}
},
"VERSION" : "1.0"
Expand Down

0 comments on commit d84d519

Please sign in to comment.