2021-01-15 06:38:36 +00:00
|
|
|
package proxynode
|
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"
|
2021-02-08 06:30:54 +00:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream/pulsarms"
|
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-12-03 11:00:11 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
2021-01-28 12:51:44 +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
|
|
|
|
2021-02-08 06:30:54 +00:00
|
|
|
msFactory := pulsarms.NewFactory()
|
|
|
|
tt := newTimeTick(ctx, tsoAllocator, Params.TimeTickInterval, checkFunc, msFactory)
|
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
|
|
|
|
|
|
|
}
|