5ed599cd5f
gates / gates (push) Successful in 2s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
75 lines
3.0 KiB
Python
75 lines
3.0 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))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|