Skip to content

test: ✅ Add tests for vmpool - #876

Merged
evaline-ju merged 2 commits into
rossoctl:mainfrom
evaline-ju:vmpool-tests-2
Nov 17, 2026
Merged

evaline-ju merged 2 commits into
rossoctl:mainfrom
evaline-ju:vmpool-tests-2

Conversation

@evaline-ju

@evaline-ju evaline-ju commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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/meminfo and 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

  • Commits are signed off (git commit -s).
  • make lint and the tests for the touched packages pass.
  • Docs: changed behavior, flags or environment variables are reflected in the relevant README or
    docs/ page, with the right maturity label (see docs/CONTRIBUTING-DOCS.md). - N/A
  • Docs: make check-links passes if any Markdown changed. - N/A
  • A new spec or ADR is registered in docs/specs/README.md or docs/adrs/README.md. - N/A

Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
@evaline-ju
evaline-ju requested a review from pdettori as a code owner November 17, 2026 20:23
@evaline-ju evaline-ju added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 17, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 at standby_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

@evaline-ju
evaline-ju merged commit 4602062 into rossoctl:main Nov 17, 2026
18 checks passed
@evaline-ju
evaline-ju deleted the vmpool-tests-2 branch November 17, 2026 22:56
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remote-worker: vmpool test follow-ups from the #647 review (host-memory no-eviction, single-batch eviction, parser seams)

3 participants