]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/example_test/test_template_json.py
doc: Add `show ipv6 rpf X:X::X:X` command to docs
[mirror_frr.git] / tests / topotests / example_test / test_template_json.py
1 #!/usr/bin/env python3
2 #
3 # September 5 2021, Christian Hopps <chopps@labn.net>
4 #
5 # Copyright (c) 2021, LabN Consulting, L.L.C.
6 # Copyright (c) 2017 by
7 # Network Device Education Foundation, Inc. ("NetDEF")
8 #
9 # Permission to use, copy, modify, and/or distribute this software
10 # for any purpose with or without fee is hereby granted, provided
11 # that the above copyright notice and this permission notice appear
12 # in all copies.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
15 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
17 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
18 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
20 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
21 # OF THIS SOFTWARE.
22 #
23
24 """
25 <template>.py: Test <template>.
26 """
27
28 import pytest
29
30 # Import topogen and topotest helpers
31 from lib import bgp
32 from lib import fixtures
33
34
35 # TODO: select markers based on daemons used during test
36 pytestmark = [
37 pytest.mark.bgpd,
38 # pytest.mark.ospfd,
39 # pytest.mark.ospf6d
40 # ...
41 ]
42
43 # Use tgen_json fixture (invoked by use test arg of same name) to
44 # setup/teardown standard JSON topotest
45 tgen = pytest.fixture(fixtures.tgen_json, scope="module")
46
47
48 # tgen is defined above
49 # topo is a fixture defined in ../conftest.py
50 def test_bgp_convergence(tgen, topo):
51 "Test for BGP convergence."
52
53 # Don't run this test if we have any failure.
54 if tgen.routers_have_failure():
55 pytest.skip(tgen.errors)
56
57 bgp_convergence = bgp.verify_bgp_convergence(tgen, topo)
58 assert bgp_convergence
59
60
61 # Memory leak test template
62 def test_memory_leak(tgen):
63 "Run the memory leak test and report results."
64
65 if not tgen.is_memleak_enabled():
66 pytest.skip("Memory leak test/report is disabled")
67
68 tgen.report_memory_leaks()