mirror of https://github.com/milvus-io/milvus.git
Increase code coverage rate for proxy (#7727)
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>pull/7781/head
parent
4c18910acd
commit
9b0aacd07a
|
@ -12,6 +12,7 @@
|
|||
package proxy
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/util/uniquegenerator"
|
||||
|
@ -209,3 +210,30 @@ func TestChannelsMgrImpl_removeAllDQLMsgStream(t *testing.T) {
|
|||
assert.Equal(t, nil, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAllKeysAndGetAllValues(t *testing.T) {
|
||||
chanMapping := make(map[vChan]pChan)
|
||||
chanMapping["v1"] = "p1"
|
||||
chanMapping["v2"] = "p2"
|
||||
|
||||
t.Run("getAllKeys", func(t *testing.T) {
|
||||
vChans := getAllKeys(chanMapping)
|
||||
assert.Equal(t, 2, len(vChans))
|
||||
})
|
||||
|
||||
t.Run("getAllValues", func(t *testing.T) {
|
||||
pChans := getAllValues(chanMapping)
|
||||
assert.Equal(t, 2, len(pChans))
|
||||
})
|
||||
}
|
||||
|
||||
func TestDeleteVChansByVID(t *testing.T) {
|
||||
mgr := singleTypeChannelsMgr{
|
||||
id2vchansMtx: sync.RWMutex{},
|
||||
id2vchans: map[int][]vChan{
|
||||
10: {"v1"},
|
||||
},
|
||||
}
|
||||
|
||||
mgr.deleteVChansByVID(10)
|
||||
}
|
||||
|
|
|
@ -75,3 +75,33 @@ func TestGetAttrByKeyFromRepeatedKV(t *testing.T) {
|
|||
assert.Equal(t, test.errIsNil, err == nil)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUtil(t *testing.T) {
|
||||
a, b := 1, 2
|
||||
t.Run("getMax", func(t *testing.T) {
|
||||
ans := getMax(a, b)
|
||||
assert.Equal(t, b, ans)
|
||||
|
||||
ans = getMax(b, a)
|
||||
assert.Equal(t, b, ans)
|
||||
})
|
||||
|
||||
t.Run("getMin", func(t *testing.T) {
|
||||
ans := getMin(a, b)
|
||||
assert.Equal(t, a, ans)
|
||||
|
||||
ans = getMin(b, a)
|
||||
assert.Equal(t, a, ans)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetPulsarConfig_Error(t *testing.T) {
|
||||
protocol := "http"
|
||||
ip := "pulsar"
|
||||
port := "17777"
|
||||
url := "/admin/v2/brokers/configuration/runtime"
|
||||
|
||||
ret, err := GetPulsarConfig(protocol, ip, port, url)
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, ret)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue