]> git.proxmox.com Git - mirror_frr.git/blame - tests/topotests/mgmt_startup/test_config.py
tests: add unified config tests
[mirror_frr.git] / tests / topotests / mgmt_startup / test_config.py
CommitLineData
e3c4bd24
CH
1# -*- coding: utf-8 eval: (blacken-mode 1) -*-
2# SPDX-License-Identifier: ISC
3#
4# May 2 2023, Christian Hopps <chopps@labn.net>
5#
6# Copyright (c) 2023, LabN Consulting, L.L.C.
7#
8"""
9Test static route functionality using old or new configuration files.
10
11User compat:
12
13 - mgmtd split config will first look to `/etc/frr/zebra.conf`
14 then `/etc/frr/staticd.conf` and finally `/etc/frr/mgmtd.conf`
15
16 - When new components are converted to mgmtd their split config should be
17 added here too.
18
19Topotest compat:
20
21 - `mgmtd.conf` is copied to `/etc/frr/` for use by mgmtd when implicit load,
22 or explicit load no config specified.
23
24 - `staticd.conf` is copied to `/etc/frr/` for use by mgmtd when staticd
25 is explicit load implict config, and explicit config.
26
27"""
28
e3c4bd24 29import pytest
7cd87abc 30from lib.common_config import step
e3c4bd24 31from lib.topogen import Topogen, TopoRouter
7cd87abc 32from util import check_kernel
e3c4bd24
CH
33
34# pytestmark = [pytest.mark.staticd, pytest.mark.mgmtd]
35pytestmark = [pytest.mark.staticd]
36
37
38@pytest.fixture(scope="module")
39def tgen(request):
40 "Setup/Teardown the environment and provide tgen argument to tests"
41
42 topodef = {
7cd87abc 43 "s1": ("r1", "r2", "r3", "r4"),
e3c4bd24
CH
44 }
45
46 tgen = Topogen(topodef, request.module.__name__)
47 tgen.start_topology()
48
49 # configure mgmtd using current mgmtd config file
50 tgen.gears["r1"].load_config(TopoRouter.RD_ZEBRA, "zebra.conf")
51 tgen.gears["r1"].load_config(TopoRouter.RD_MGMTD, "mgmtd.conf")
52
53 # user/topotest compat:
54 # configure mgmtd using old staticd config file, with explicity staticd
55 # load.
56 tgen.gears["r2"].load_config(TopoRouter.RD_ZEBRA, "zebra.conf")
57 tgen.gears["r2"].load_config(TopoRouter.RD_STATIC, "staticd.conf")
58
59 # user compat:
60 # configure mgmtd using backup config file `zebra.conf`
61 tgen.gears["r3"].load_config(TopoRouter.RD_ZEBRA, "zebra.conf")
62
7cd87abc
CH
63 # configure mgmtd using current mgmtd config file
64 tgen.gears["r4"].load_frr_config("frr.conf")
65
e3c4bd24
CH
66 tgen.start_router()
67 yield tgen
68 tgen.stop_topology()
69
70
7cd87abc 71def test_staticd_routes_present(tgen):
e3c4bd24
CH
72 if tgen.routers_have_failure():
73 pytest.skip(tgen.errors)
74
7cd87abc 75 for x in ["r1", "r2", "r3", "r4"]:
e3c4bd24
CH
76 tgen.gears[x].net.cmd_nostatus(
77 "vtysh -c 'debug mgmt client frontend' "
78 "-c 'debug mgmt client backend' "
79 "-c 'debug mgmt backend frontend datastore transaction'"
80 )
81
82 r1 = tgen.routers()["r1"]
83 r2 = tgen.routers()["r2"]
84 r3 = tgen.routers()["r3"]
7cd87abc 85 r4 = tgen.routers()["r4"]
e3c4bd24
CH
86
87 step("Verifying routes are present on r1")
88 result = check_kernel(r1, "12.0.0.0/24")
89 assert result is None
90 result = check_kernel(r1, "13.0.0.0/24")
91 assert result is None
92
93 step("Verifying routes are present on r2")
94 result = check_kernel(r2, "11.0.0.0/24")
95 assert result is None
96 result = check_kernel(r2, "13.0.0.0/24")
97 assert result is None
98
99 step("Verifying routes are present on r3")
100 result = check_kernel(r3, "11.0.0.0/24")
101 assert result is None
102 result = check_kernel(r3, "12.0.0.0/24")
103 assert result is None
7cd87abc
CH
104
105 step("Verifying routes are present on r4")
106 result = check_kernel(r4, "11.0.0.0/24")
107 assert result is None
108 result = check_kernel(r4, "12.0.0.0/24")
109 assert result is None