Skip to content

test: remove fixed test waits on the CI critical path (~90s off module test time) - #3553

Merged
xzxiaoshan merged 3 commits into
agentscope-ai:mainfrom
xzxiaoshan:fix/scheduler-test-retry-fix
Oct 14, 2026
Merged

xzxiaoshan merged 3 commits into
agentscope-ai:mainfrom
xzxiaoshan:fix/scheduler-test-retry-fix

Conversation

@xzxiaoshan

@xzxiaoshan xzxiaoshan commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Background

The Linux CI build step sits at 693s after #3543; effective parallelism (~3.3/4) is near hardware saturation, so the remaining bottleneck is the dependency-chain critical path: Core(84s) → extensions → Harness(167s) → Service Common(78s) → … → Service Scheduler(119s, wall end). This PR removes deterministic wait waste from tests on that path (fixed sleeps, coarse polling, oversized observation windows). No assertion or behavior under test changes; production defaults are untouched.

Changes

  1. Scheduler (−55s): SchedulerAppContextLoadTest sets builder.scheduler.channel-config-retries=1 — the 12×5s retry backoff was pure idle waiting in tests (local 85.65s → 13.89s); the app still boots with 0 channels. Production default (12 retries / 5s) unchanged.
  2. Injectable poll intervals: WorkspaceMessageBus heartbeat and WaitAsyncResultsTool polling gained injectable constructors, and WorkspaceTaskRepository a package-private setAwaitingConfirmPollMs seam (mirrors the existing setTransport hook). Production defaults (3s / 3s / 750ms) unchanged; tests inject 50ms.
  3. Wait tightening (scenario-derived bounds, each documented with its derivation in comments):
    • 5 budget waits in WaitAsyncResultsToolTest use the existing VirtualTime helper (8.6s → 0.65s), timeout values unchanged
    • Observation windows sized to iteration periods: AgentSpawnToolOrphanCancelTest 4s → 1s (~150ms/iteration), SubAgentToolTimeoutRetryIntegrationTest 2s+2s → 1.5s+0.75s
    • Fixed sleeps → bounded polling (25ms step / 5s cap, returns on completion): GracefulShutdownTest, TrainingRunnerTest, AsyncToolMiddlewareTest
    • Negative-assertion windows sized to tick multiples: WakeupDispatcherTest 500ms×2 → 300ms×2, MongoSandboxExecutionGuardTest 500+after(500) → 300+after(300)

Verification

  • Affected test classes green (targeted runs)
  • Full harness module: 1240 tests / 0 failures / 0 errors
  • core / training / mongodb targeted suites green
  • spotless:check clean
  • Rebased onto current upstream main (8485ca8); affected classes re-run green after rebase

Expected impact(Estimate)

~−89s of module-level test time (Scheduler −55 / harness −32.5 / core −2.2); Linux build step 693s → ~600–610s (−13%). Sleep durations are wall-clock stable under CI contention, so the translation to wall time is ~1:1 for critical-path modules.

SchedulerAppContextLoadTest paid 55s per run sleeping through
SchedulerChannelRuntime's default 12 x 5s control-plane retries against
the unlistened test URL (localhost:8081). service-scheduler is the
critical-path wall endpoint, so the saving lands ~1:1 on the Linux
build step. Set builder.scheduler.channel-config-retries=1 in the test
properties: one failed attempt yields the same "starting with zero
channels" outcome (local run 85.7s -> 13.9s; production defaults
unchanged).

AsyncToolMiddlewareTest.toolExceedsTimeout_emitsPlaceholderAndOffloads
waited a fixed 3s for the background inbox push that arrives ~2s after
the offload. Replace the sleep with a bounded poll (5s deadline, 50ms
interval) so the test finishes as soon as the push lands and keeps a
safe margin on slow runners (the old fixed margin was ~0.3s).
WorkspaceMessageBus.subscribe() ticks at a hardcoded 3s (pub/sub is
degraded to polling) and WaitAsyncResultsTool polls at a hardcoded 3s
granularity, so every signal-driven test paid up to 3s per wait:
WakeupDispatcherTest waited out two full ticks, the subscribe regression
tests in WorkspaceMessageBusTest waited ~3s each for the first tick, and
two completion-bound WaitAsyncResultsTool tests slept through their whole
remaining budget after the tasks had completed at 150/300ms.

Add injectable intervals with unchanged production defaults (3s):
- WorkspaceMessageBus(filesystem, busRoot, pollInterval) public ctor;
  null/zero/negative falls back to the default
- WaitAsyncResultsTool package-private (bus, repo, pollIntervalMs) and
  (bus, repo, clock, sleeper, pollIntervalMs) overloads

Tests pass 50ms where the tick is the bottleneck. Local per-class:
WakeupDispatcherTest 7.2s -> 1.2s, WorkspaceMessageBusTest 6.1s -> 0.2s,
WaitAsyncResultsToolTest 12.1s -> 8.6s (the remainder is 1s-budget empty
waits, i.e. the semantics under test). Harness verify: 1240 tests green.
- WaitAsyncResultsToolTest: convert 5 real-clock budget waits to the
  existing VirtualTime helper (8.6s -> 0.65s), timeout values unchanged
- WorkspaceTaskRepository: add package-private setAwaitingConfirmPollMs
  test seam mirroring setTransport (production default 750ms unchanged);
  remote streaming tests inject 50ms (5.4s -> 0.96s)
- Observation windows sized to iteration periods:
  AgentSpawnToolOrphanCancelTest 4s -> 1s (~150ms/iteration),
  SubAgentToolTimeoutRetryIntegrationTest 2s+2s -> 1.5s+0.75s
- Replace fixed sleeps with bounded polling (25ms step, 5s cap):
  GracefulShutdownTest, TrainingRunnerTest
- Negative-assertion windows sized to tick multiples:
  WakeupDispatcherTest 500ms x2 -> 300ms x2,
  MongoSandboxExecutionGuardTest 500+after(500) -> 300+after(300)
- Fix stale comments/javadoc from the previous poll-seam commit

Assertions and behavior under test are unchanged; each new duration is
documented with its derivation.

Verified: affected classes green, full harness module 1240 tests /
0 failures, spotless clean.
@xzxiaoshan
xzxiaoshan merged commit 044f3b1 into agentscope-ai:main Oct 14, 2026
7 checks passed
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ntscope/harness/agent/bus/WorkspaceMessageBus.java 77.77% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants