mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-18 04:47:28 +00:00
fix(cache): harden cache backends, resilience, recovery, and transports
- RESP -ERR no longer closes healthy conn / aborts batch; global cap replacement-aware - global health-check pass serialized (latent data race); MemoryMonitor via ResourceManager - token-exchange retry, open-circuit rejections counted as failures - TLS-posture matching transport reuse (no silent InsecureSkipVerify handoff)
This commit is contained in:
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestCacheClose_NilStopCleanupNoPanic guards the R149 fix in Close():
|
||||
// stopCleanup is only allocated when EnableAutoCleanup && CleanupInterval > 0,
|
||||
// but Close() previously closed it whenever EnableAutoCleanup was set. A
|
||||
// cache built with EnableAutoCleanup=true and CleanupInterval left at its
|
||||
// zero value therefore called close(nil) and panicked during shutdown.
|
||||
func TestCacheClose_NilStopCleanupNoPanic(t *testing.T) {
|
||||
c := New(Config{EnableAutoCleanup: true}) // CleanupInterval defaults to 0
|
||||
if err := c.Close(); err != nil {
|
||||
t.Fatalf("Close() with CleanupInterval=0 must not panic and return nil, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestCacheClose_WithCleanupIntervalClosesOnce ensures the normal path
|
||||
// (cleanup started) still closes cleanly exactly once.
|
||||
func TestCacheClose_WithCleanupIntervalClosesOnce(t *testing.T) {
|
||||
c := New(Config{EnableAutoCleanup: true, CleanupInterval: time.Minute})
|
||||
if err := c.Close(); err != nil {
|
||||
t.Fatalf("Close() with a started cleanup goroutine must succeed, got: %v", err)
|
||||
}
|
||||
if err := c.Close(); err == nil {
|
||||
t.Fatal("second Close() must report already-closed")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user