Skip to content

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

Closed
xzxiaoshan wants to merge 3 commits into
mainfrom
fix/scheduler-test-retry-fix
Closed

xzxiaoshan wants to merge 3 commits into
mainfrom
fix/scheduler-test-retry-fix

Conversation

@xzxiaoshan

Copy link
Copy Markdown
Owner

Background

The Linux CI build step is at 693s after agentscope-ai#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 (3 commits)

  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); 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

Expected impact

~−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.

Test plan

  • Linux CI: watch build step 693s → 600–610s
  • Windows CI: no new flakes
  • Re-check on main after merge

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 closed this Oct 14, 2026
@xzxiaoshan

Copy link
Copy Markdown
Owner Author

Closing in favor of the upstream PR: agentscope-ai#3553 (this one was mistakenly created against the fork's own main).

xzxiaoshan added a commit that referenced this pull request Nov 11, 2026
…_source semantics

Review feedback #2 (scope reduction): the skillId format, default source
and same-name merge changes were not required for the grant layer.

- separator: SKILL_ID_SEPARATOR moves to SkillUtil and reverts to "_";
  getSkillId() always composes name + "_" + source
- restore the "custom" default source and the strict name charset
  (^[a-z0-9][a-z0-9-]*$, no underscores — PR agentscope-ai#3787)
- catalogs merge by name again: same name keeps the higher-priority copy
- grant vocabulary is the skill name: convention groups resolve by backward
  derivation (group name -> name part), activateOnSkill bindings expand at
  the call entry via the new SkillUtil.parseSkillName
- allowedSkills additionally honours an exact full-skillId entry as a
  program-level compatibility (javadoc-documented; user docs stay name-only)

Unconfigured behavior is unchanged from main; the grant layer (gates,
filters, inheritance, ordering) is untouched.
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.

1 participant