From 4f80541b9f00ad8dace9534c778118b1f93f4926 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Mon, 18 Jan 2021 16:08:08 +0100 Subject: [PATCH] increase test timing cor sync.cache --- ocis-pkg/sync/cache_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ocis-pkg/sync/cache_test.go b/ocis-pkg/sync/cache_test.go index c5c84f622..c7d360de3 100644 --- a/ocis-pkg/sync/cache_test.go +++ b/ocis-pkg/sync/cache_test.go @@ -30,7 +30,7 @@ func BenchmarkCache(b *testing.B) { size := 1024 c, cr := cacheRunner(size) - cr(func(i int) { c.Store(strconv.Itoa(i), i, time.Now().Add(10*time.Millisecond)) }) + cr(func(i int) { c.Store(strconv.Itoa(i), i, time.Now().Add(100*time.Millisecond)) }) cr(func(i int) { c.Delete(strconv.Itoa(i)) }) } @@ -38,14 +38,14 @@ func TestCache(t *testing.T) { size := 1024 c, cr := cacheRunner(size) - cr(func(i int) { c.Store(strconv.Itoa(i), i, time.Now().Add(10*time.Millisecond)) }) + cr(func(i int) { c.Store(strconv.Itoa(i), i, time.Now().Add(100*time.Millisecond)) }) assert.Equal(t, size, int(c.length), "length is atomic") cr(func(i int) { c.Delete(strconv.Itoa(i)) }) assert.Equal(t, 0, int(c.length), "delete is atomic") cr(func(i int) { - time.Sleep(11 * time.Millisecond) + time.Sleep(101 * time.Millisecond) c.evict() }) assert.Equal(t, 0, int(c.length), "evict is atomic") @@ -68,7 +68,7 @@ func TestCache_Load(t *testing.T) { }) cr(func(i int) { - wait := 10 * time.Millisecond + wait := 100 * time.Millisecond c.Store(strconv.Itoa(i), i, time.Now().Add(wait)) time.Sleep(wait + 1) assert.Nil(t, c.Load(strconv.Itoa(i)), "entry is nil if it's expired") @@ -79,12 +79,12 @@ func TestCache_Store(t *testing.T) { c, cr := cacheRunner(1024) cr(func(i int) { - c.Store(strconv.Itoa(i), i, time.Now().Add(10*time.Millisecond)) + c.Store(strconv.Itoa(i), i, time.Now().Add(100*time.Millisecond)) assert.Equal(t, i, c.Load(strconv.Itoa(i)).V, "new entries can be added") }) cr(func(i int) { - replacedExpiration := time.Now().Add(10 * time.Millisecond) + replacedExpiration := time.Now().Add(10 * time.Minute) c.Store(strconv.Itoa(i), "old", time.Now().Add(10*time.Minute)) c.Store(strconv.Itoa(i), "updated", replacedExpiration) assert.Equal(t, "updated", c.Load(strconv.Itoa(i)).V, "entry values can be updated") @@ -96,7 +96,7 @@ func TestCache_Delete(t *testing.T) { c, cr := cacheRunner(1024) cr(func(i int) { - c.Store(strconv.Itoa(i), i, time.Now().Add(10*time.Millisecond)) + c.Store(strconv.Itoa(i), i, time.Now().Add(100*time.Millisecond)) c.Delete(strconv.Itoa(i)) assert.Nil(t, c.Load(strconv.Itoa(i)), "entries can be deleted") })