mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-11 13:17:07 +00:00
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>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
import unittest
|
|
|
|
from utils.preflight.host import disk_usage_errors
|
|
|
|
HEADER = "Filesystem 1024-blocks Used Available Capacity Mounted on"
|
|
|
|
|
|
def _df(*rows):
|
|
return "\n".join([HEADER, *rows]) + "\n"
|
|
|
|
|
|
class TestDiskUsageErrors(unittest.TestCase):
|
|
def test_filesystems_at_or_below_the_limit_pass(self):
|
|
output = _df(
|
|
"/dev/sda1 100 90 10 90% /",
|
|
"/dev/sdb1 100 12 88 12% /var/lib/docker",
|
|
)
|
|
self.assertEqual(
|
|
disk_usage_errors(["/", "/var/lib/docker"], output, 90),
|
|
[],
|
|
)
|
|
|
|
def test_a_filesystem_above_the_limit_names_path_mount_and_usage(self):
|
|
output = _df(
|
|
"/dev/sda1 100 50 50 50% /",
|
|
"/dev/sda1 100 91 9 91% /srv/docker data",
|
|
)
|
|
self.assertEqual(
|
|
disk_usage_errors(["/", "/srv/docker data/root"], output, 90),
|
|
[
|
|
"/srv/docker data/root lies on /srv/docker data, which is 91 % full (limit 90 %)"
|
|
],
|
|
)
|
|
|
|
def test_every_full_path_is_reported(self):
|
|
output = _df(
|
|
"overlay 100 95 5 95% /",
|
|
"overlay 100 95 5 95% /",
|
|
)
|
|
self.assertEqual(
|
|
len(disk_usage_errors(["/", "/var/lib/docker"], output, 90)), 2
|
|
)
|
|
|
|
def test_a_row_count_mismatch_is_rejected(self):
|
|
with self.assertRaises(ValueError):
|
|
disk_usage_errors(
|
|
["/", "/var/lib/docker"], _df("/dev/sda1 1 1 0 99% /"), 90
|
|
)
|
|
|
|
def test_a_row_without_a_percentage_is_rejected(self):
|
|
with self.assertRaises(ValueError):
|
|
disk_usage_errors(["/"], _df("/dev/sda1 1 1 0 - /"), 90)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|