mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 11:18:43 +00:00
tests: Start the ability to mark tests
Add the ability for our topotests to take advantage of pytest `mark`ing. This effectively allows you to tell pytest to run against certain sets of tests. For a demonstration purpose I've added in marks for: babel eigrp ldp ospf pim rip And setup tests to run against those tests that only test those protocols. You can run against eigrp tests by running `pytest -k eigrp` Other combinations are also available based upon simple boolean logic. Just read the pytest.mark documentation. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
9fad1340d4
commit
b9f3e47f3a
@ -82,7 +82,8 @@ class NetworkTopo(Topo):
|
|||||||
##
|
##
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
@pytest.mark.ospf
|
||||||
|
@pytest.mark.rip
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
global topo, net
|
global topo, net
|
||||||
global fatal_error
|
global fatal_error
|
||||||
|
@ -362,7 +362,7 @@ def config_hosts(tgen, hosts):
|
|||||||
host = tgen.gears[host_name]
|
host = tgen.gears[host_name]
|
||||||
config_host(host_name, host)
|
config_host(host_name, host)
|
||||||
|
|
||||||
|
@pytest.mark.pim
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
"Setup topology"
|
"Setup topology"
|
||||||
tgen = Topogen(NetworkTopo, module.__name__)
|
tgen = Topogen(NetworkTopo, module.__name__)
|
||||||
|
@ -91,7 +91,7 @@ class NetworkTopo(Topo):
|
|||||||
##
|
##
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
@pytest.mark.eigrp
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
"Setup topology"
|
"Setup topology"
|
||||||
tgen = Topogen(NetworkTopo, module.__name__)
|
tgen = Topogen(NetworkTopo, module.__name__)
|
||||||
|
@ -97,7 +97,7 @@ class NetworkTopo(Topo):
|
|||||||
##
|
##
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
@pytest.mark.pim
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
"Setup topology"
|
"Setup topology"
|
||||||
tgen = Topogen(NetworkTopo, module.__name__)
|
tgen = Topogen(NetworkTopo, module.__name__)
|
||||||
|
@ -159,7 +159,7 @@ class NetworkTopo(Topo):
|
|||||||
##
|
##
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
@pytest.mark.ldp
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
global topo, net
|
global topo, net
|
||||||
global fatal_error
|
global fatal_error
|
||||||
|
@ -121,7 +121,8 @@ class TemplateTopo(Topo):
|
|||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
|
@pytest.mark.ldp
|
||||||
|
@pytest.mark.ospf
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
"Sets up the pytest environment"
|
"Sets up the pytest environment"
|
||||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||||
|
@ -80,7 +80,7 @@ class PIMTopo(Topo):
|
|||||||
sw.add_link(tgen.gears["r1"])
|
sw.add_link(tgen.gears["r1"])
|
||||||
sw.add_link(tgen.gears["r3"])
|
sw.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
|
@pytest.mark.pim
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
"Sets up the pytest environment"
|
"Sets up the pytest environment"
|
||||||
tgen = Topogen(PIMTopo, mod.__name__)
|
tgen = Topogen(PIMTopo, mod.__name__)
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
# Skip pytests example directory
|
# Skip pytests example directory
|
||||||
[pytest]
|
[pytest]
|
||||||
norecursedirs = .git example-test example-topojson-test lib docker
|
norecursedirs = .git example-test example-topojson-test lib docker
|
||||||
|
markers =
|
||||||
|
babel: Tests that run against BABEL
|
||||||
|
eigrp: Tests that run against EIGRPD
|
||||||
|
ldp: Tests that run against LDPD
|
||||||
|
ospf: Tests that run against OSPF( v2 and v3 )
|
||||||
|
pim: Tests that run against pim
|
||||||
|
rip: Tests that run against RIP, both v4 and v6
|
||||||
|
|
||||||
[topogen]
|
[topogen]
|
||||||
# Default configuration values
|
# Default configuration values
|
||||||
|
@ -104,7 +104,7 @@ class NetworkTopo(Topo):
|
|||||||
##
|
##
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
@pytest.mark.rip
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
global topo, net
|
global topo, net
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class NetworkTopo(Topo):
|
|||||||
##
|
##
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
@pytest.mark.rip
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
global topo, net
|
global topo, net
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user