From 24475048e21f6b12e03f6fd4c9b04180abfff2f4 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 8 Nov 2017 21:54:21 -0800 Subject: [PATCH] Adds a sleep to make sure we are in the next GC bucket, ups time. Fixes #3670 --- agent/consul/state/tombstone_gc_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/agent/consul/state/tombstone_gc_test.go b/agent/consul/state/tombstone_gc_test.go index b05d0c2773..f1a5c72ac9 100644 --- a/agent/consul/state/tombstone_gc_test.go +++ b/agent/consul/state/tombstone_gc_test.go @@ -1,7 +1,6 @@ package state import ( - "os" "testing" "time" ) @@ -24,12 +23,8 @@ func TestTombstoneGC_invalid(t *testing.T) { } func TestTombstoneGC(t *testing.T) { - if os.Getenv("TRAVIS") == "true" { - t.Skip("GC test is flaky on travis-ci (see #3670)") - } - - ttl := 20 * time.Millisecond - gran := 5 * time.Millisecond + ttl := 200 * time.Millisecond + gran := 50 * time.Millisecond gc, err := NewTombstoneGC(ttl, gran) if err != nil { t.Fatalf("err: %v", err) @@ -61,6 +56,12 @@ func TestTombstoneGC(t *testing.T) { t.Fatalf("should get expiration") } + // At this point we know we are very close to a TTL bucket + // so we sleep a small fraction of the bucket size in order + // to hit the case we desire for the next section where we + // hint twice into the same bucket and see them coalesce. + time.Sleep(gran / 5) + start2 := time.Now() gc.Hint(120) gc.Hint(125)