From d97b16e9f144141c4356086b5d458e348d02f2f0 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 6 May 2026 19:38:21 +0200 Subject: [PATCH] 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 --category --count 1` - subnets: `infinito meta networks suggest --clients --count 1` Plus a hint that an exhausted `PORT_BANDS..` 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) --- .../networks/test_unique_valid_and_mapped.py | 16 ++++++++++++++-- tests/lint/repository/test_role_meta_layout.py | 10 ++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/integration/networks/test_unique_valid_and_mapped.py b/tests/integration/networks/test_unique_valid_and_mapped.py index df16cb517e..2a9085b9af 100644 --- a/tests/integration/networks/test_unique_valid_and_mapped.py +++ b/tests/integration/networks/test_unique_valid_and_mapped.py @@ -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 --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 --count 1` " + + "and update the role's meta/server.yml.networks.local.subnet." + ) if __name__ == "__main__": diff --git a/tests/lint/repository/test_role_meta_layout.py b/tests/lint/repository/test_role_meta_layout.py index 45b0141d3f..052f4f15d1 100644 --- a/tests/lint/repository/test_role_meta_layout.py +++ b/tests/lint/repository/test_role_meta_layout.py @@ -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 " + + "--category --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 " + + "--category --count 1`. " + + "If the band itself is exhausted, extend " + + "`PORT_BANDS...end` in " + + "group_vars/all/08_networks.yml." )