Skip to content

Commit fc5717a

Browse files
committed
tests: add CLI command send log topotest
Signed-off-by: Christian Hopps <chopps@labn.net>
1 parent b852129 commit fc5717a

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
log timestamp precision 6
2+
log record-priority
3+
log file frr.log
4+
5+
ip route 11.11.11.11/32 lo
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 eval: (blacken-mode 1) -*-
2+
# SPDX-License-Identifier: ISC
3+
#
4+
# June 14 2025, Christian Hopps <chopps@labn.net>
5+
#
6+
# Copyright (c) 2025, LabN Consulting, L.L.C.
7+
#
8+
"""
9+
Test Logging Config
10+
"""
11+
import re
12+
13+
import pytest
14+
from lib.topogen import Topogen
15+
from munet.testing.util import retry
16+
from munet.watchlog import WatchLog
17+
18+
pytestmark = [pytest.mark.staticd, pytest.mark.mgmtd]
19+
20+
21+
@pytest.fixture(scope="module")
22+
def tgen(request):
23+
"Setup/Teardown the environment and provide tgen argument to tests"
24+
25+
topodef = {"s1": ("r1",)}
26+
27+
tgen = Topogen(topodef, request.module.__name__)
28+
tgen.start_topology()
29+
tgen.routers()["r1"].load_frr_config("frr.conf")
30+
31+
tgen.start_router()
32+
yield tgen
33+
tgen.stop_topology()
34+
35+
36+
@retry(retry_timeout=10)
37+
def scan_log(log, regex):
38+
log.update_content()
39+
assert re.search(regex, log.from_mark(log.last_snap_mark))
40+
41+
42+
def test_log(tgen):
43+
r1 = tgen.net.hosts["r1"]
44+
log = WatchLog(r1.rundir / "staticd.log")
45+
46+
s = "Foo Bar Baz"
47+
assert s not in log.snapshot()
48+
r1.cmd_raises(f"vtysh -c 'send log {s}'")
49+
scan_log(log, re.escape(s))
50+
51+
s = "Notice Me!"
52+
assert s not in log.snapshot()
53+
r1.cmd_raises(f"vtysh -c 'send log severity warning {s}'")
54+
scan_log(log, f"warnings:.*{re.escape(s)}")

0 commit comments

Comments
 (0)