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
@@ -63,5 +63,22 @@ destinations:
|
||||
finally:
|
||||
env_file.unlink()
|
||||
|
||||
def test_load_config_sort_defaults(self):
|
||||
content = """
|
||||
defaults:
|
||||
sort_by: "ip"
|
||||
sort_reverse: true
|
||||
"""
|
||||
with NamedTemporaryFile("w+", suffix=".yaml", delete=False) as f:
|
||||
f.write(content)
|
||||
cfg_path = Path(f.name)
|
||||
|
||||
try:
|
||||
config = ConfigLoader.load(cfg_path)
|
||||
self.assertEqual(config.sort_by, "ip")
|
||||
self.assertTrue(config.sort_reverse)
|
||||
finally:
|
||||
cfg_path.unlink()
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -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()
|
||||
@@ -33,13 +33,13 @@ class TestPackaging(unittest.TestCase):
|
||||
|
||||
def test_get_version(self):
|
||||
version = get_version(self.source_root)
|
||||
self.assertEqual(version, "1.1.1")
|
||||
self.assertEqual(version, "1.1.2")
|
||||
|
||||
def test_build_tarball(self):
|
||||
builder = PackageBuilder(
|
||||
source_root=self.source_root,
|
||||
output_dir=self.output_dir,
|
||||
version="1.1.1",
|
||||
version="1.1.2",
|
||||
)
|
||||
tar_path = builder.build_tarball()
|
||||
self.assertTrue(tar_path.exists())
|
||||
@@ -48,16 +48,16 @@ class TestPackaging(unittest.TestCase):
|
||||
# Verify tar contents
|
||||
with tarfile.open(str(tar_path), "r:gz") as tar:
|
||||
names = tar.getnames()
|
||||
self.assertIn("inventory-collector-1.1.1/bin/inventory-collector", names)
|
||||
self.assertIn("inventory-collector-1.1.1/inventory_collector/__init__.py", names)
|
||||
self.assertIn("inventory-collector-1.1.1/install.sh", names)
|
||||
self.assertIn("inventory-collector-1.1.1/packaging/install.sh", names)
|
||||
self.assertIn("inventory-collector-1.1.2/bin/inventory-collector", names)
|
||||
self.assertIn("inventory-collector-1.1.2/inventory_collector/__init__.py", names)
|
||||
self.assertIn("inventory-collector-1.1.2/install.sh", names)
|
||||
self.assertIn("inventory-collector-1.1.2/packaging/install.sh", names)
|
||||
|
||||
def test_build_deb(self):
|
||||
builder = PackageBuilder(
|
||||
source_root=self.source_root,
|
||||
output_dir=self.output_dir,
|
||||
version="1.1.1",
|
||||
version="1.1.2",
|
||||
)
|
||||
deb_path = builder.build_deb()
|
||||
self.assertTrue(deb_path.exists())
|
||||
|
||||
Reference in new issue
Block a user