mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
lax timing
This commit is contained in:
@@ -88,7 +88,7 @@ func TestResetHeartbeatTimerLocked_Renew(t *testing.T) {
|
||||
testutil.WaitForLeader(t, s1.RPC)
|
||||
|
||||
s1.heartbeatTimersLock.Lock()
|
||||
s1.resetHeartbeatTimerLocked("foo", 5*time.Millisecond)
|
||||
s1.resetHeartbeatTimerLocked("foo", 30*time.Millisecond)
|
||||
s1.heartbeatTimersLock.Unlock()
|
||||
|
||||
if _, ok := s1.heartbeatTimers["foo"]; !ok {
|
||||
@@ -99,23 +99,23 @@ func TestResetHeartbeatTimerLocked_Renew(t *testing.T) {
|
||||
|
||||
// Renew the heartbeat
|
||||
s1.heartbeatTimersLock.Lock()
|
||||
s1.resetHeartbeatTimerLocked("foo", 5*time.Millisecond)
|
||||
s1.resetHeartbeatTimerLocked("foo", 30*time.Millisecond)
|
||||
s1.heartbeatTimersLock.Unlock()
|
||||
renew := time.Now()
|
||||
|
||||
// Watch for invalidation
|
||||
for time.Now().Sub(renew) < time.Duration(testutil.TestMultiplier()*20)*time.Millisecond {
|
||||
for time.Now().Sub(renew) < time.Duration(testutil.TestMultiplier()*100)*time.Millisecond {
|
||||
s1.heartbeatTimersLock.Lock()
|
||||
_, ok := s1.heartbeatTimers["foo"]
|
||||
s1.heartbeatTimersLock.Unlock()
|
||||
if !ok {
|
||||
end := time.Now()
|
||||
if diff := end.Sub(renew); diff < 5*time.Millisecond {
|
||||
if diff := end.Sub(renew); diff < 30*time.Millisecond {
|
||||
t.Fatalf("early invalidate %v", diff)
|
||||
}
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
time.Sleep(2 * time.Millisecond)
|
||||
}
|
||||
t.Fatalf("should have expired")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user