39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
from pathlib import Path
|
|
import re
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).parents[1]
|
|
|
|
|
|
class SysctlRoleContract(unittest.TestCase):
|
|
def test_canonical_streaming_profile_keeps_64mib_and_bbr_fq(self):
|
|
text = (ROOT / "roles/sysctl/defaults/main.yml").read_text()
|
|
self.assertIn("net.core.rmem_max", text)
|
|
self.assertIn('value: "67108864"', text)
|
|
self.assertIn("net.core.default_qdisc", text)
|
|
self.assertIn("net.ipv4.tcp_congestion_control", text)
|
|
self.assertIn("net.ipv4.tcp_no_metrics_save", text)
|
|
|
|
def test_role_removes_managed_keys_from_legacy_sources(self):
|
|
text = (ROOT / "roles/sysctl/tasks/main.yml").read_text()
|
|
self.assertIn("/etc/sysctl.conf", text)
|
|
self.assertIn("/etc/sysctl.d/99-streaming.conf", text)
|
|
self.assertIn("/etc/sysctl.d/99-proxmox-tuning.conf", text)
|
|
self.assertIn("/etc/sysctl.d/99-zzz-cloudflare-warp-connector.conf", text)
|
|
self.assertIn("state: absent", text)
|
|
self.assertIn("regex_escape", text)
|
|
|
|
def test_proxmox_tuning_runs_canonical_network_role_first(self):
|
|
play = (ROOT / "sysctl-proxmox.yaml").read_text()
|
|
self.assertLess(play.index("- sysctl\n"), play.index("- sysctl_proxmox"))
|
|
|
|
def test_proxmox_role_does_not_duplicate_canonical_network_keys(self):
|
|
canonical = (ROOT / "roles/sysctl/defaults/main.yml").read_text()
|
|
proxmox = (ROOT / "roles/sysctl_proxmox/tasks/main.yml").read_text()
|
|
canonical_keys = set(re.findall(r"key:\s*([a-z0-9_.-]+)", canonical))
|
|
proxmox_keys = set(re.findall(r"key:\s*([a-z0-9_.-]+)", proxmox))
|
|
self.assertEqual(canonical_keys & proxmox_keys, set())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|