Log water mark for incoming queue in cacher
This commit is contained in:
@@ -16,7 +16,11 @@ limitations under the License.
|
||||
|
||||
package storage
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"math/rand"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEtcdParseWatchResourceVersion(t *testing.T) {
|
||||
testCases := []struct {
|
||||
@@ -99,3 +103,34 @@ func TestHasPathPrefix(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHighWaterMark(t *testing.T) {
|
||||
var h HighWaterMark
|
||||
|
||||
for i := int64(10); i < 20; i++ {
|
||||
if !h.Update(i) {
|
||||
t.Errorf("unexpected false for %v", i)
|
||||
}
|
||||
if h.Update(i - 1) {
|
||||
t.Errorf("unexpected true for %v", i-1)
|
||||
}
|
||||
}
|
||||
|
||||
m := int64(0)
|
||||
wg := sync.WaitGroup{}
|
||||
for i := 0; i < 300; i++ {
|
||||
wg.Add(1)
|
||||
v := rand.Int63()
|
||||
go func(v int64) {
|
||||
defer wg.Done()
|
||||
h.Update(v)
|
||||
}(v)
|
||||
if v > m {
|
||||
m = v
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
if m != int64(h) {
|
||||
t.Errorf("unexpected value, wanted %v, got %v", m, int64(h))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user