Merge pull request #613 from youtube/suguwork

Fix flaky rand ticker test.
This commit is contained in:
sougou 2015-04-21 22:26:44 -07:00
Родитель 78786355a9 ee0236140c
Коммит 4f59fd1306
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -10,17 +10,17 @@ import (
)
const (
testDuration = 20 * time.Millisecond
testVariance = 5 * time.Millisecond
testDuration = 100 * time.Millisecond
testVariance = 20 * time.Millisecond
)
func TestTick(t *testing.T) {
tkr := NewRandTicker(testDuration, testVariance)
for i := 0; i < 10; i++ {
for i := 0; i < 5; i++ {
start := time.Now()
end := <-tkr.C
diff := start.Add(testDuration).Sub(end)
tolerance := testVariance + 3*time.Millisecond
tolerance := testVariance + 20*time.Millisecond
if diff < -tolerance || diff > tolerance {
t.Errorf("start: %v, end: %v, diff %v. Want <%v tolerenace", start, end, diff, tolerance)
}