|
|
@ -870,13 +870,10 @@ func Test_StoreLogTruncationMultinode(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Wait for the snapshot to happen and log to be truncated.
|
|
|
|
// Wait for the snapshot to happen and log to be truncated.
|
|
|
|
for {
|
|
|
|
f := func() bool {
|
|
|
|
time.Sleep(1000 * time.Millisecond)
|
|
|
|
return stats.Get(numSnaphots).String() != nSnaps
|
|
|
|
if stats.Get(numSnaphots).String() != nSnaps {
|
|
|
|
|
|
|
|
// It's changed, so a snap and truncate has happened.
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
testPoll(t, f, 100*time.Millisecond, 2*time.Second)
|
|
|
|
|
|
|
|
|
|
|
|
// Fire up new node and ensure it picks up all changes. This will
|
|
|
|
// Fire up new node and ensure it picks up all changes. This will
|
|
|
|
// involve getting a snapshot and truncated log.
|
|
|
|
// involve getting a snapshot and truncated log.
|
|
|
@ -1203,3 +1200,21 @@ func asJSON(v interface{}) string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return string(b)
|
|
|
|
return string(b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func testPoll(t *testing.T, f func() bool, p time.Duration, d time.Duration) {
|
|
|
|
|
|
|
|
tck := time.NewTicker(p)
|
|
|
|
|
|
|
|
defer tck.Stop()
|
|
|
|
|
|
|
|
tmr := time.NewTimer(d)
|
|
|
|
|
|
|
|
defer tmr.Stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case <-tck.C:
|
|
|
|
|
|
|
|
if f() {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-tmr.C:
|
|
|
|
|
|
|
|
t.Fatalf("timeout expired: %s", t.Name())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|