Skip to content

Commit

Permalink
Tightens timing up and reorders GC test to be less flaky.
Browse files Browse the repository at this point in the history
  • Loading branch information
slackpad committed Nov 8, 2017
1 parent 7c6ab5e commit 7b966e2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions agent/consul/state/tombstone_gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestTombstoneGC_invalid(t *testing.T) {
}

func TestTombstoneGC(t *testing.T) {
ttl := 500 * time.Millisecond
gran := 200 * time.Millisecond
ttl := 20 * time.Millisecond
gran := 5 * time.Millisecond
gc, err := NewTombstoneGC(ttl, gran)
if err != nil {
t.Fatalf("err: %v", err)
Expand All @@ -38,11 +38,6 @@ func TestTombstoneGC(t *testing.T) {
start := time.Now()
gc.Hint(100)

time.Sleep(2*gran + gran/3)
start2 := time.Now()
gc.Hint(120)
gc.Hint(125)

if !gc.PendingExpiration() {
t.Fatalf("should be pending")
}
Expand All @@ -61,6 +56,14 @@ func TestTombstoneGC(t *testing.T) {
t.Fatalf("should get expiration")
}

start2 := time.Now()
gc.Hint(120)
gc.Hint(125)

if !gc.PendingExpiration() {
t.Fatalf("should be pending")
}

select {
case index := <-gc.ExpireCh():
end := time.Now()
Expand Down

0 comments on commit 7b966e2

Please sign in to comment.