mirror of https://github.com/milvus-io/milvus.git
Load etcd port from etcd
Signed-off-by: neza2017 <yefu.chen@zilliz.com>pull/4973/head^2
parent
85db2c0438
commit
14d4a400dd
|
@ -2,7 +2,9 @@ package kv
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zilliztech/milvus-distributed/internal/conf"
|
||||
"path"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -10,7 +12,9 @@ import (
|
|||
)
|
||||
|
||||
func TestEtcdKV_Load(t *testing.T) {
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
conf.LoadConfig("config.yaml")
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:" + etcd_port}})
|
||||
assert.Nil(t, err)
|
||||
rootpath := "/etcd/test/root"
|
||||
kv := NewEtcdKV(cli, rootpath)
|
||||
|
@ -64,7 +68,9 @@ func TestEtcdKV_Load(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEtcdKV_MultiSave(t *testing.T) {
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
conf.LoadConfig("config.yaml")
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:" + etcd_port}})
|
||||
assert.Nil(t, err)
|
||||
rootpath := "/etcd/test/root"
|
||||
kv := NewEtcdKV(cli, rootpath)
|
||||
|
@ -91,7 +97,9 @@ func TestEtcdKV_MultiSave(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEtcdKV_Remove(t *testing.T) {
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
conf.LoadConfig("config.yaml")
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:" + etcd_port}})
|
||||
assert.Nil(t, err)
|
||||
rootpath := "/etcd/test/root"
|
||||
kv := NewEtcdKV(cli, rootpath)
|
||||
|
@ -158,7 +166,9 @@ func TestEtcdKV_Remove(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEtcdKV_MultiSaveAndRemove(t *testing.T) {
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
conf.LoadConfig("config.yaml")
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:" + etcd_port}})
|
||||
assert.Nil(t, err)
|
||||
rootpath := "/etcd/test/root"
|
||||
kv := NewEtcdKV(cli, rootpath)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -14,7 +15,7 @@ func newKvBase() *kv.EtcdKV {
|
|||
//etcdAddr := conf.Config.Etcd.Address
|
||||
//etcdAddr += ":"
|
||||
//etcdAddr += strconv.FormatInt(int64(conf.Config.Etcd.Port), 10)
|
||||
etcdAddr := "127.0.0.1:2379"
|
||||
etcdAddr := "127.0.0.1:" + strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, _ := clientv3.New(clientv3.Config{
|
||||
Endpoints: []string{etcdAddr},
|
||||
DialTimeout: 5 * time.Second,
|
||||
|
|
|
@ -29,7 +29,7 @@ func (s *Master) CreateCollection(ctx context.Context, in *internalpb.CreateColl
|
|||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
||||
Reason: "Enqueue failed",
|
||||
}, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
err = t.WaitToFinish(ctx)
|
||||
|
@ -37,7 +37,7 @@ func (s *Master) CreateCollection(ctx context.Context, in *internalpb.CreateColl
|
|||
return &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
||||
Reason: "create collection failed",
|
||||
}, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &commonpb.Status{
|
||||
|
|
|
@ -2,6 +2,8 @@ package master
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zilliztech/milvus-distributed/internal/conf"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
@ -15,15 +17,19 @@ import (
|
|||
)
|
||||
|
||||
func TestMaster_CreateCollection(t *testing.T) {
|
||||
conf.LoadConfig("config.yaml")
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
defer cancel()
|
||||
|
||||
etcdCli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
etcd_addr := "127.0.0.1:" + etcd_port
|
||||
|
||||
etcdCli, err := clientv3.New(clientv3.Config{Endpoints: []string{etcd_addr}})
|
||||
assert.Nil(t, err)
|
||||
_, err = etcdCli.Delete(ctx, "/test/root", clientv3.WithPrefix())
|
||||
assert.Nil(t, err)
|
||||
|
||||
svr, err := CreateServer(ctx, "/test/root/kv", "/test/root/meta", "/test/root/meta/tso", []string{"127.0.0.1:2379"})
|
||||
svr, err := CreateServer(ctx, "/test/root/kv", "/test/root/meta", "/test/root/meta/tso", []string{etcd_addr})
|
||||
assert.Nil(t, err)
|
||||
err = svr.Run(10001)
|
||||
assert.Nil(t, err)
|
||||
|
@ -137,5 +143,10 @@ func TestMaster_CreateCollection(t *testing.T) {
|
|||
assert.Equal(t, coll_meta.Schema.Fields[1].IndexParams[0].Value, "col1_f2_iv1")
|
||||
assert.Equal(t, coll_meta.Schema.Fields[1].IndexParams[1].Value, "col1_f2_iv2")
|
||||
|
||||
req.Timestamp = Timestamp(10)
|
||||
st, err = cli.CreateCollection(ctx, &req)
|
||||
assert.Nil(t, err)
|
||||
assert.NotEqual(t, st.ErrorCode, commonpb.ErrorCode_SUCCESS)
|
||||
|
||||
svr.Close()
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package master
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zilliztech/milvus-distributed/internal/conf"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -12,7 +14,9 @@ import (
|
|||
)
|
||||
|
||||
func TestMetaTable_Collection(t *testing.T) {
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
conf.LoadConfig("config.yaml")
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:" + etcd_port}})
|
||||
assert.Nil(t, err)
|
||||
etcdKV := kv.NewEtcdKV(cli, "/etcd/test/root")
|
||||
|
||||
|
@ -133,7 +137,9 @@ func TestMetaTable_Collection(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMetaTable_DeletePartition(t *testing.T) {
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
conf.LoadConfig("config.yaml")
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:" + etcd_port}})
|
||||
assert.Nil(t, err)
|
||||
etcdKV := kv.NewEtcdKV(cli, "/etcd/test/root")
|
||||
|
||||
|
@ -214,7 +220,9 @@ func TestMetaTable_DeletePartition(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMetaTable_Segment(t *testing.T) {
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
|
||||
conf.LoadConfig("config.yaml")
|
||||
etcd_port := strconv.Itoa(int(conf.Config.Etcd.Port))
|
||||
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:" + etcd_port}})
|
||||
assert.Nil(t, err)
|
||||
etcdKV := kv.NewEtcdKV(cli, "/etcd/test/root")
|
||||
|
||||
|
|
Loading…
Reference in New Issue