Skip to content

Commit 5f30a86

Browse files
committed
Add orchestrator wiring tests for control-plane ACLs
Patch _add_ctrlplane_acls in the orchestrator helper fixture like the other section helpers, so the orchestrator glue stays exercised in isolation, and pin the wiring for #2330: the helper runs exactly once with the OOB IP and prefix when one exists, and is not invoked when the device has no OOB IP — in which case the owned ACL_TABLE and ACL_RULE tables stay absent even if the base config carried stale entries. AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
1 parent 92a2a14 commit 5f30a86

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

tests/unit/tasks/conductor/sonic/test_config_generator_orchestrator.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def patch(name, **kw):
9595
_add_loopback_configuration=patch("_add_loopback_configuration"),
9696
_add_log_server_configuration=patch("_add_log_server_configuration"),
9797
_add_snmp_configuration=patch("_add_snmp_configuration"),
98+
_add_ctrlplane_acls=patch("_add_ctrlplane_acls"),
9899
_add_vrf_configuration=patch("_add_vrf_configuration"),
99100
_add_portchannel_configuration=patch("_add_portchannel_configuration"),
100101
get_cached_device_interfaces=patch(
@@ -395,6 +396,43 @@ def test_generate_sonic_config_no_oob_ip_leaves_mgmt_empty_and_passes_none(
395396
assert snmp_oob is None
396397

397398

399+
def test_generate_sonic_config_oob_ip_wires_ctrlplane_acls(
400+
mocker, patch_orchestrator_helpers, make_orchestrator_device
401+
):
402+
"""With an OOB IP the orchestrator delegates the control-plane ACLs
403+
(#2330) to ``_add_ctrlplane_acls`` with the raw OOB IP and prefix —
404+
network normalisation is the helper's job."""
405+
patch_base_config(mocker)
406+
patch_orchestrator_helpers.get_device_oob_ip.return_value = ("10.42.0.5", 24)
407+
device = make_orchestrator_device()
408+
409+
config = generate_sonic_config(device, "HWSKU")
410+
411+
patch_orchestrator_helpers._add_ctrlplane_acls.assert_called_once_with(
412+
config, "10.42.0.5", 24
413+
)
414+
415+
416+
def test_generate_sonic_config_no_oob_ip_skips_ctrlplane_acls(
417+
mocker, patch_orchestrator_helpers, make_orchestrator_device
418+
):
419+
"""Without an OOB IP no control-plane ACLs are wired and the owned
420+
ACL_TABLE / ACL_RULE tables stay absent — stale base-config content is
421+
removed by the up-front owned-table drop, not re-created."""
422+
base = make_base_config()
423+
base["ACL_TABLE"] = {"SNMP_ONLY": {"type": "CTRLPLANE"}}
424+
base["ACL_RULE"] = {"SNMP_ONLY|RULE_1": {"PRIORITY": "9999"}}
425+
patch_base_config(mocker, base_config=base)
426+
patch_orchestrator_helpers.get_device_oob_ip.return_value = None
427+
device = make_orchestrator_device()
428+
429+
config = generate_sonic_config(device, "HWSKU")
430+
431+
patch_orchestrator_helpers._add_ctrlplane_acls.assert_not_called()
432+
assert "ACL_TABLE" not in config
433+
assert "ACL_RULE" not in config
434+
435+
398436
# ---------------------------------------------------------------------------
399437
# generate_sonic_config — breakout merge
400438
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)