Skip to content

Improve file integrity check + local testing environment#1045

Open
eachristgr wants to merge 3 commits into
dmwm:masterfrom
eachristgr:improve-file-integrity-check
Open

Improve file integrity check + local testing environment#1045
eachristgr wants to merge 3 commits into
dmwm:masterfrom
eachristgr:improve-file-integrity-check

Conversation

@eachristgr

Copy link
Copy Markdown
Contributor

Makes both DMOps apps testable without cluster secrets or a VOMS proxy, and tightens how the integrity checker handles a file's PFNs.

Local testing environment

Added a LOCAL_TESTING switch in settings.py. Set LOCAL_TESTING=true and the app runs self-contained — SQLite plus dummy secrets — so the suite runs with no .env and no source edits:

LOCAL_TESTING=true python manage.py test

It defaults to False, so production is untouched. On master, settings.py fails to import unless SECRET_KEY, JIRA_PAT, and GROUP_AUTHORIZATION_CLIENT_SECRET are set — which blocked every test, including the invalidation tool's fi_manager tests, from starting. LOCAL_TESTING=true supplies dummy values so the whole suite runs.

Integrity check

  • run_check.py: new check_rse helper — an RSE's PFNs are just different access paths to the same bytes, so it tries them in order, validates the first one that copies, and returns a single result per RSE (OK/CORRUPTED/ERROR). It falls through to the next PFN only when a copy fails, and reports ERROR only if all fail — so a transient access failure can't mask a healthy copy. Every attempt is logged.
  • New grid-free tests (test_run_check.py) that mock Rucio/gfal so they run anywhere.
  • file_integrity_checker: fixed the include_* query params, corrected the submit-response wording, added tests.
  • Docs (both READMEs) and .gitignore cleanup.

…wording

The requests view read include_replicas/include_summary/include_logs as raw
query strings, so "false" was truthy and the documented toggles silently did
nothing — a regression from the UI PR (dmwm#1034) that dropped the string->bool
coercion. Restore explicit coercion via a query_bool() helper; include_summary
again defaults on for the detail view and off for the list view (where it costs
one query per request).

Also stop the submit response from advertising "Job ID: None." Jobs are now
assigned asynchronously by the queue processor, so report the queued state
honestly (status SUBMITTED, job_id null).

Add regression tests for the boolean params (including HTML template rendering)
and the submit wording.
…ygiene

Make LOCAL_TESTING read from the environment (default False) and fall back to
dev-default secrets + SQLite under it, so `LOCAL_TESTING=true manage.py test`
runs with no source edits or .env file. Production behaviour is unchanged —
the secrets are still required when LOCAL_TESTING is unset.

Update the file_integrity_checker README: replace the manual settings-patch
instructions with the LOCAL_TESTING workflow, fix the stale submit-response
example and controller filenames, document UI access and deployment, and
correct the test count.

Ignore .env and *.sqlite3 (local secrets and the dev DB the workflow creates).
The per-RSE PFN loop appended a row on every PFN outcome, so an RSE with
multiple PFNs could emit several rows. When the first PFN failed to copy but a
later one succeeded, downstream get_or_create(request, lfn, rse) kept the first
(ERROR) row and dropped the later OK — a transient copy failure became a sticky
false verdict, and per-RSE counts were inflated.

Extract the per-RSE logic into check_rse(), which tries PFNs in order, logs each
attempt, validates the first that copies, and returns exactly one result per
RSE (a single ERROR only if every PFN fails to copy). PFNs point at the same
physical bytes, so re-checking other paths adds no value. The copy/checksum/
content calls are injectable to allow testing without the grid stack.

Add test_run_check.py (7 unit tests, stdlib unittest, gfal2/uproot/rucio stubbed
in sys.modules) covering the regression and the per-RSE behaviour, and document
how to run them in the README.
@eachristgr
eachristgr requested a review from juanpablosalas July 1, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant