Commit 7783c27
committed
test(redis-lua): drop flaky pool.Hits() assertion in VMReuse leak test
CI on PR #582 failed with:
--- FAIL: TestLua_VMReuseDoesNotLeakGlobals (0.00s)
Error: "0" is not greater than or equal to "1"
redis_lua_pool_test.go:112
The assertion `require.GreaterOrEqual(t, pool.Hits(), uint64(1))`
requires the Script-B `pool.get(nil)` to return the exact
`pooledLuaState` that Script-A put back moments earlier. sync.Pool
is explicitly allowed to evict pooled items under GC pressure
between Put and Get (the comment above line 80 acknowledges this
non-determinism for pointer identity, but then contradicts itself
by asserting a hit counter that has the SAME source of
non-determinism).
Under GHA's -race runtime + whatever GC triggers during the test,
the Script-B Get sometimes returns a fresh allocation (miss), so
Hits() stays at 0 and the assertion fails.
Pool effectiveness already has its own dedicated deterministic
test: TestLua_PoolRecordsReuseVsAllocation asserts
hits + misses across a controlled loop, which is resilient to
sync.Pool eviction. This test is about the security invariant
("no globals leak across pooled states") — the hit counter line
does not contribute to that and only adds flake. Remove it; leave
a comment pointing to the deterministic test.
Verified with `go test -race -count=20 -run
TestLua_VMReuseDoesNotLeakGlobals ./adapter/` 20/20 green and the
full `-short` adapter suite 63s green.1 parent e9a2bb9 commit 7783c27
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
113 | 119 | | |
114 | 120 | | |
115 | 121 | | |
| |||
0 commit comments