mirror of
https://github.com/hansjone/netx.git
synced 2026-10-10 18:10:45 +08:00
Ship IOH CN migration as ZTE status default; push filters and percent into SQL compare.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
85e5f95838
commit
3d92a74fac
5 changed files with 1374 additions and 99 deletions
|
|
@ -455,21 +455,31 @@ class CompareSheetDefaultsTests(unittest.TestCase):
|
|||
self.assertIn("isis_adjacency.ipv6", ids)
|
||||
# Same source metric may appear multiple times (afi splits)
|
||||
self.assertEqual(sum(1 for s in sheets if s["metric_id"] == "bgp_peer"), 6)
|
||||
self.assertGreaterEqual(sum(1 for s in sheets if s["metric_id"] == "bgp_route"), 4)
|
||||
self.assertIn("bgp_peer.evpn", ids)
|
||||
self.assertIn("bgp_peer.vpls", ids)
|
||||
self.assertIn("vrrp.ipv4", ids)
|
||||
self.assertIn("lldp_neighbor", ids)
|
||||
detail = next(s for s in sheets if sheet_key(s) == "interface_detail")
|
||||
self.assertEqual(detail["compare_fields"], ["port_status"])
|
||||
self.assertIn("input_bps", detail["display_fields"])
|
||||
optical = next(s for s in sheets if sheet_key(s) == "optical_brief")
|
||||
self.assertEqual(optical["compare_fields"], ["status"])
|
||||
self.assertIn("rx_power", optical["display_fields"])
|
||||
bgp4 = next(s for s in sheets if sheet_key(s) == "bgp_peer.ipv4")
|
||||
self.assertEqual(bgp4["compare_fields"], ["as_num", "state"])
|
||||
self.assertIn("pfx_rcd", bgp4["display_fields"])
|
||||
# Packaged IOH default: filtered bgp_route ipv4 + percent pfx_rcd
|
||||
route4 = next(s for s in sheets if sheet_key(s) == "bgp_route")
|
||||
self.assertEqual(route4["metric_id"], "bgp_route")
|
||||
self.assertTrue(
|
||||
any(
|
||||
f.get("field") == "afi" and f.get("value") == "ipv4"
|
||||
for f in (route4.get("row_filters") or [])
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
any(
|
||||
r.get("field") == "pfx_rcd" and r.get("compare") == "percent"
|
||||
for r in (route4.get("field_rules") or [])
|
||||
)
|
||||
)
|
||||
vpnv4 = next(s for s in sheets if sheet_key(s) == "bgp_peer.vpnv4")
|
||||
self.assertEqual(vpnv4["row_filters"], [{"field": "afi", "op": "eq", "value": "vpnv4"}])
|
||||
self.assertEqual(
|
||||
vpnv4["row_filters"],
|
||||
[{"field": "afi", "op": "eq", "value": "vpnv4"}],
|
||||
)
|
||||
isis4 = next(s for s in sheets if sheet_key(s) == "isis_adjacency.ipv4")
|
||||
self.assertEqual(isis4["row_filters"][0]["op"], "contains")
|
||||
|
||||
|
|
|
|||
|
|
@ -112,13 +112,18 @@ class CompareSqlGateTests(unittest.TestCase):
|
|||
"network",
|
||||
"next_hop",
|
||||
],
|
||||
"compare_fields": ["path", "as_num"],
|
||||
"compare_fields": ["path", "as_num", "pfx_rcd"],
|
||||
"iface_fields": [],
|
||||
"field_rules": [],
|
||||
"row_filters": [{"field": "afi", "op": "eq", "value": "ipv4"}],
|
||||
"field_rules": [
|
||||
{"field": "pfx_rcd", "compare": "percent", "tolerance": 5},
|
||||
],
|
||||
"row_filters": [
|
||||
{"field": "vrf", "op": "empty"},
|
||||
{"field": "afi", "op": "eq", "value": "ipv4"},
|
||||
],
|
||||
}
|
||||
self.assertTrue(can_sql_compare(_db(), sheet, port_map={}))
|
||||
# BGP afi/vrf sheet splits via row_filters must not force Python
|
||||
# BGP afi/vrf sheet splits + percent rules must not force Python
|
||||
self.assertEqual(sql_compare_skip_reason(_db(), sheet, port_map={}), "")
|
||||
|
||||
def test_rejects_iface_normalize_when_key_uses_iface(self) -> None:
|
||||
|
|
@ -204,11 +209,16 @@ class CompareSqlFilterCompileTests(unittest.TestCase):
|
|||
def test_field_rules_matrix(self) -> None:
|
||||
self.assertTrue(_field_rules_sql_compatible([{"field": "mac", "normalize": "lower"}]))
|
||||
self.assertFalse(_field_rules_sql_compatible([{"field": "mac", "normalize": "mac"}]))
|
||||
self.assertFalse(
|
||||
self.assertTrue(
|
||||
_field_rules_sql_compatible(
|
||||
[{"field": "rx", "compare": "numeric", "tolerance": 1}]
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
_field_rules_sql_compatible(
|
||||
[{"field": "pfx_rcd", "compare": "percent", "tolerance": 5}]
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
_field_rules_sql_compatible([{"field": "x", "compare": "ignore"}])
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue