Skip to content

[Bug Report] network-agent: TestEnsureReleaseEnsureReusesTapFromPool fails (stale async tap-pool assertions) #1013

Description

@annismckenzie

Environment

  • CubeSandbox commit: master @ 002e404
  • Relevant component: network-agent (internal/service)

Problem

TestEnsureReleaseEnsureReusesTapFromPool fails deterministically. After a successful ReleaseNetwork it asserts the recycled tap is empty in tapPool and pending in abnormalTapPool ("before async preparation"), but the tap is already in tapPool.

Steps to Reproduce

cd network-agent && go test ./internal/service/ -run '^TestEnsureReleaseEnsureReusesTapFromPool$'

Actual Behavior

local_service_test.go:588: tapPool len=1, want 0 before async preparation
--- FAIL: TestEnsureReleaseEnsureReusesTapFromPool

Deterministic (10/10) — the test builds localService as a struct literal with success mocks and no maintenance goroutine, so there is no timing element.

Root cause

With only success mocks installed (cubevsPrepareTAPPolicy → nil, etc.), releaseStateprepareAndStageTapForPool runs synchronously and stages the tap straight into tapPool via stageTapForPoolLocked. Deferral into abnormalTapPool happens only when preparation fails — exactly what the sibling test TestReleaseNetworkQueuesTapWhenPoolPrepareFails exercises by injecting a prepare boom error. The assertions in TestEnsureReleaseEnsureReusesTapFromPool appear to predate the switch to synchronous-on-success staging and were left stale.

Expected Behavior

On the success path the recycled tap is staged synchronously into tapPool (tapPool==1, abnormalTapPool==0).

Proposed fix

Test-only: assert the synchronous outcome and drop the handleAbnormalTaps() step. Production code is unchanged; the intended behavior is already covered by the failure-path sibling test. Verified 50/50 pass after the change, internal/service package green. A PR follows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions