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:
R.B. Boyer 2019-04-17 15:52:23 -05:00 committed by GitHub
parent 59c0174de5
commit 6269d1f130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

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