milvus/internal/master/id/id_test.go
dragondriver b8ccbc1c97 Add InsertTask and SearchTask to Proxy
Signed-off-by: dragondriver <jiquan.long@zilliz.com>
2020-11-07 16:18:23 +08:00

37 lines
828 B
Go

package id
import (
"github.com/stretchr/testify/assert"
"github.com/zilliztech/milvus-distributed/internal/kv/mockkv"
"os"
"testing"
)
var GIdAllocator *GlobalIdAllocator
func TestMain(m *testing.M) {
GIdAllocator = NewGlobalIdAllocator("idTimestamp", mockkv.NewEtcdKV())
exitCode := m.Run()
os.Exit(exitCode)
}
func TestGlobalIdAllocator_Initialize(t *testing.T) {
err := GIdAllocator.Initialize()
assert.Nil(t, err)
}
func TestGlobalIdAllocator_AllocOne(t *testing.T) {
one, err := GIdAllocator.AllocOne()
assert.Nil(t, err)
ano, err := GIdAllocator.AllocOne()
assert.Nil(t, err)
assert.NotEqual(t, one, ano)
}
func TestGlobalIdAllocator_Alloc(t *testing.T) {
count := uint32(2<<10)
idStart, idEnd, err := GIdAllocator.Alloc(count)
assert.Nil(t, err)
assert.Equal(t, count, uint32(idEnd - idStart))
}