Skip to content

feat(testing-utils): Cron job trigger for test harness #1287

@drewstone

Description

@drewstone

Problem

CronJob / workflow_tick fires on real wall-clock time. Tests cannot force-fire a cron workflow iteration without waiting for the next cron tick, making tests:

  • Slow: A cron job scheduled for every 60 seconds means tests wait up to 60 seconds per iteration.
  • Non-deterministic: Timing-dependent assertions are inherently flaky — CI machines under load may miss windows entirely.
  • Hard to debug: Reproducing a cron-related bug requires waiting through real schedule intervals.

Proposal

Add a harness.trigger_cron_job(job_id) method to the test harness that directly invokes the cron handler, bypassing the wall-clock schedule.

// In a test
let harness = BlueprintHarness::new(config).await?;

// Instead of sleeping and hoping the cron fires...
// trigger_cron_job() invokes the handler immediately
let result = harness.trigger_cron_job(MY_CRON_JOB_ID).await?;

// Assert on the result deterministically
assert!(result.is_ok());

This would also be useful for debugging — developers could manually trigger cron iterations from a REPL or test script without modifying the schedule.

Context

BlueprintHarness already supports a rich set of test utilities (PR #1283):

  • with_env_vars() — inject environment variables per-test
  • with_state_dir_env() — isolated state directories
  • with_pre_spawn_hook() — custom setup before spawning
  • MultiHarness — test multiple blueprints and operators together
  • OperatorFleet — manage multiple operators per blueprint

Adding trigger_cron_job() would complete the testing toolkit by giving tests full control over time-dependent workflows, making the harness sufficient for all blueprint testing scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature ➕Tasks that are functional additions or enhancements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions