未验证 提交 2398dafb 编写于 作者: G groot 提交者: GitHub

Add unittest for distributed proxy (#7976)

Signed-off-by: Nyhmo <yihua.mo@zilliz.com>
上级 900f2d73
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
package grpcproxyclient
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_NewClient(t *testing.T) {
client, err := NewClient(context.Background(), "")
assert.Nil(t, client)
assert.Error(t, err)
client, err = NewClient(context.Background(), "localhost")
assert.Nil(t, err)
assert.NotNil(t, client)
err = client.Start()
assert.Nil(t, err)
err = client.Stop()
assert.Nil(t, err)
err = client.Register()
assert.Nil(t, err)
}
......@@ -14,7 +14,9 @@ package grpcproxyclient
import (
"testing"
"github.com/milvus-io/milvus/internal/distributed/grpcconfigs"
"github.com/milvus-io/milvus/internal/log"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
)
......@@ -23,4 +25,12 @@ func TestParamTable(t *testing.T) {
log.Info("TestParamTable", zap.Int("ClientMaxSendSize", Params.ClientMaxSendSize))
log.Info("TestParamTable", zap.Int("ClientMaxRecvSize", Params.ClientMaxRecvSize))
Params.Remove("proxy.grpc.clientMaxSendSize")
Params.initClientMaxSendSize()
assert.Equal(t, Params.ClientMaxSendSize, grpcconfigs.DefaultClientMaxSendSize)
Params.Remove("proxy.grpc.clientMaxRecvSize")
Params.initClientMaxRecvSize()
assert.Equal(t, Params.ClientMaxRecvSize, grpcconfigs.DefaultClientMaxRecvSize)
}
......@@ -14,7 +14,10 @@ package grpcproxy
import (
"testing"
"github.com/milvus-io/milvus/internal/distributed/grpcconfigs"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/util/funcutil"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
)
......@@ -23,4 +26,15 @@ func TestParamTable(t *testing.T) {
log.Info("TestParamTable", zap.Int("ServerMaxSendSize", Params.ServerMaxSendSize))
log.Info("TestParamTable", zap.Int("ServerMaxRecvSize", Params.ServerMaxRecvSize))
Params.Remove("proxy.grpc.serverMaxSendSize")
Params.initServerMaxSendSize()
assert.Equal(t, Params.ServerMaxSendSize, grpcconfigs.DefaultServerMaxSendSize)
Params.Remove("proxy.grpc.serverMaxRecvSize")
Params.initServerMaxRecvSize()
assert.Equal(t, Params.ServerMaxRecvSize, grpcconfigs.DefaultServerMaxRecvSize)
Params.LoadFromEnv()
assert.Equal(t, Params.IP, funcutil.GetLocalIP())
}
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
package grpcproxy
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_NewServer(t *testing.T) {
server, err := NewServer(context.Background(), nil)
assert.NotNil(t, server)
assert.Nil(t, err)
}
......@@ -23,6 +23,6 @@ func Test_RandomString(t *testing.T) {
assert.Equal(t, len(str), length)
}
func TestGenRandomStr(t *testing.T) {
func Test_GenRandomStr(t *testing.T) {
assert.True(t, len(GenRandomStr()) >= 1)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册