Skip to content

Commit ef86fea

Browse files
committed
tests: topotests/ospf_yang_startup_config: verify startup config-file batching
Add a single-router topology that exercises the daemon-direct startup config-file batching path added by lib: batch direct-daemon config-file loads into one NB transaction The ospfd fixture places area 0.0.0.61 default-cost 31 area 0.0.0.61 stub no-summary with default-cost *before* the stub-area line. With per-line commit the first line fails RFC 9129's "default-cost is valid only on stub/NSSA areas" when clause and the daemon never reaches the stub-area line. Only the batched path, where the whole file commits in one northbound transaction, lets the two leaves validate against each other and both end up in the committed running configuration. The ospf6d fixture carries a matching stub area without default-cost (v3 has no default-cost surface) so the v3 startup-batching code path is exercised too. The test asserts both stub-area lines are present in show running-config after the topology has started. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
1 parent bc19a2b commit ef86fea

5 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
!
2+
router ospf6
3+
ospf6 router-id 10.0.255.1
4+
area 0.0.0.62 stub no-summary
5+
!
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
!
2+
router ospf
3+
ospf router-id 10.0.255.1
4+
area 0.0.0.61 default-cost 31
5+
area 0.0.0.61 stub no-summary
6+
!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
# SPDX-License-Identifier: ISC
3+
4+
"""
5+
test_ospf_yang_startup_config.py: Test OSPF YANG startup config batching.
6+
"""
7+
8+
import os
9+
import sys
10+
11+
import pytest
12+
13+
CWD = os.path.dirname(os.path.realpath(__file__))
14+
sys.path.append(os.path.join(CWD, "../"))
15+
16+
# pylint: disable=C0413
17+
from lib.topogen import Topogen, TopoRouter, get_topogen
18+
19+
pytestmark = [pytest.mark.ospfd, pytest.mark.ospf6d]
20+
21+
22+
def build_topo(tgen):
23+
"Build a single-router topology for startup config parsing."
24+
tgen.add_router("r1")
25+
26+
27+
def setup_module(mod):
28+
"Sets up the pytest environment."
29+
tgen = Topogen(build_topo, mod.__name__)
30+
tgen.start_topology()
31+
32+
r1 = tgen.gears["r1"]
33+
r1.load_config(TopoRouter.RD_ZEBRA, os.path.join(CWD, "r1/zebra.conf"))
34+
r1.load_config(TopoRouter.RD_OSPF, os.path.join(CWD, "r1/ospfd.conf"))
35+
r1.load_config(TopoRouter.RD_OSPF6, os.path.join(CWD, "r1/ospf6d.conf"))
36+
37+
tgen.start_router()
38+
39+
40+
def teardown_module():
41+
"Teardown the pytest environment."
42+
tgen = get_topogen()
43+
tgen.stop_topology()
44+
45+
46+
def test_ospf_yang_startup_config_file_batching():
47+
"Verify direct daemon startup config loads commit cross-leaf OSPF changes."
48+
tgen = get_topogen()
49+
if tgen.routers_have_failure():
50+
pytest.skip("skipped because of router(s) failure")
51+
52+
r1 = tgen.gears["r1"]
53+
54+
running = r1.vtysh_cmd("show running-config ospfd")
55+
assert "area 0.0.0.61 stub no-summary" in running, running
56+
assert "area 0.0.0.61 default-cost 31" in running, running
57+
58+
running = r1.vtysh_cmd("show running-config ospf6d")
59+
assert "area 0.0.0.62 stub no-summary" in running, running

0 commit comments

Comments
 (0)