mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
Resolves 68 conflicted files. The governing rule was our structure with their
network semantics: the tor boolean becomes a network mode (clearnet | tor |
multi) throughout the variant layer, while this branch's architecture and mesh
axes, its extracted modules and its i18n content stay.
Where the two sides covered different ground, both are kept rather than one
picked:
- ca_injected answers a ca_client on the deployment's TLS mode OR on an SSO
issuer that resolves self-signed. 3a3e9ed2c9 records why: an issuer is not
an object store, so keeping only one side drops the other's coverage.
- get_merged_domains keeps the loud refusal when svc-net-tor is deployed
without a provisioned node, now gated on their tor_serves_host; their
node_onion_of returns an empty string there, which would have served every
onion-exclusive app on clearnet in silence.
- sso_cookie_domains stays the single source for oauth2-proxy's cookie scope.
Their per-network branch omitted the issuer domain on the onion arm, which
breaks the callback leg.
- The clearnet CSP batch carries --clearnet-timeout again; their batch dict
hardcoded zero while the role still passes the flag.
- The dashboard keeps its i18n content dir, image, version and design
resolution; their side reduced the logo sources to the bare service
provider values.
Their side wins where it is measurably better: the onion mirror rewrite is
gated per vhost rather than per app, the Playwright onion decision reads the
pass's own domain instead of the role's canonical one, and the matomo
reinjection and dashboard config render per network sibling.
Eight files were broken by the merge without ever carrying a conflict marker,
because git marks only the lines both sides touched:
- utils/cache/domains.py lost the onionize block that sat between two hunks
- roles/sys-front-inj-all/templates/body_filter.lua.j2 called it
- web-app-bluesky, keycloak sso_proxy: the get_entity_name filter was renamed
- trigger/__main__.py, playwright_coverage.py and its test: the deleted tor
module
- cli/administration/deploy/ci/timings.py read Label.tor
- plugins/filter/csp_filters.py called _aligned_url with four of six arguments
- tests/unit/python/utils/cache/test_domains.py referenced a renamed class
- tests/.../sys-ctl-hlth-csp/files/test_script.py mocked a function main no
longer calls
Verified: the variant layer (155 tests, 65 subtests), ca_injected (18),
the CI layer (175), the domains cache including the restored guard (32),
retrigger inputs (9), timings and the CSP health script (53). make
quality-high clears autoformat; its remaining findings are tracked separately.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
127 lines
4.0 KiB
Python
127 lines
4.0 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from typing import ClassVar
|
|
|
|
from cli.administration.deploy.ci import timings
|
|
from tests.utils.ci.job_names import deploy_job_name
|
|
from utils.github.variant.pools import ARCHITECTURES, DISTROS, FILESYSTEMS
|
|
|
|
|
|
def _job(
|
|
name: str,
|
|
*,
|
|
minutes: float,
|
|
conclusion: str = "success",
|
|
status: str = "completed",
|
|
) -> dict:
|
|
return {
|
|
"name": name,
|
|
"status": status,
|
|
"conclusion": conclusion,
|
|
"startedAt": "2026-09-23T10:00:00Z",
|
|
"completedAt": f"2026-09-23T{10 + int(minutes) // 60:02d}:{int(minutes) % 60:02d}:00Z",
|
|
}
|
|
|
|
|
|
class TestSamples(unittest.TestCase):
|
|
"""Which jobs a duration is read off, and which are left out."""
|
|
|
|
def test_a_failed_job_is_not_measured(self) -> None:
|
|
jobs = [
|
|
_job(deploy_job_name("docker", "web-app-matomo", "0"), minutes=10),
|
|
_job(
|
|
deploy_job_name("swarm", "web-app-matomo", "0"),
|
|
minutes=90,
|
|
conclusion="failure",
|
|
),
|
|
]
|
|
grouped = timings.samples(jobs)
|
|
self.assertEqual(
|
|
sorted(grouped["mode"]),
|
|
["compose"],
|
|
"a failed job's duration measures the failure, not the axis",
|
|
)
|
|
|
|
def test_a_job_without_both_timestamps_is_left_out(self) -> None:
|
|
job = _job(deploy_job_name("docker", "web-app-matomo", "0"), minutes=10)
|
|
del job["completedAt"]
|
|
self.assertEqual(timings.samples([job])["mode"], {})
|
|
|
|
def test_a_title_that_carries_no_row_is_left_out(self) -> None:
|
|
self.assertEqual(
|
|
timings.samples([_job("🧪 Unit tests", minutes=5)])["mode"], {}
|
|
)
|
|
|
|
def test_every_axis_of_one_title_is_attributed(self) -> None:
|
|
job = _job(
|
|
deploy_job_name(
|
|
"swarm",
|
|
"web-app-matomo",
|
|
"0",
|
|
network="tor",
|
|
distro=DISTROS[0],
|
|
filesystem=FILESYSTEMS[0],
|
|
architecture=ARCHITECTURES[0],
|
|
),
|
|
minutes=30,
|
|
)
|
|
grouped = timings.samples([job])
|
|
self.assertEqual(sorted(grouped["mode"]), ["swarm"])
|
|
self.assertEqual(sorted(grouped["network"]), ["tor"])
|
|
self.assertEqual(sorted(grouped["distro"]), [DISTROS[0]])
|
|
self.assertEqual(sorted(grouped["filesystem"]), [FILESYSTEMS[0]])
|
|
self.assertEqual(sorted(grouped["architecture"]), [ARCHITECTURES[0]])
|
|
|
|
|
|
class TestRanking(unittest.TestCase):
|
|
"""Cheapest first, and only for values that were seen often enough."""
|
|
|
|
_GROUPED: ClassVar[dict[str, dict[str, list[float]]]] = {
|
|
"mode": {
|
|
"swarm": [600.0, 600.0, 600.0],
|
|
"compose": [300.0, 300.0, 300.0],
|
|
"host": [1.0],
|
|
},
|
|
"tor": {},
|
|
"distro": {},
|
|
"filesystem": {},
|
|
}
|
|
|
|
def test_the_cheapest_measured_value_wins(self) -> None:
|
|
self.assertEqual(timings.fastest(self._GROUPED, "mode"), "compose")
|
|
|
|
def test_a_single_observation_does_not_steer_the_run(self) -> None:
|
|
self.assertNotIn(
|
|
"host",
|
|
[
|
|
value
|
|
for value, _median, _count in timings.ranking(self._GROUPED, "mode")
|
|
],
|
|
"one job is a queue wait, not a measurement",
|
|
)
|
|
|
|
def test_the_median_ignores_one_long_tail(self) -> None:
|
|
grouped = {
|
|
"mode": {"compose": [300.0, 300.0, 9000.0], "swarm": [400.0] * 3},
|
|
"tor": {},
|
|
"distro": {},
|
|
"filesystem": {},
|
|
}
|
|
self.assertEqual(timings.fastest(grouped, "mode"), "compose")
|
|
|
|
def test_among_restricts_the_choice(self) -> None:
|
|
self.assertEqual(
|
|
timings.fastest(self._GROUPED, "mode", among=("swarm",)), "swarm"
|
|
)
|
|
|
|
def test_nothing_measured_enough_returns_none(self) -> None:
|
|
self.assertIsNone(
|
|
timings.fastest(self._GROUPED, "mode", minimum=99),
|
|
"None tells the caller to leave the axis to the rotation",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|