mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
43 lines
921 B
Go
43 lines
921 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"strings"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
|
||
|
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
|
||
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
||
|
"github.com/milvus-io/milvus/pkg/util/etcd"
|
||
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||
|
)
|
||
|
|
||
|
func TestServer(t *testing.T) {
|
||
|
paramtable.Init()
|
||
|
|
||
|
params := paramtable.Get()
|
||
|
|
||
|
endpoints := params.EtcdCfg.Endpoints.GetValue()
|
||
|
etcdEndpoints := strings.Split(endpoints, ",")
|
||
|
c, err := etcd.GetRemoteEtcdClient(etcdEndpoints)
|
||
|
assert.NoError(t, err)
|
||
|
assert.NotNil(t, c)
|
||
|
|
||
|
b := NewServerBuilder()
|
||
|
metaKV := etcdkv.NewEtcdKV(c, "test")
|
||
|
s := sessionutil.NewMockSession(t)
|
||
|
s.EXPECT().GetServerID().Return(1)
|
||
|
|
||
|
newServer := b.WithETCD(c).
|
||
|
WithMetaKV(metaKV).
|
||
|
WithSession(s).
|
||
|
Build()
|
||
|
|
||
|
ctx := context.Background()
|
||
|
err = newServer.Init(ctx)
|
||
|
assert.NoError(t, err)
|
||
|
newServer.Start()
|
||
|
newServer.Stop()
|
||
|
}
|