Skip to content

Adapt scheduler tests to JobRunr-backed core scheduler - #264

Merged
dkayiwa merged 1 commit into
masterfrom
fix/scheduler-tests-jobrunr
Jun 8, 2026
Merged

Adapt scheduler tests to JobRunr-backed core scheduler#264
dkayiwa merged 1 commit into
masterfrom
fix/scheduler-tests-jobrunr

Conversation

@dkayiwa

@dkayiwa dkayiwa commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

mvn clean install was failing on 4 scheduler tests. The root cause is upstream: OpenMRS core's scheduler was rewritten to use JobRunr, so TaskDefinition.getTaskInstance() is now always null (nothing in core calls setTaskInstance anymore) and the legacy in-process Task instance with isExecuting() polling no longer exists. The tests relying on it failed with NullPointerException and assertNotSame(null, null).

Changes

  • SchedulerFormControllerTest — replace the task-instance identity assertions with assertions on the persisted started flag and start time, read back via SchedulerService.getTask(id). Comments document that the reschedule call itself is no longer observable through the TaskDefinition under JobRunr.
  • TaskHelper — remove waitUntilTaskIsExecuting(...) (and its now-unused logger/imports); JobRunr exposes no in-process executing state to poll.
  • TaskHelperTest — remove the two waitUntilTaskIsExecuting_* tests.
  • Remove the onSubmit_shouldNotRescheduleAnExecutingTask controller test (the "executing task" state can't be reproduced under JobRunr).

The production SchedulerFormController is intentionally left unchanged; its getTaskInstance() == null guard remains null-safe (always short-circuits) under JobRunr.

Test plan

  • mvn clean installBUILD SUCCESS, 391 tests run, 0 failures, 0 errors, 3 skipped.
  • SchedulerFormControllerTest 4/4 and TaskHelperTest 4/4 pass.

🤖 Generated with Claude Code

The core scheduler was rewritten to use JobRunr, so
TaskDefinition.getTaskInstance() is now always null and the legacy
in-process Task instance (with isExecuting() polling) no longer exists.
Tests relying on it were failing with NPEs and assertNotSame(null, null).

- Replace task-instance identity assertions in SchedulerFormControllerTest
  with assertions on the persisted started flag and start time.
- Remove TaskHelper.waitUntilTaskIsExecuting and the two TaskHelperTest
  cases plus the executing-task controller test, which exercised the
  removed in-process execution-polling behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@dkayiwa
dkayiwa merged commit 7a8b836 into master Jun 8, 2026
5 checks passed
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