Skip to content

Replace Thread.sleep with event-driven waits in pause/reconfiguration tests #4517

Closed

Description

@Yicong-Huang

Task Summary

Two e2e specs use hardcoded Thread.sleep to wait for state transitions instead of reacting to ExecutionStateUpdate events:

  • PauseSpec.shouldPause (amber/src/test/scala/.../e2e/PauseSpec.scala:111-117): three sleeps (4000 + 400 + 4000 ms) per call. With 2 tests in the spec, that's ~16.8s of pure sleep.
  • ReconfigurationSpec.shouldReconfigure (ReconfigurationSpec.scala:151): one Thread.sleep(4000) after pauseWorkflow.

In both cases the sleep is "wait for the engine to reach PAUSED before the next action." AmberClient already exposes registerCallback[ExecutionStateUpdate], so a Promise that resolves on the matching state event is a drop-in replacement and exits as soon as the engine actually transitions.

Local measurement on PauseSpec: Run completed in 41s 869ms → 28s 791ms, ~13s saved.

The 400ms sleep after resumeWorkflow cannot currently be replaced by an event-driven wait — ResumeHandler does not emit ExecutionStateUpdate (tracked separately in #4514). It can be dropped in a follow-up once that issue is fixed.

The 1000ms sleep at ReconfigurationSpec.scala:132 (per terminal op, inside the COMPLETED callback) is left alone — its TODO comment marks it as a known workaround for "completion reported too early," which is a different bug.

Priority

P2 – Medium

Task Type

  • Refactor / Cleanup
  • Testing / QA

Activity

  1. added a commit that references this issue on Apr 26, 2026
    20c3a57
  2. added a commit that references this issue on Jun 22, 2026
    4bcf726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions