Adapt scheduler tests to JobRunr-backed core scheduler - #264
Merged
Conversation
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>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
mvn clean installwas failing on 4 scheduler tests. The root cause is upstream: OpenMRS core's scheduler was rewritten to use JobRunr, soTaskDefinition.getTaskInstance()is now alwaysnull(nothing in core callssetTaskInstanceanymore) and the legacy in-processTaskinstance withisExecuting()polling no longer exists. The tests relying on it failed withNullPointerExceptionandassertNotSame(null, null).Changes
SchedulerFormControllerTest— replace the task-instance identity assertions with assertions on the persistedstartedflag and start time, read back viaSchedulerService.getTask(id). Comments document that the reschedule call itself is no longer observable through theTaskDefinitionunder JobRunr.TaskHelper— removewaitUntilTaskIsExecuting(...)(and its now-unused logger/imports); JobRunr exposes no in-process executing state to poll.TaskHelperTest— remove the twowaitUntilTaskIsExecuting_*tests.onSubmit_shouldNotRescheduleAnExecutingTaskcontroller test (the "executing task" state can't be reproduced under JobRunr).The production
SchedulerFormControlleris intentionally left unchanged; itsgetTaskInstance() == nullguard remains null-safe (always short-circuits) under JobRunr.Test plan
mvn clean install→ BUILD SUCCESS, 391 tests run, 0 failures, 0 errors, 3 skipped.SchedulerFormControllerTest4/4 andTaskHelperTest4/4 pass.🤖 Generated with Claude Code