Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add test for northbound ordering fix #1

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/topotests/mgmt_config/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,23 @@ def test_regression_issue_13920(tgen):
)
output = r1.net.checkRouterCores()
assert not output.strip()


def test_regression_pullreq_15423(tgen):
r1 = tgen.gears["r1"]
r1.vtysh_multicmd(
"""
conf t
access-list test seq 1 permit ip any 10.10.10.0 0.0.0.255
"""
)

output = r1.vtysh_multicmd(
"""
conf terminal file-lock
mgmt delete-config /frr-filter:lib/access-list[name='test'][type='ipv4']/entry[sequence='1']/destination-network
mgmt commit apply
end
"""
)
assert "No changes found" not in output
6 changes: 6 additions & 0 deletions tests/topotests/nb_config/r1/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
log timestamp precision 6
log file frr.log

interface r1-eth0
ip address 1.1.1.1/24
exit
69 changes: 69 additions & 0 deletions tests/topotests/nb_config/test_nb_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -*- coding: utf-8 eval: (blacken-mode 1) -*-
# SPDX-License-Identifier: ISC
#
# February 24 2024, Christian Hopps <[email protected]>
#
# Copyright (c) 2024, LabN Consulting, L.L.C.
#
"""
Test Northbound Config Operations
"""
import json
import os

import pytest
from lib.topogen import Topogen
from lib.topotest import json_cmp

pytestmark = [pytest.mark.mgmtd]

CWD = os.path.dirname(os.path.realpath(__file__))


@pytest.fixture(scope="module")
def tgen(request):
"Setup/Teardown the environment and provide tgen argument to tests"

topodef = {
"s1": ("r1",)
}

tgen = Topogen(topodef, request.module.__name__)
tgen.start_topology()

router_list = tgen.routers()
for rname, router in router_list.items():
router.load_frr_config("frr.conf")

tgen.start_router()
yield tgen
tgen.stop_topology()


def test_access_list_config_ordering(tgen):
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

r1 = tgen.gears["r1"]

output = r1.vtysh_multicmd([
"conf t",
"access-list test seq 1 permit host 10.0.0.1"])
output = r1.vtysh_cmd("show ip access-list test json")
got = json.loads(output)
expected = json.loads('{"ZEBRA":{"test":{"type":"Standard", "addressFamily":"IPv4", "rules":[{"sequenceNumber":1, "filterType":"permit", "address":"10.0.0.1", "mask":"0.0.0."}]}}}')
result = json_cmp(got, expected)
assert result is None

#
# If the northbound mis-orders the create/delete then this test fails.
# https://github.com/FRRouting/frr/pull/15423/commits/38b85e0c2bc555b8827dbd2cb6515b6febf548b4
#
output = r1.vtysh_multicmd([
"conf t",
"access-list test seq 1 permit 10.0.0.0/8"])
output = r1.vtysh_cmd("show ip access-list test json")
got = json.loads(output)
expected = json.loads('{"ZEBRA":{"test":{"type":"Zebra", "addressFamily":"IPv4", "rules":[{"sequenceNumber":1, "filterType":"permit", "prefix":"10.0.0.0/8", "exact-match":false}]}}}')
result = json_cmp(got, expected)
assert result is None