FINERACT-2455: Pin the business date in savings interest posting job tests - #6422
Open
oleksii-novikov-onix wants to merge 1 commit into
Open
Conversation
7 tasks
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.
Description
The tests in SavingsInterestPostingJobIntegrationTest build their accounts on fixed 2022 dates (10 April, 21 June, 01 July). But four of them ran the "Post Interest For Savings" job without setting a business date, and one set it to Utils.getLocalDateOfTenant(). When enable-business-date is off, the business date falls back to the tenant's today, so the job posted interest from 2022 up to the real current date.
That is slow and it gets slower. For the April account the job walks about 1600 daily posting periods today, and one more every day.
It is also fragile. The job processes every ACTIVE savings account in the tenant, not only ours. SavingsSchedularInterestPoster.postInterest() is all or nothing per batch: if one account throws, batchUpdate() is skipped and no account in that batch gets its transactions. PostInterestForSavingTasklet.checkCompletion() only logs the error and the tasklet still returns RepeatStatus.FINISHED, so the job reports success and the test fails later on a short transaction list. A wider posting window means more work per batch and more chances to hit this.
Which accounts share the database is not stable either. scripts/split-tests.sh sorts all eligible test classes and splits them by NR % total_shards (15 shards, same for mysql, postgresql and mariadb). Adding one test class anywhere shifts every class after it into the next shard, so this class gets new neighbours. A clock-driven, tenant-wide job can therefore pass for a long time and then break in a branch that only added an unrelated test.
Fix: pin the business date. POSTING_JOB_BUSINESS_DATE = 31 July 2022 sits past every fixture in the class (last account starts on 01 July, last asserted posting is on 10 July), and every test that runs the job now goes through businessDateHelper.runAt(...). The submittedOnDate check compares against that date instead of today. The posting window drops from ~1600 days to 112.
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.