Исправить замечания ревью: защита rollout от остановленных реплик, чтение серий, время экспериментов по часам Docker, выход сервера при ошибке старта

This commit is contained in:
2026-11-02 18:23:26 +03:00
parent b2973405f3
commit c9d0f73221
8 changed files with 153 additions and 25 deletions
+15 -3
View File
@@ -129,7 +129,11 @@ func TestLogoutRevokesOnlyThatSession(t *testing.T) {
}
}
// ExpiresAt is written by this process's clock and enforced by Valkey's. In
// the tests Valkey runs in the Docker VM, whose clock may lag the Windows host
// by a fraction of a second, so the expiry is awaited with a tolerance.
func TestSessionExpiresAfterTTL(t *testing.T) {
const clockTolerance = 3 * time.Second
f := newFixture(t, time.Second)
issued, err := f.svc.Login(f.ctx, "alice", pw)
if err != nil {
@@ -138,8 +142,16 @@ func TestSessionExpiresAfterTTL(t *testing.T) {
if _, err := f.svc.Authenticate(f.ctx, issued.Token); err != nil {
t.Fatalf("fresh session: %v", err)
}
time.Sleep(time.Until(issued.ExpiresAt) + 100*time.Millisecond)
if _, err := f.svc.Authenticate(f.ctx, issued.Token); !errors.Is(err, auth.ErrUnauthenticated) {
t.Fatalf("expired session: err = %v, want ErrUnauthenticated", err)
time.Sleep(time.Until(issued.ExpiresAt))
deadline := time.Now().Add(clockTolerance)
for {
_, err := f.svc.Authenticate(f.ctx, issued.Token)
if errors.Is(err, auth.ErrUnauthenticated) {
return
}
if time.Now().After(deadline) {
t.Fatalf("expired session: err = %v %v after ExpiresAt, want ErrUnauthenticated", err, clockTolerance)
}
time.Sleep(100 * time.Millisecond)
}
}