VSB-TUO/Fix EmbargoImportIT time-bomb: compute embargo dates dynamically - #1359
Merged
Merged
Conversation
testStandardEmbargoImport and testMultipleBitstreamsEmbargo started failing on 2026-06-30 because the test hardcoded EMBARGOEND_DATE_FUTURE = 2026-06-30 as a future embargo end date. Once real time passed that date, ItemImportServiceImpl.processEmbargoMetadata correctly skipped the embargo (a policy whose end date is past must not be applied - the same behaviour this suite itself asserts in testPastEmbargoDateNoPolicy), so the policy start date was null and both assertNotNull checks failed. The import logic is NOT broken: the branch head is unchanged since 2026-06-08, CI was green through 2026-06-29 and turned red on every run from 2026-06-30 00:57 UTC onward - the exact moment the hardcoded date rolled into the past. The bug is the test encoding the assumption that a fixed calendar date stays in the future. Fix: derive the embargo end date from LocalDate.now().plusYears(1) and the expected policy start date from it (+1 day), preserving the exact assertions (policy start = embargoend + 1 day, formatted yyyy-MM-dd). Verified locally: EmbargoImportIT 5/5 pass (was 3/5). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Fixes the two consistently failing integration tests on
customer/vsb-tuo:EmbargoImportIT.testStandardEmbargoImport(line 174) —AssertionError: Embargo policy should have start dateEmbargoImportIT.testMultipleBitstreamsEmbargo(line 362) —AssertionError: Each embargo policy should have start dateVerdict: the test was wrong, not the embargo logic. The test hardcoded a "future" embargo end date (
2026-06-30) that rolled into the past — a time-bomb test.Root cause analysis
EmbargoImportITdeclared:ItemImportServiceImpl.processEmbargoMetadata()intentionally refuses to apply an embargo whose end date has already passed (if (endDate.before(new Date())) { ... return; }), so once real time passed 2026-06-30 the import stopped creating the embargoResourcePolicy, its start date wasnull, and bothassertNotNullchecks failed.Hypotheses considered and ruled out
60f0a21a) has been unchanged since 2026-06-08. Scheduled CI on that same commit was green through 2026-06-29 20:40 UTC and has failed on every run since 2026-06-30 00:57 UTC — the exact momentDCDate("2026-06-30")(midnight UTC, 2026-06-30) became a past date. No code changed; only the calendar moved.org.dspace.app.itemimport.EmbargoImportITto diverge from. The hardcoded date has been in the test since it was written (2025-09), when it was still ~9 months in the future.testPastEmbargoDateNoPolicy("Should not have embargo policy for past dates"). The incorrect assumption is that a fixed calendar date stays in the future.Fix
Compute the embargo dates relative to the test run instead of hardcoding them:
No assertion was relaxed or removed: the test still requires the embargo policy to exist for the Anonymous group, to have a non-null start date, and that the start date equals embargo end + 1 day in
yyyy-MM-ddformat (LocalDate.toString()is the same ISO format previously hardcoded).EMBARGOEND_DATE_PASTstays hardcoded (2020-01-01) since a past date can never expire.Test evidence
EmbargoImportIT(local, Windows)dspace-apiIT suiteEmbargoImportIT, failed even withrerunFailingTestsCount=2→ consistent, not flaky)EmbargoImportITgreen; remaining failures only inItemImportCLIIT(see below)Note on
ItemImportCLIIT(local only, pre-existing): on my Windows machineItemImportCLIITfails nondeterministically (9 failures in the full run, 1 when run in isolation) withjava.nio.file.FileSystemException: ... The process cannot access the file because it is being used by another processduring temp-file cleanup — a Windows file-locking issue. It is unrelated to this change (this PR touches only constants inEmbargoImportIT) and the class passes on Linux CI, where the pre-fix run's only failures across all 458 tests were the two embargo tests. CI on this PR should come back fully green.cc @Kasinhou
🤖 Generated with Claude Code