mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 04:49:08 +08:00
0e5931a3da
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
32 lines
531 B
Go
32 lines
531 B
Go
package datanode
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMergedTimeTicker(t *testing.T) {
|
|
var ticks []uint64
|
|
var mut sync.Mutex
|
|
|
|
mt := newMergedTimeTickerSender(func(ts Timestamp) error {
|
|
mut.Lock()
|
|
defer mut.Unlock()
|
|
ticks = append(ticks, ts)
|
|
return nil
|
|
})
|
|
|
|
for i := 1; i < 100; i++ {
|
|
time.Sleep(time.Millisecond * 10)
|
|
mt.bufferTs(uint64(i))
|
|
}
|
|
mt.close()
|
|
mut.Lock()
|
|
assert.EqualValues(t, 99, ticks[len(ticks)-1])
|
|
assert.Less(t, len(ticks), 20)
|
|
mut.Unlock()
|
|
}
|