Files
computer-playbook/tests/unit/python/utils/preflight/test_domains.py
T
kevinveenbirkenbachandClaude Opus 5.5 a67dd9b372 feat(constructor): stop a deploy in a pre-flight when the host cannot carry it
The constructor now runs tasks/utils/constructor/preflight.yml before the package install and fails with a named remedy when: the running kernel has no module index on disk or the clock is not synchronised (chrony leap status, else timedatectl, outside containers); / or the docker root is fuller than SIZE_PERCENT_MAXIMUM_DISK_USAGE (90); a docker network contradicts the entity that declares it (name, compose project label, subnet outside its block, overlap with another declared subnet); a declared container lacks or a declared volume carries a foreign entity label; a docker default address pool overlaps the mesh, Tor or a declared subnet; a host process outside docker holds a public port of the deploy; or, in assert mode, a clearnet domain of the deploy does not resolve.

A volume without any label passes, since compose adopts it and installs before this change created the Synapse volume with docker run. web-app-discourse declares its launcher-started containers through networks.local.launcher, and web-app-matrix labels a new Synapse volume with its compose project.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:38:15 +01:00

35 lines
1006 B
Python

import unittest
from utils.preflight.domains import clearnet_domains
class TestClearnetDomains(unittest.TestCase):
def test_mappings_lists_and_strings_flatten(self):
domains = [
{"canonical": ["matomo.example.org"], "api": "api.example.org"},
"example.org",
[],
]
self.assertEqual(
clearnet_domains(domains),
["api.example.org", "example.org", "matomo.example.org"],
)
def test_onion_addresses_are_left_out(self):
self.assertEqual(
clearnet_domains(["abc.onion", "x.abc.onion", "example.org"]),
["example.org"],
)
def test_case_trailing_dots_and_duplicates_collapse(self):
self.assertEqual(
clearnet_domains(["Example.org.", "example.org", " "]), ["example.org"]
)
def test_non_domain_values_are_ignored(self):
self.assertEqual(clearnet_domains([None, 5, True]), [])
if __name__ == "__main__":
unittest.main()