pingora icon indicating copy to clipboard operation
pingora copied to clipboard

Tests: five load balancing, pool and eviction behaviours the unit tests don't pin down

Open Trenyx opened this issue 1 month ago • 0 comments

What is the problem your feature solves, or the need it fulfills?

A follow-up to #1035, on a different part of the code. We ran another planted-bug exercise on Pingora: in a private copy, we made one small, realistic change at a time and ran the existing tests. On current main (1adcb38), these five changes leave every test of the crate they touch passing:

  1. pingora-ketama/src/lib.rs: VersionedRing::node_idx sends a hash above the last ring point to the last point instead of wrapping to the first, so those keys land on a different node than the code comment says.
  2. pingora-load-balancing/src/selection/consistent.rs: KetamaHashing builds every bucket with weight 1, so a weight 3 backend gets the same share of the ring as a weight 1 backend.
  3. pingora-load-balancing/src/health_check.rs: Health::observe_health doesn't clear the counter on a flip, so with a threshold above 1 a single opposite check flips the backend straight back.
  4. pingora-pool/src/connection.rs: PoolNode::remove drops the items it pops ahead of its target instead of putting them back, so removing one idle connection loses the others queued in front of it.
  5. pingora-cache/src/eviction/lru.rs: Manager::peek promotes the asset, though EvictionManager::peek says it shouldn't change the asset's popularity.

None of these bugs is in Pingora today. They are regressions the current tests would let through.

Describe the solution you'd like

One unit test per behaviour, in the existing test module of each file. Tests only: no change to library code, no new dependencies. I have them ready. Would you like a PR?

Additional context

We ran the tests of those four crates, not pingora-proxy's integration tests, which need OpenResty. If one of those already covers a case, I'll drop that test from the PR.

This was found with Claude Code during a planted-bug run by SK @ Trenyx.

Trenyx avatar Nov 02 '26 21:11 Trenyx