Repository navigation
test: ✅ Add tests for vmpool - #876
Conversation
Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Solid test PR: table tests for the cgroup/meminfo/chv-scope parsers are assertive and cover malformed input, and the concurrency tests exercise real pool behavior. Two findings below — one possible test race, one labeling nit. No agent/IDE config files touched, no secrets, all commits signed off, CI green.
Author: evaline-ju (CONTRIBUTOR — returning external)
Areas reviewed: Go (tests), concurrency, error handling
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| t.Helper() | ||
| pp := p.(*pool) | ||
| oldAvail := memAvailable | ||
| memAvailable = func() (int64, error) { return 512 << 20, nil } |
There was a problem hiding this comment.
suggestion — refusedAtHostFloor reassigns the package-level memAvailable (line 242) and restores it in a defer (line ~243) with no synchronization, while the calling tests still hold a p.Exec goroutine blocked mid-flight (TestEvictionShedsAsMuchDirtyChargeAsAdmissionNeeds, TestSequentialWarmAcquiresOnOneRunShedIdleStandbys). If reclaimLoop or an in-flight Exec path reads memAvailable (or pp.cfg.HostMemFloorBytes outside pp.mu) during the swap, that's a data race under -race.
Suggested fix: guard the swap with the pool lock, or quiesce the blocked goroutine before swapping. Worth a go test -race ./remote-worker/internal/vmpool/ run on this branch to confirm either way.
There was a problem hiding this comment.
Not a race. memAvailable is only read in cachedMemAvailable, which runs only with p.mu held (hostFloorLocked, plus leaseMemDeficitLocked, which these tests never reach because they have no leases). HostMemFloorBytes is written under pp.mu and read only under p.mu. The blocked Exec has already been admitted and is parked in the fake Run, so it reads neither value. The helper's own Exec is ordered by the go statement before it and the channel receive after it, and release() runs after the restore. go test -race ./internal/vmpool passes on this branch.
pdettori
left a comment
There was a problem hiding this comment.
Summary
Test-only in effect. The readMemAvailableFrom extraction keeps behaviour the same, because production still passes /proc/meminfo. Each new test fails when the bug it targets is put back on the PR head:
- making cold admission evict on
RefuseHostMemory(budget.go:91) fails atstandby_charge_test.go:200; - making warm acquire evict on it (
pool.go:656) fails at:343; - sending one reclaim batch per VM fails
TestAdmissionFundingIsOneReclaimBatch(7 batches left queued).
The full vmpool package passes under -race.
nit: the commit subjects (:white_check_mark: Add vmpool tests, :recycle: Move test files) have no conventional prefix (test: / refactor:). Since PRs land as merge commits, these subjects end up in history.
Author: evaline-ju (MEMBER — maintainer)
Areas reviewed: Go (vmpool tests, hostmem.go refactor), concurrency, security
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (17/17)
Assisted-By: Claude Code
Summary
Adds tests that a host-memory floor refusal evicts nothing at admission or warm acquire, and that one eviction call sends one reclaim batch. Also adds table tests for the memory.current,
/proc/meminfoand Cloud Hypervisor scope-cgroup path parsers, covering malformed input, whitespace and the fail-safe paths.To make the parser testable, readHostMemAvailable now delegates to readMemAvailableFrom(path). Production still reads
/proc/meminfo, so its errors are unchanged.Closes #649
Assisted-By: Claude Code
Checklist
git commit -s).make lintand the tests for the touched packages pass.docs/page, with the right maturity label (seedocs/CONTRIBUTING-DOCS.md). - N/Amake check-linkspasses if any Markdown changed. - N/Adocs/specs/README.mdordocs/adrs/README.md. - N/A