CLARIN-DSpace v9/Restore the fork health checks taken wholesale from vanilla (23 of 26 report-diff mappings have no emitter) - #1439
Open
milanmajchrak wants to merge 1 commit into
Conversation
… report-diff mappings had no emitter) InfoCheck, ItemCheck and UserCheck were byte-identical with vanilla dspace-9.3 on the v9 base although the fork changes all three. The upgrade took them from upstream whole and the fork hunks never landed, so their setReportJson calls were gone: only LicenseCheck and (since BE-13) MetadataCheck still emitted report JSON, and 23 of the 26 mappings in report-diff-fields.json addressed a value nothing produced - Item summary 17, User summary 4, General Information 2. report-diff printed those columns empty and nothing failed. The three checks now build the same JSON the fork does, alongside the unchanged human-readable report. Two deliberate deviations from the fork, both recorded in the PR: getObjectSizesInfo keeps the v9 direct calls instead of the fork's wrapSql wrapper, which converts the checked SQLException into a RuntimeException that run()'s catch cannot see and that would abort the whole report; and ReportInfo returns LocalDate on v9, so the dates are formatted directly instead of via Date.toInstant().atZone(). UserCheck also carries the fork's fix of the "Self registered" counter, which tested getNetid() twice. Report.java goes with them: the fork deleted it in 3dc9cec when the health-report script replaced it, and launcher.xml still pointed the healthcheck command at it, so `dspace healthcheck` ran the old class that writes no JSON and no ReportResult at all. ReportDiffFieldMappingIT walks every mapping in report-diff-fields.json against a real health report, so a mapping that loses its emitter fails instead of silently printing nothing. Card X-08. Co-Authored-By: Claude Opus 5 (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.
References
_sync3/cards/X-08.md); depends on BE-13, merged asac1eeecd793dc9cecf7d"Health report, report diff fixes (Health report, report diff fixes #1254)" ondtq-devItemCheckandReportare the two largest entries in the BE X1 worklistDescription
InfoCheck,ItemCheckandUserCheckwere byte-identical with vanilladspace-9.3on this branchalthough the fork changes all three. Their
setReportJsoncalls were therefore gone, and 23 of the 26mappings in
report-diff-fields.jsonaddressed a value that nothing produced.report-diffprintedthose columns empty and no test failed.
Instructions for Reviewers
The defect
report-diffnever reads the checks. It reads the JSON that a health-report run stored and addresses eachvalue by a path such as
/checks/[name=Item summary]/report/collectionsSizesInfo/totalSize. Nothing linksthat path back to the class that is supposed to emit it, so when the v9 upgrade took the three classes from
upstream whole, the mappings kept resolving to nothing and the only symptom was empty columns.
Measured on the base (
6e8185521f):Breakdown of the 23: Item summary 17, User summary 4, General Information 2.
List of changes in this PR
InfoCheck- emitsgenerated,fromTill,urland thedirectoryStatsarray.report-diffaddresses that array positionally (
directoryStats/0assetstore,/1log dir), so an entry is appendedfor every directory even when it cannot be read; dropping one would shift the other's index.
ItemCheck- emitscommunities,collectionsSizesInfo(withtotalSize,deletedBitstreams,orphanBitstreamsCount, ...),publishedItems,withdrawnItems,notPublishedItems,stagesCounts,waitingForApprovaland the eleven entity counts. All 17 Item summary mappings.UserCheck- emitsusers,haveEmail, the camel-cased per-attribute counts (includingselfRegistered),emptyGroups,subscribersandsubscribedCollections. It also carries the fork'sfix of the "Self registered" counter, which tested
getNetid()twice and so reported a copy of"Have netid".
Report.javadeleted, and itshealthcheckcommand removed fromlauncher.xml- see below.ReportDiffFieldMappingIT(new) - three tests that keep this from happening again.Two deliberate deviations from the fork, both to avoid importing a defect:
ItemCheck.getObjectSizesInfokeeps the v9 directcountTotal(context)calls instead of the fork'swrapSql+LinkedHashMap<String, CountInfo>refactor.wrapSqlconverts the checkedSQLExceptioninto a
RuntimeException, whichrun()'scatch (SQLException)cannot see - one failing count wouldabort the entire health report instead of being recorded by
error(e)and the rest of the reportfinishing. The JSON keys, their order and the report text are the fork's.
ReportInforeturnsLocalDateon v9 andDateon the fork, so the dates are formatted directly withDateFormatConstants.DATE_FORMATTERrather than throughDate.toInstant().atZone(...).Minor:
!s.isEmpty()kept where the fork writess.length() > 0; instance service fields kept rather thanthe fork's
static final.Why
Report.javais in this PR3dc9cecf7ddeletedorg/dspace/health/Report.javawhen thehealth-reportDSpaceRunnable replaced it,and removed the
healthcheckcommand that pointed at it. The v9 base kept both: the class, andlauncher.xml:14still declaringhealthcheckwith<class>org.dspace.health.Report</class>. Sodspace healthcheckon the CLI ran the pre-script class, which writes neithersetReportJsonoutput nor aReportResultrow - report-diff would have had nothing to diff even after the three checks above werefixed. The replacement is already wired on this branch
(
dspace/config/spring/api/scripts.xml:115, beanhealth-report), andReporthad no other reference inthe tree. It belongs to the same fork hunk and the same feature, so it goes in the same PR. The
matomo-report-generatorcommand that sits in the samelauncher.xmldelta does not - that is card X-04.How to test
everyMappedFieldIsEmittedByItsCheckreport-diff-fields.jsonagainst the JSON it storedeveryMappedCheckNameResolvesToACheckOnTheClasspath[name=...]resolves to aCheckplugin registered inconfig/modules/healthcheck.cfgfieldMappingsAndFieldOrderDescribeTheSameFieldsReportDiffiteratesfieldOrderand only looks the label up infieldMappings, so a field in one and not the other is silently droppedNegative control - revert each class to its vanilla blob and the test names exactly the mappings that class
owns:
dspace-9.3ItemCheck[name=Item summary]UserCheck[name=User summary]InfoCheck[name=General Information]/report/directoryStats/N/size_bytes17 + 4 + 2 = the 23 mappings this PR restores.
Regression gate:
HealthReportIT-Tests run: 12, Failures: 0, Errors: 0.mvn clean install -P-assembly -DskipTests- BUILD SUCCESS, 0 Checkstyle violations.Found while working, not fixed here
dspace-api/src/test/java/org/dspace/scripts/ReportDiffIT.javaexists ondtq-dev(1016 lines) and isabsent from this branch, and no acceptance card owns it. The report-diff script itself is ported here;
only its test is missing. It needs its own card.
Checklist
dtq-dev-9-basebranch (fork's DSpace 9 base; notmain).launcher.xmlcommand.🤖 Generated with Claude Code