feat: release v1.1.2 - hardened IP sorting with ipaddress and config sort defaults
Build and Publish Release / Build Packages and Publish (push) Successful in 10s
Build and Publish Release / Build Packages and Publish (push) Successful in 10s
This commit is contained in:
1 parent
62710d8bb7
commit
1dbbb1ce56
12 files changed
+88
-21
No files matched your search
@@ -100,5 +100,30 @@ class TestDeduplicationEngine(unittest.TestCase):
|
||||
rev_inv = inv.sort(sort_by="ip", reverse=True)
|
||||
self.assertEqual(list(rev_inv.hosts.keys()), ["host-no-ip", "host-101", "host-20", "host-2"])
|
||||
|
||||
def test_inventory_sort_by_ip_robustness(self):
|
||||
from inventory_collector.models import InventoryData
|
||||
inv = InventoryData()
|
||||
inv.add_host(HostRecord(name="node0", ansible_host="192.168.0.101"))
|
||||
inv.add_host(HostRecord(name="node0-cidr", ansible_host="192.168.0.2/24"))
|
||||
inv.add_host(HostRecord(name="node0-port", ansible_host="192.168.0.101:2222"))
|
||||
inv.add_host(HostRecord(name="alma-crash", ansible_host="192.168.5.51"))
|
||||
inv.add_host(HostRecord(name="rhcsa-111", ansible_host="192.168.5.111"))
|
||||
inv.add_host(HostRecord(name="ipv6-host", ansible_host="fe80::1"))
|
||||
inv.add_host(HostRecord(name="named-host", ansible_host="nas.wired.intra"))
|
||||
inv.add_host(HostRecord(name="empty-host", ansible_host=""))
|
||||
|
||||
sorted_inv = inv.sort(sort_by="ip")
|
||||
expected_order = [
|
||||
"node0-cidr", # 192.168.0.2
|
||||
"node0", # 192.168.0.101
|
||||
"node0-port", # 192.168.0.101:2222 (tie broken by name)
|
||||
"alma-crash", # 192.168.5.51 (51 < 111)
|
||||
"rhcsa-111", # 192.168.5.111
|
||||
"ipv6-host", # fe80::1 (IPv6 after IPv4)
|
||||
"named-host", # nas.wired.intra (hostname after IP)
|
||||
"empty-host", # "" (empty IP at end)
|
||||
]
|
||||
self.assertEqual(list(sorted_inv.hosts.keys()), expected_order)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user