]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env python3 | |
2 | # SPDX-License-Identifier: ISC | |
3 | # | |
4 | # September 5 2021, Christian Hopps <chopps@labn.net> | |
5 | # | |
6 | # Copyright (c) 2021, LabN Consulting, L.L.C. | |
7 | # Copyright (c) 2017 by | |
8 | # Network Device Education Foundation, Inc. ("NetDEF") | |
9 | # | |
10 | ||
11 | """ | |
12 | <template>.py: Test <template>. | |
13 | """ | |
14 | ||
15 | import pytest | |
16 | ||
17 | # Import topogen and topotest helpers | |
18 | from lib import bgp | |
19 | from lib import fixtures | |
20 | ||
21 | ||
22 | # TODO: select markers based on daemons used during test | |
23 | pytestmark = [ | |
24 | pytest.mark.bgpd, | |
25 | # pytest.mark.ospfd, | |
26 | # pytest.mark.ospf6d | |
27 | # ... | |
28 | ] | |
29 | ||
30 | # Use tgen_json fixture (invoked by use test arg of same name) to | |
31 | # setup/teardown standard JSON topotest | |
32 | tgen = pytest.fixture(fixtures.tgen_json, scope="module") | |
33 | ||
34 | ||
35 | # tgen is defined above | |
36 | # topo is a fixture defined in ../conftest.py | |
37 | def test_bgp_convergence(tgen, topo): | |
38 | "Test for BGP convergence." | |
39 | ||
40 | # Don't run this test if we have any failure. | |
41 | if tgen.routers_have_failure(): | |
42 | pytest.skip(tgen.errors) | |
43 | ||
44 | bgp_convergence = bgp.verify_bgp_convergence(tgen, topo) | |
45 | assert bgp_convergence | |
46 | ||
47 | ||
48 | # Memory leak test template | |
49 | def test_memory_leak(tgen): | |
50 | "Run the memory leak test and report results." | |
51 | ||
52 | if not tgen.is_memleak_enabled(): | |
53 | pytest.skip("Memory leak test/report is disabled") | |
54 | ||
55 | tgen.report_memory_leaks() |