mirror of https://github.com/status-im/consul.git
tests: actually have TestSessionTTLRenew sleep during execution (#5669)
Due to an unintended order of operations issue with integer division TestSessionTTLRenew was sleeping for 0s every time. Also add explicit failures for when the various session renewal returns nil unexpectedly.
This commit is contained in:
parent
59c0174de5
commit
6269d1f130
|
@ -397,7 +397,11 @@ func TestSessionTTLRenew(t *testing.T) {
|
|||
}
|
||||
|
||||
// Sleep to consume some time before renew
|
||||
time.Sleep(ttl * (structs.SessionTTLMultiplier / 3))
|
||||
sleepFor := ttl * structs.SessionTTLMultiplier / 3
|
||||
if sleepFor <= 0 {
|
||||
t.Fatalf("timing tests need to sleep")
|
||||
}
|
||||
time.Sleep(sleepFor)
|
||||
|
||||
req, _ = http.NewRequest("PUT", "/v1/session/renew/"+id, nil)
|
||||
resp = httptest.NewRecorder()
|
||||
|
@ -405,6 +409,9 @@ func TestSessionTTLRenew(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if obj == nil {
|
||||
t.Fatalf("session '%s' expired before renewal", id)
|
||||
}
|
||||
respObj, ok = obj.(structs.Sessions)
|
||||
if !ok {
|
||||
t.Fatalf("should work")
|
||||
|
|
Loading…
Reference in New Issue