Use embed ETCD for datacoord unit test (#21890)

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

View File

@ -25,6 +25,7 @@ import (
"os/signal"
"path"
"strconv"
"strings"
"sync"
"syscall"
"testing"
@ -61,6 +62,18 @@ import (
)
func TestMain(m *testing.M) {
// init embed etcd
embedetcdServer, tempDir, err := etcd.StartTestEmbedEtcdServer()
if err != nil {
log.Fatal(err.Error())
}
defer os.RemoveAll(tempDir)
defer embedetcdServer.Close()
addrs := etcd.GetEmbedEtcdEndpoints(embedetcdServer)
// setup env for etcd endpoint
os.Setenv("etcd.endpoints", strings.Join(addrs, ","))
paramtable.Init()
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())