fix(tests): make testLastDayCron deterministic#15809
Merged
Conversation
…rst of month The test used ZonedDateTime.now() as the previous trigger date, which caused it to fail whenever run on the last day of any month (e.g. April 30). On such days, nextEvaluationDate correctly returns the last day of the *next* month, not the current month, making the assertion fail. Forcing withDayOfMonth(1) ensures the test always runs as if it is early in the month, so the next L-cron hit is always within the same month.
Member
OpenAPI Spec Changes (EE-generated)No EE spec drift (EE branch: |
Contributor
🐋 Docker imagedocker run --pull=always --rm -it -p 8080:8080 --user=root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp ghcr.io/kestra-io/kestra-pr:15809 server local🧪 Java Unit Tests
|
Contributor
Tests report quick summary:success ✅ > tests: 5304, success: 5284, skipped: 20, failed: 0 unfold for details
Develocity build scan: https://develocity.kestra.io/s/4rkk65ntcjfeg Flaky tests report quick summary:failed ❌ > tests: 38, success: 36, skipped: 0, failed: 2
Failed tests:scheduler > io.kestra.scheduler.TriggerSchedulerTest > shouldSucceedScheduleConditionalScheduleTriggerGivenValidTimeZone() failed ❌ in 1.077worker > io.kestra.worker.WorkerTest > shouldKillTasksWhenExecutionKillEventReceived() failed ❌ in 14.266 |
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
ScheduleTest.testLastDayCron()fails on the last day of any month becauseZonedDateTime.now()is used as the previous trigger datenextEvaluationDatecorrectly returns the last day of the next month, but the test expected the current month's last daynowtowithDayOfMonth(1)so the test always executes as if it is early in the month, making the next L-cron hit predictably within the same monthRoot cause
The cron
0 12 L * *fires at noon on the last day of each month. When the test ran on April 30 at noon, the previous-trigger date was April 30 12:00, sonextEvaluationDatereturned May 31 (day 31) — but the assertion expected day 30 (April's last day).Test plan
./gradlew :core:test --tests "io.kestra.plugin.core.trigger.ScheduleTest.testLastDayCron"passes locally