]>
Commit | Line | Data |
---|---|---|
7cd87abc 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 | ||
9 | """ | |
10 | Verify large set of routes present when staticd (backend client) is started after it's | |
11 | startup config is present during launch. | |
12 | """ | |
13 | ||
14 | import logging | |
15 | import os | |
16 | ||
17 | import pytest | |
18 | from lib.common_config import step | |
19 | from lib.topogen import Topogen, TopoRouter | |
20 | from munet.base import Timeout | |
21 | from util import check_kernel, check_vtysh_up, write_big_route_conf | |
22 | ||
23 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
24 | ||
25 | # pytestmark = [pytest.mark.staticd, pytest.mark.mgmtd] | |
26 | pytestmark = [pytest.mark.staticd] | |
27 | ||
28 | track = Timeout(0) | |
29 | ROUTE_COUNT = 2500 | |
30 | ROUTE_RANGE = [None, None] | |
31 | ||
32 | ||
33 | @pytest.fixture(scope="module") | |
34 | def tgen(request): | |
35 | "Setup/Teardown the environment and provide tgen argument to tests" | |
36 | ||
37 | global start_time | |
38 | topodef = { | |
39 | "s1": ("r1",), | |
40 | } | |
41 | ||
42 | tgen = Topogen(topodef, request.module.__name__) | |
43 | tgen.start_topology() | |
44 | ||
45 | confpath = f"{tgen.gears['r1'].gearlogdir}/r1-late-big.conf" | |
46 | start, end = write_big_route_conf("10.0.0.0/8", ROUTE_COUNT, confpath) | |
47 | ROUTE_RANGE[0] = start | |
48 | ROUTE_RANGE[1] = end | |
49 | ||
50 | # configure mgmtd using current mgmtd config file | |
51 | tgen.gears["r1"].load_config(TopoRouter.RD_ZEBRA, "zebra.conf") | |
52 | tgen.gears["r1"].load_config(TopoRouter.RD_MGMTD, confpath) | |
53 | ||
54 | # Explicit disable staticd now.. | |
55 | tgen.gears["r1"].net.daemons["staticd"] = 0 | |
56 | ||
57 | tgen.start_router() | |
58 | yield tgen | |
59 | tgen.stop_topology() | |
60 | ||
61 | ||
62 | def test_staticd_latestart(tgen): | |
63 | if tgen.routers_have_failure(): | |
64 | pytest.skip(tgen.errors) | |
65 | ||
66 | r1 = tgen.routers()["r1"] | |
67 | ||
68 | check_vtysh_up(r1) | |
69 | logging.info("r1: vtysh connected after %ss", track.elapsed()) | |
70 | ||
71 | result = check_kernel(r1, ROUTE_RANGE[0], retry_timeout=20, expected=False) | |
72 | assert result is not None, "first route present and should not be" | |
73 | result = check_kernel(r1, ROUTE_RANGE[1], retry_timeout=20, expected=False) | |
74 | assert result is not None, "last route present and should not be" | |
75 | ||
76 | step("Starting staticd") | |
77 | r1.startDaemons(["staticd"]) | |
78 | ||
79 | result = check_kernel(r1, ROUTE_RANGE[0], retry_timeout=60) | |
80 | assert result is None, "first route not present and should be" | |
81 | result = check_kernel(r1, ROUTE_RANGE[1], retry_timeout=20) | |
82 | assert result is None, "last route not present and should be" |