Files
Pulse/internal
pulse-triage[bot] 1c8607abd0 Parallelize slow internal/api race subtests and speed up fixtures (#5366)
**Parallelize slow internal/api race subtests and speed up fixtures**

Backend tests (api-0..4) finished last on post-#5350 Pulse Build and
Test runs
(46109093360, ~1,726 runner-seconds across 5 shards), with the slowest
unclaimed
internal/api tests executing isolated subtest matrices sequentially,
seeding the
full default public demo estate where compact mock topologies suffice,
or
bypassing TestMain's PULSE_TEST_BCRYPT_COST via direct
bcrypt.DefaultCost calls.

- Parallelize isolated subtest matrices across 14 unclaimed internal/api
test
files (host_agent_credential_handoff_test.go,
agent_snapshot_authority_test.go,
  resource_read_authority_test.go, token_stream_lifetime_test.go,
  token_stream_shutdown_test.go, assistant_stream_lifetime_test.go,
  assistant_json_lifetime_test.go, agent_events_auth_test.go,
  reporting_boundary_test.go, docker_agents_report_size_test.go,
  security_setup_fixture_isolation_test.go, websocket_auth_test.go,
security_token_withdrawal_test.go, and log_stream_auth_test.go), lifting
shared
env/session setup out of per-subtest helpers, serializing only the
temporary
AI alert-analysis binder swap during router construction, and caching
read-only
  source file bytes once in reporting_boundary_test.go.
- Use the existing compact 2-node mock integration fixture
(newIntegrationServer)
for TestStateEndpointReturnsMockData, TestConfigNodesUsesMockTopology,
and
TestMockModeToggleEndpoint in router_integration_test.go, while
preserving
  newFleetIntegrationServer for multi-page recovery rollup/point tests.
- Route four test fixtures (change_password_session_admin_test.go,
oidc_only_admin_parity_test.go, platform_admin_session_parity_test.go,
and
security_status_capability_enforcement_test.go) through
pkg/auth.HashPassword
so they honor TestMain's PULSE_TEST_BCRYPT_COST instead of
bcrypt.DefaultCost.

Contract-Neutral: Test-only parallelization and fixture optimization
across 19 internal/api test files with zero production code, API
behavior, or assertion changes.

**Keep global-session-store internal/api subtests sequential**

NewRouter calls ensureSessionStore(cfg.DataPath), which replaces and
shuts
down the package-global session store whenever a router is built with a
new
data directory. Keep the six subtest suites that create or mutate
entries in
GetSessionStore() sequential while retaining parallel execution for all
token-only and router-free subtest matrices.

Contract-Neutral: Test-only adjustment reverting t.Parallel() on six
session-store subtest suites; zero production code or assertion changes.

**Keep 24 MiB blocked-write cancellation subtests sequential**

Each subtest in
TestUpdateStreamChainRequestCancellationInterruptsBlockedWrites
broadcasts a 24 MiB payload into a stalled socket; running all four
concurrently
under -race spikes memory pressure on 6 GiB guests without meaningful
runtime gain.
Keep those four subtests sequential while retaining parallel unit
subtests in
token_stream_shutdown_test.go.

Contract-Neutral: Test-only adjustment reverting t.Parallel() on one
4-subtest blocked-write test to avoid concurrent 24 MiB memory spikes
under -race.

**Restrict internal/api subtest parallelization to router-free tests**

NewRouter mutates three package-global singletons (ensureSessionStore,
ensureCSRFStore, and auth.SetManager), and newTestRouter cleanup calls
ShutdownRBAC which closes and clears the global RBAC manager. Remove
t.Parallel() from all subtest matrices that construct newTestRouter
instances while keeping the 11 strictly router-free / sequential-fixture
speedups intact.

Contract-Neutral: Test-only revert of t.Parallel() on
newTestRouter-based subtest matrices to keep package-global RBAC,
session, and CSRF singletons strictly serialized.

---
Fleet candidate `20261128T052019Z-delivery-trust` from the
`delivery-trust` lane. Reviewed tip
`69815679f46c571d6492d382884bb7ffb4170186` on `main`.

[How Pulse handles
triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
2026-11-28 07:27:53 +00:00
..