mirror of
https://github.com/status-im/consul.git
synced 2025-02-26 20:30:39 +00:00
Merge pull request #3672 from hashicorp/gc-flake
Adds a small sleep to make sure we are in the next GC bucket.
This commit is contained in:
commit
5a437d7099
@ -1,7 +1,6 @@
|
|||||||
package state
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -24,12 +23,8 @@ func TestTombstoneGC_invalid(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTombstoneGC(t *testing.T) {
|
func TestTombstoneGC(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS") == "true" {
|
ttl := 200 * time.Millisecond
|
||||||
t.Skip("GC test is flaky on travis-ci (see #3670)")
|
gran := 50 * time.Millisecond
|
||||||
}
|
|
||||||
|
|
||||||
ttl := 20 * time.Millisecond
|
|
||||||
gran := 5 * time.Millisecond
|
|
||||||
gc, err := NewTombstoneGC(ttl, gran)
|
gc, err := NewTombstoneGC(ttl, gran)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
@ -61,6 +56,12 @@ func TestTombstoneGC(t *testing.T) {
|
|||||||
t.Fatalf("should get expiration")
|
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()
|
start2 := time.Now()
|
||||||
gc.Hint(120)
|
gc.Hint(120)
|
||||||
gc.Hint(125)
|
gc.Hint(125)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user