Use embed etcd for ConnectManager unit test (#21884)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/21890/head
congqixia 2023-01-31 13:35:49 +08:00 committed by GitHub
parent f1daef22a1
commit d329cf33a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 1 deletions

View File

@ -40,8 +40,26 @@ import (
"google.golang.org/grpc"
)
func TestConnectionManager(t *testing.T) {
func TestMain(t *testing.M) {
// init embed etcd
embedetcdServer, tempDir, err := etcd.StartTestEmbedEtcdServer()
if err != nil {
log.Fatal("failed to start embed etcd server for unittest", zap.Error(err))
}
defer os.RemoveAll(tempDir)
defer embedetcdServer.Server.Stop()
addrs := etcd.GetEmbedEtcdEndpoints(embedetcdServer)
// setup env for etcd endpoint
os.Setenv("etcd.endpoints", strings.Join(addrs, ","))
paramtable.Init()
os.Exit(t.Run())
}
func TestConnectionManager(t *testing.T) {
ctx := context.Background()
session := initSession(ctx)