2020-10-15 13:31:50 +00:00
|
|
|
package proxy
|
2020-10-15 08:32:22 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-11-14 03:24:49 +00:00
|
|
|
"fmt"
|
|
|
|
"math/rand"
|
2020-11-03 06:53:36 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2020-10-15 08:32:22 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-11-14 03:24:49 +00:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/allocator"
|
2020-10-15 08:32:22 +00:00
|
|
|
)
|
|
|
|
|
2020-11-14 03:24:49 +00:00
|
|
|
var trueCnt = 0
|
2020-10-15 08:32:22 +00:00
|
|
|
|
2020-11-14 03:24:49 +00:00
|
|
|
func checkFunc(timestamp Timestamp) bool {
|
|
|
|
ret := rand.Intn(2) == 1
|
|
|
|
if ret {
|
|
|
|
trueCnt++
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTimeTick_Start(t *testing.T) {
|
|
|
|
fmt.Println("HHH")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTimeTick_Start2(t *testing.T) {
|
2020-10-15 08:32:22 +00:00
|
|
|
|
2020-11-14 03:24:49 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
2020-11-21 07:06:46 +00:00
|
|
|
masterAddr := Params.MasterAddress()
|
2020-11-16 13:10:43 +00:00
|
|
|
tsoAllocator, err := allocator.NewTimestampAllocator(ctx, masterAddr)
|
2020-11-14 03:24:49 +00:00
|
|
|
assert.Nil(t, err)
|
|
|
|
err = tsoAllocator.Start()
|
2020-11-03 06:53:36 +00:00
|
|
|
assert.Nil(t, err)
|
2020-10-15 08:32:22 +00:00
|
|
|
|
2020-11-21 11:12:59 +00:00
|
|
|
tt := newTimeTick(ctx, tsoAllocator, Params.TimeTickInterval(), checkFunc)
|
2020-10-15 08:32:22 +00:00
|
|
|
|
2020-11-14 03:24:49 +00:00
|
|
|
defer func() {
|
|
|
|
cancel()
|
|
|
|
tsoAllocator.Close()
|
|
|
|
tt.Close()
|
|
|
|
}()
|
2020-10-15 08:32:22 +00:00
|
|
|
|
2020-11-14 03:24:49 +00:00
|
|
|
tt.Start()
|
2020-11-12 04:04:12 +00:00
|
|
|
|
2020-11-14 03:24:49 +00:00
|
|
|
<-ctx.Done()
|
2020-10-15 08:32:22 +00:00
|
|
|
|
|
|
|
}
|