Files
app-catalog-felhom.eu/scripts/test_upgrade_bench.py
T
admin 5b1972b7f9
gates / gates (push) Successful in 2s
harness: five new front-door fixtures, gitea's installer, HTTPS backends, per-file change names (R-462, R-624, R-735)
- fixtures (upgrade_fixtures_box.py): calibre-web (Upload form -> OPDS readback + the served EPUB),
  wger (web login -> weight entry API), crafty-controller (API v2 roles), uptime-kuma (socket.io
  polling: setup, login, addStatusPage -> public /api/status-page/<slug>); gitea posts its own
  first-run installer form (R-624's fixable case) and keeps the admin CLI for an installed one.
  calibre-web and wger run the template's own after_install on the bench, which has none.
- R-735: the bench's `password:N:special` now has the controller's shape (randomWithSpecial);
  test seen failing first (length 32, no special), then 45/45.
- upgrade_boxport / the memory watch: a backend traefik reaches over https (loadbalancer.server.scheme)
  is reached over https on the bench too (crafty-controller).
- upgrade-test: files-before/after-detail.json and `files_changed_detail` NAME the files behind a
  files_may_change mark (R-734's method, now in the harness); test ChangedFiles.
- test_catalog_gates: the gate count was stale (9, the runner has 10) and red on main; now 10.

Evidence: felhom.eu/documentation/audits/more-night-apps-2026-09-30/

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
2026-09-30 18:16:45 +02:00

86 lines
3.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""test_upgrade_bench.py — the test bench's two night-of-2026-09-23 faults (R-653, R-656). No Docker.
python3 scripts/test_upgrade_bench.py
"""
import importlib.util
import os
import shutil
import tempfile
import unittest
HERE = os.path.dirname(os.path.abspath(__file__))
spec = importlib.util.spec_from_file_location("upgrade_test_mod", os.path.join(HERE, "upgrade-test.py"))
ut = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ut)
class LoadVerdict(unittest.TestCase):
"""R-653. RED-PROOF (REPORT.md): make load_verdict always return "reached" — the ghost case fails."""
def test_every_request_errored_is_inconclusive(self):
# ghost's first watch, 2026-09-23 night: 11 797 requests, all `err`
self.assertEqual(ut.load_verdict(11797, {"err": 11797}), "inconclusive")
def test_answers_of_any_code_are_the_app_answering(self):
self.assertEqual(ut.load_verdict(11429, {"200": 5712, "401": 5717}), "reached")
self.assertEqual(ut.load_verdict(10, {"302": 5, "err": 5}), "reached")
def test_under_half_is_inconclusive_and_none_is_inconclusive(self):
self.assertEqual(ut.load_verdict(10, {"200": 4, "err": 6}), "inconclusive")
self.assertEqual(ut.load_verdict(0, {}), "inconclusive")
class ClearScratch(unittest.TestCase):
"""R-656. RED-PROOF (REPORT.md): make clear_scratch_folders return [] without removing — the first
test fails with the last run's config still there."""
def setUp(self):
self.root = tempfile.mkdtemp(prefix="bench-scratch-")
self.hdd = os.path.join(self.root, "hdd")
self.env = {"HDD_PATH": self.hdd, "USERDATA_PATH": self.hdd + "/userdata"}
self.said = []
def tearDown(self):
shutil.rmtree(self.root, ignore_errors=True)
def plant(self, rel):
p = os.path.join(self.hdd, rel, "config", "config.php")
os.makedirs(os.path.dirname(p), exist_ok=True)
open(p, "w").write("last run")
return p
def test_the_apps_own_folders_are_cleared_and_said(self):
mine = self.plant("appdata/nextcloud")
other = self.plant("appdata/immich")
comp = "services:\n nextcloud:\n volumes:\n - ${HDD_PATH}/appdata/nextcloud:/var/www/html\n"
got = ut.clear_scratch_folders(comp, self.env, self.said.append)
self.assertFalse(os.path.exists(mine), "the last run's files are still there")
self.assertTrue(os.path.exists(other), "another app's folder was touched")
self.assertEqual(len(got), 1)
self.assertTrue(any("cleared before FROM" in s for s in self.said))
def test_never_a_bare_root_never_outside(self):
keep = self.plant("appdata/x")
comp = (" volumes:\n - ${HDD_PATH}:/data\n - ${HDD_PATH}/:/d2\n"
" - ${HDD_PATH}/../escape:/e\n")
got = ut.clear_scratch_folders(comp, self.env, self.said.append)
self.assertEqual(got, [])
self.assertTrue(os.path.exists(keep))
class ChangedFiles(unittest.TestCase):
"""2026-09-30: a `files_may_change` mark names its files (R-734's method, now in the harness)."""
def test_names_changed_added_removed_and_nothing_else(self):
before = {"/d": {"a.txt": "1:aa", "b.txt": "1:bb", "gone": "1:cc"}}
after = {"/d": {"a.txt": "1:aa", "b.txt": "2:bd", "new": "1:dd"}}
self.assertEqual(ut.changed_files(before, after),
["/d/b.txt (changed)", "/d/gone (removed)", "/d/new (added)"])
self.assertEqual(ut.changed_files(before, before), [])
if __name__ == "__main__":
unittest.main(verbosity=2)