mirror of https://github.com/milvus-io/milvus.git
Signed-off-by: longjiquan <jiquan.long@zilliz.com> Signed-off-by: longjiquan <jiquan.long@zilliz.com> Signed-off-by: longjiquan <jiquan.long@zilliz.com>pull/21083/head
parent
368686e149
commit
a334853475
|
@ -51,6 +51,7 @@ func (gc *GroupChecker) init() {
|
|||
// work is the main procedure logic
|
||||
func (gc *GroupChecker) work() {
|
||||
gc.t = time.NewTicker(gc.d)
|
||||
defer gc.t.Stop()
|
||||
var name string
|
||||
var ts time.Time
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ func TestGroupChecker(t *testing.T) {
|
|||
signal := make(chan []string, 1)
|
||||
// 10ms period which set before is too short
|
||||
// change 10ms to 500ms to ensure the the group checker schedule after the second value stored
|
||||
gc1 := GetGroupChecker(groupName, 500*time.Millisecond, func(list []string) {
|
||||
duration := 500 * time.Millisecond
|
||||
gc1 := GetGroupChecker(groupName, duration, func(list []string) {
|
||||
signal <- list
|
||||
})
|
||||
gc1.Check("1")
|
||||
|
@ -37,14 +38,16 @@ func TestGroupChecker(t *testing.T) {
|
|||
})
|
||||
gc2.Check("2")
|
||||
|
||||
assert.Equal(t, 500*time.Millisecond, gc2.d)
|
||||
assert.Equal(t, duration, gc2.d)
|
||||
|
||||
list := <-signal
|
||||
assert.ElementsMatch(t, []string{"1", "2"}, list)
|
||||
assert.Eventually(t, func() bool {
|
||||
list := <-signal
|
||||
return len(list) == 2
|
||||
}, duration*3, duration)
|
||||
|
||||
gc2.Remove("2")
|
||||
|
||||
list = <-signal
|
||||
list := <-signal
|
||||
assert.ElementsMatch(t, []string{"1"}, list)
|
||||
|
||||
assert.NotPanics(t, func() {
|
||||
|
|
Loading…
Reference in New Issue