Tightens timing up and reorders GC test to be less flaky.

This commit is contained in:
James Phillips 2017-11-08 15:09:29 -08:00
parent e00624425b
commit 444a345a3a
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 10 additions and 7 deletions

View File

@ -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)
@ -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")
}
@ -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()