mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-06 01:40:19 +00:00
test(lint): add CLI suggest hint to port and subnet collision failures
When `test_role_meta_layout.TestHostBoundPortCollisions`, `TestPortBandMembership`, or `test_unique_valid_and_mapped.TestNetworksUniqueValidAndMapped` fails, surface the canonical resolver command in the failure message: - ports: `infinito meta ports suggest --scope <local|public> --category <http|oauth2|...> --count 1` - subnets: `infinito meta networks suggest --clients <N> --count 1` Plus a hint that an exhausted `PORT_BANDS.<scope>.<category>` band can be widened in `group_vars/all/08_networks.yml`. Reduces the diagnose-to-fix loop for contributors hitting these lints. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c9c8535034
commit
d97b16e9f1
2 files changed
+24
-2
No files matched your search
@@ -56,7 +56,13 @@ class TestNetworksUniqueValidAndMapped(unittest.TestCase):
|
||||
else:
|
||||
seen[net] = role
|
||||
if dupes:
|
||||
self.fail("Duplicate subnets detected:\n" + "\n".join(dupes))
|
||||
self.fail(
|
||||
"Duplicate subnets detected:\n"
|
||||
+ "\n".join(dupes)
|
||||
+ "\n\nFix: pick a free subnet via "
|
||||
+ "`infinito meta networks suggest --clients <N> --count 1` "
|
||||
+ "and update the role's meta/server.yml.networks.local.subnet."
|
||||
)
|
||||
|
||||
def test_no_overlapping_subnets(self):
|
||||
items = list(self.role_to_subnet.items())
|
||||
@@ -68,7 +74,13 @@ class TestNetworksUniqueValidAndMapped(unittest.TestCase):
|
||||
if net1.overlaps(net2):
|
||||
overlaps.append(f"'{name1}' ({net1}) overlaps '{name2}' ({net2})")
|
||||
if overlaps:
|
||||
self.fail("Subnet overlaps detected:\n" + "\n".join(overlaps))
|
||||
self.fail(
|
||||
"Subnet overlaps detected:\n"
|
||||
+ "\n".join(overlaps)
|
||||
+ "\n\nFix: pick a free subnet via "
|
||||
+ "`infinito meta networks suggest --clients <N> --count 1` "
|
||||
+ "and update the role's meta/server.yml.networks.local.subnet."
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -272,6 +272,10 @@ class TestHostBoundPortCollisions(unittest.TestCase):
|
||||
self.fail(
|
||||
"Host-bound port collisions detected (req-009):\n"
|
||||
+ "\n".join(f" - {c}" for c in clashes)
|
||||
+ "\n\nFix: pick a free port via "
|
||||
+ "`infinito meta ports suggest --scope <local|public> "
|
||||
+ "--category <http|oauth2|websocket|...> --count 1` "
|
||||
+ "and update the role's meta/services.yml."
|
||||
)
|
||||
|
||||
|
||||
@@ -324,6 +328,12 @@ class TestPortBandMembership(unittest.TestCase):
|
||||
self.fail(
|
||||
"PORT_BANDS membership / shape violation (req-009):\n"
|
||||
+ "\n".join(f" - {o}" for o in offenders)
|
||||
+ "\n\nFix: pick an in-band port via "
|
||||
+ "`infinito meta ports suggest --scope <local|public> "
|
||||
+ "--category <http|oauth2|websocket|...> --count 1`. "
|
||||
+ "If the band itself is exhausted, extend "
|
||||
+ "`PORT_BANDS.<scope>.<category>.end` in "
|
||||
+ "group_vars/all/08_networks.yml."
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user