Merge pull request #8172 from donaldsharp/more_pytest_bgp

More pytest stuff
This commit is contained in:
Donatas Abraitis 2021-03-02 09:30:06 +02:00 committed by GitHub
commit c103ac43de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 1226 additions and 750 deletions

View File

@ -352,7 +352,7 @@ def test_converge_protocols():
actual = ( actual = (
net["r%s" % i] net["r%s" % i]
.cmd( .cmd(
'vtysh -c "show ip route" | sed -e \'/^Codes: /,/^\s*$/d\' | env LC_ALL=en_US.UTF-8 sort 2> /dev/null' "vtysh -c \"show ip route\" | sed -e '/^Codes: /,/^\s*$/d' | env LC_ALL=en_US.UTF-8 sort 2> /dev/null"
) )
.rstrip() .rstrip()
) )
@ -383,7 +383,7 @@ def test_converge_protocols():
actual = ( actual = (
net["r%s" % i] net["r%s" % i]
.cmd( .cmd(
'vtysh -c "show ipv6 route" | sed -e \'/^Codes: /,/^\s*$/d\' | env LC_ALL=en_US.UTF-8 sort 2> /dev/null' "vtysh -c \"show ipv6 route\" | sed -e '/^Codes: /,/^\s*$/d' | env LC_ALL=en_US.UTF-8 sort 2> /dev/null"
) )
.rstrip() .rstrip()
) )

View File

@ -44,7 +44,8 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd] pytestmark = [pytest.mark.bgpd, pytest.mark.bfdd]
class BFDTopo(Topo): class BFDTopo(Topo):
"Test topology builder" "Test topology builder"
@ -65,6 +66,7 @@ class BFDTopo(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"])
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
tgen = Topogen(BFDTopo, mod.__name__) tgen = Topogen(BFDTopo, mod.__name__)

View File

@ -92,6 +92,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.isisd] pytestmark = [pytest.mark.bfdd, pytest.mark.isisd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -92,6 +92,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.ospfd] pytestmark = [pytest.mark.bfdd, pytest.mark.ospfd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -45,7 +45,8 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.isisd, pytest.mark.ospfd] pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.ospfd]
class BFDProfTopo(Topo): class BFDProfTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -45,7 +45,8 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd] pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd]
class BFDTopo(Topo): class BFDTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -46,7 +46,8 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.ospfd] pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.ospfd]
class BFDTopo(Topo): class BFDTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -45,6 +45,8 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd]
class BFDTopo(Topo): class BFDTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -46,7 +46,8 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bfdd] pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd]
class BFDTopo(Topo): class BFDTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -40,6 +40,8 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger from lib.topolog import logger
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
class BgpAggregatorAsnZero(Topo): class BgpAggregatorAsnZero(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):

View File

@ -91,6 +91,9 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation # Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_basic_functionality.json".format(CWD) jsonFile = "{}/bgp_basic_functionality.json".format(CWD)
try: try:

View File

@ -324,6 +324,7 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
write_test_footer(tc_name) write_test_footer(tc_name)
@pytest.mark.parametrize("ecmp_num", ["8", "16", "32"]) @pytest.mark.parametrize("ecmp_num", ["8", "16", "32"])
@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"]) @pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
def test_ecmp_after_clear_bgp(request, ecmp_num, test_type): def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
@ -349,7 +350,7 @@ def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
addr_type, addr_type,
dut, dut,
input_dict_1, input_dict_1,
next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
protocol=protocol, protocol=protocol,
) )
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(
@ -372,7 +373,7 @@ def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
addr_type, addr_type,
dut, dut,
input_dict_1, input_dict_1,
next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
protocol=protocol, protocol=protocol,
) )
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(

View File

@ -325,6 +325,7 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
write_test_footer(tc_name) write_test_footer(tc_name)
@pytest.mark.parametrize("ecmp_num", ["8", "16", "32"]) @pytest.mark.parametrize("ecmp_num", ["8", "16", "32"])
@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"]) @pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
def test_ecmp_after_clear_bgp(request, ecmp_num, test_type): def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
@ -350,7 +351,7 @@ def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
addr_type, addr_type,
dut, dut,
input_dict_1, input_dict_1,
next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
protocol=protocol, protocol=protocol,
) )
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(
@ -373,7 +374,7 @@ def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
addr_type, addr_type,
dut, dut,
input_dict_1, input_dict_1,
next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
protocol=protocol, protocol=protocol,
) )
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(

View File

@ -603,6 +603,7 @@ def ping_anycast_gw(tgen):
local_host.run(cmd_str) local_host.run(cmd_str)
remote_host.run(cmd_str) remote_host.run(cmd_str)
def check_mac(dut, vni, mac, m_type, esi, intf, ping_gw=False, tgen=None): def check_mac(dut, vni, mac, m_type, esi, intf, ping_gw=False, tgen=None):
""" """
checks if mac is present and if desination matches the one provided checks if mac is present and if desination matches the one provided

View File

@ -47,6 +47,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -47,6 +47,8 @@ from lib.snmptest import SnmpTester
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"
@ -266,7 +268,7 @@ def test_pe1_converge_evpn():
break break
count += 1 count += 1
sleep(1) sleep(1)
#tgen.mininet_cli() # tgen.mininet_cli()
assertmsg = "BGP Peer 10.4.4.4 did not connect" assertmsg = "BGP Peer 10.4.4.4 did not connect"
assert passed, assertmsg assert passed, assertmsg
@ -503,8 +505,10 @@ def test_r1_mplsvpn_VrfTable():
associated_int = r1_snmp.get( associated_int = r1_snmp.get(
"mplsL3VpnVrfAssociatedInterfaces.{}".format(snmp_str_to_oid("VRF-a")) "mplsL3VpnVrfAssociatedInterfaces.{}".format(snmp_str_to_oid("VRF-a"))
) )
assertmsg = "mplsL3VpnVrfAssociatedInterfaces incorrect should be 3 value {}".format( assertmsg = (
associated_int "mplsL3VpnVrfAssociatedInterfaces incorrect should be 3 value {}".format(
associated_int
)
) )
assert associated_int == "3", assertmsg assert associated_int == "3", assertmsg
@ -620,7 +624,7 @@ rte_table_test = {
"unknown(0)", "unknown(0)",
"ipv4(1)", "ipv4(1)",
"unknown(0)", "unknown(0)",
], ],
"mplsL3VpnVrfRteInetCidrNextHop": [ "mplsL3VpnVrfRteInetCidrNextHop": [
"C0 A8 64 0A", "C0 A8 64 0A",
"C0 A8 C8 0A", "C0 A8 C8 0A",
@ -649,7 +653,15 @@ rte_table_test = {
"bgp(14)", "bgp(14)",
"local(2)", "local(2)",
], ],
"mplsL3VpnVrfRteInetCidrNextHopAS": ["65001", "65001", "0", "65001", "0", "65001", "0"], "mplsL3VpnVrfRteInetCidrNextHopAS": [
"65001",
"65001",
"0",
"65001",
"0",
"65001",
"0",
],
"mplsL3VpnVrfRteInetCidrMetric1": ["0", "0", "20", "0", "0", "0", "0"], "mplsL3VpnVrfRteInetCidrMetric1": ["0", "0", "20", "0", "0", "0", "0"],
"mplsL3VpnVrfRteInetCidrMetric2": ["-1", "-1", "-1", "-1", "-1", "-1", "-1"], "mplsL3VpnVrfRteInetCidrMetric2": ["-1", "-1", "-1", "-1", "-1", "-1", "-1"],
"mplsL3VpnVrfRteInetCidrMetric3": ["-1", "-1", "-1", "-1", "-1", "-1", "-1"], "mplsL3VpnVrfRteInetCidrMetric3": ["-1", "-1", "-1", "-1", "-1", "-1", "-1"],
@ -663,7 +675,7 @@ rte_table_test = {
"active(1)", "active(1)",
"active(1)", "active(1)",
"active(1)", "active(1)",
"active(1)", "active(1)",
], ],
} }

View File

@ -47,6 +47,8 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger from lib.topolog import logger
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):

View File

@ -50,6 +50,8 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger from lib.topolog import logger
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):

View File

@ -76,6 +76,9 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation # Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_as_allow_in.json".format(CWD) jsonFile = "{}/bgp_as_allow_in.json".format(CWD)
try: try:

View File

@ -45,6 +45,8 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger from lib.topolog import logger
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):

View File

@ -40,6 +40,8 @@ from lib.topolog import logger
from mininet.topo import Topo from mininet.topo import Topo
from lib.common_config import step from lib.common_config import step
pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):

View File

@ -45,6 +45,8 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger from lib.topolog import logger
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):

View File

@ -66,6 +66,9 @@ from lib.bgp import (
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
from copy import deepcopy from copy import deepcopy
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation # Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_communities.json".format(CWD) jsonFile = "{}/bgp_communities.json".format(CWD)
try: try:

View File

@ -70,6 +70,9 @@ from lib.bgp import (
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
from copy import deepcopy from copy import deepcopy
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation # Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_communities_topo2.json".format(CWD) jsonFile = "{}/bgp_communities_topo2.json".format(CWD)
try: try:

View File

@ -59,6 +59,8 @@ from mininet.topo import Topo
from lib.common_config import step from lib.common_config import step
from time import sleep from time import sleep
pytestmark = [pytest.mark.bgpd, pytest.mark.bgpd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):

View File

@ -8,7 +8,7 @@ if len(sys.argv) != 2:
fifo = sys.argv[1] fifo = sys.argv[1]
while True: while True:
pipe = open(fifo, 'r') pipe = open(fifo, "r")
with pipe: with pipe:
line = pipe.readline().strip() line = pipe.readline().strip()
if line != "": if line != "":

View File

@ -8,7 +8,7 @@ if len(sys.argv) != 2:
fifo = sys.argv[1] fifo = sys.argv[1]
while True: while True:
pipe = open(fifo, 'r') pipe = open(fifo, "r")
with pipe: with pipe:
line = pipe.readline().strip() line = pipe.readline().strip()
if line != "": if line != "":

View File

@ -8,7 +8,7 @@ if len(sys.argv) != 2:
fifo = sys.argv[1] fifo = sys.argv[1]
while True: while True:
pipe = open(fifo, 'r') pipe = open(fifo, "r")
with pipe: with pipe:
line = pipe.readline().strip() line = pipe.readline().strip()
if line != "": if line != "":

View File

@ -8,7 +8,7 @@ if len(sys.argv) != 2:
fifo = sys.argv[1] fifo = sys.argv[1]
while True: while True:
pipe = open(fifo, 'r') pipe = open(fifo, "r")
with pipe: with pipe:
line = pipe.readline().strip() line = pipe.readline().strip()
if line != "": if line != "":

View File

@ -31,6 +31,7 @@ from lib.ltemplate import *
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
def test_adjacencies(): def test_adjacencies():
CliOnFail = None CliOnFail = None
# For debugging, uncomment the next line # For debugging, uncomment the next line

View File

@ -31,6 +31,7 @@ from lib.ltemplate import *
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
def test_check_linux_vrf(): def test_check_linux_vrf():
CliOnFail = None CliOnFail = None
# For debugging, uncomment the next line # For debugging, uncomment the next line

View File

@ -142,7 +142,7 @@ def _bgp_converge_initial(router_name, peer_address, timeout=180):
""" """
Waits for the BGP connection between a given router and a given peer Waits for the BGP connection between a given router and a given peer
(specified by its IP address) to be established. If the connection is (specified by its IP address) to be established. If the connection is
not established within a given timeout, then an exception is raised. not established within a given timeout, then an exception is raised.
""" """
tgen = get_topogen() tgen = get_topogen()
router = tgen.routers()[router_name] router = tgen.routers()[router_name]

View File

@ -45,17 +45,18 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
#Basic scenario for BGP-LU. Nodes are directly connected. # Basic scenario for BGP-LU. Nodes are directly connected.
#Node 3 is advertising many routes to 2, which advertises them # Node 3 is advertising many routes to 2, which advertises them
#as BGP-LU to 1; this way we get routes with actual labels, as # as BGP-LU to 1; this way we get routes with actual labels, as
#opposed to implicit-null routes in the 2-node case. # opposed to implicit-null routes in the 2-node case.
# #
# AS1 BGP-LU AS2 iBGP AS2 # AS1 BGP-LU AS2 iBGP AS2
#+-----+ +-----+ +-----+ # +-----+ +-----+ +-----+
#| |.1 .2| |.2 .3| | # | |.1 .2| |.2 .3| |
#| 1 +----------------+ 2 +-----------------+ 3 | # | 1 +----------------+ 2 +-----------------+ 3 |
#| | 10.0.0.0/24 | | 10.0.1.0/24 | | # | | 10.0.0.0/24 | | 10.0.1.0/24 | |
#+-----+ +-----+ +-----+ # +-----+ +-----+ +-----+
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"
@ -84,7 +85,6 @@ class TemplateTopo(Topo):
switch.add_link(tgen.gears["R3"]) switch.add_link(tgen.gears["R3"])
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
@ -115,15 +115,19 @@ def teardown_module(mod):
# This function tears down the whole topology. # This function tears down the whole topology.
tgen.stop_topology() tgen.stop_topology()
def check_labelpool(router): def check_labelpool(router):
json_file = "{}/{}/labelpool.summ.json".format(CWD, router.name) json_file = "{}/{}/labelpool.summ.json".format(CWD, router.name)
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial(topotest.router_json_cmp, router, "show bgp labelpool summary json", expected) test_func = partial(
topotest.router_json_cmp, router, "show bgp labelpool summary json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=20, wait=1) _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
assertmsg = '"{}" JSON output mismatches - Did not converge'.format(router.name) assertmsg = '"{}" JSON output mismatches - Did not converge'.format(router.name)
assert result is None, assertmsg assert result is None, assertmsg
def test_converge_bgplu(): def test_converge_bgplu():
"Wait for protocol convergence" "Wait for protocol convergence"
@ -132,13 +136,14 @@ def test_converge_bgplu():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
#tgen.mininet_cli(); # tgen.mininet_cli();
r1 = tgen.gears["R1"] r1 = tgen.gears["R1"]
r2 = tgen.gears["R2"] r2 = tgen.gears["R2"]
check_labelpool(r1) check_labelpool(r1)
check_labelpool(r2) check_labelpool(r2)
def test_clear_bgplu(): def test_clear_bgplu():
"Wait for protocol convergence" "Wait for protocol convergence"
@ -147,7 +152,7 @@ def test_clear_bgplu():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
#tgen.mininet_cli(); # tgen.mininet_cli();
r1 = tgen.gears["R1"] r1 = tgen.gears["R1"]
r2 = tgen.gears["R2"] r2 = tgen.gears["R2"]
@ -164,6 +169,7 @@ def test_clear_bgplu():
check_labelpool(r1) check_labelpool(r1)
check_labelpool(r2) check_labelpool(r2)
def test_memory_leak(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."
tgen = get_topogen() tgen = get_topogen()

View File

@ -31,6 +31,7 @@ from lib.ltemplate import *
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
def test_add_routes(): def test_add_routes():
CliOnFail = None CliOnFail = None
# For debugging, uncomment the next line # For debugging, uncomment the next line

View File

@ -44,7 +44,7 @@ from lib.topolog import logger
from mininet.topo import Topo from mininet.topo import Topo
#TODO: select markers based on daemons used during test # TODO: select markers based on daemons used during test
# pytest module level markers # pytest module level markers
""" """
pytestmark = pytest.mark.bfdd # single marker pytestmark = pytest.mark.bfdd # single marker

View File

@ -54,7 +54,7 @@ from lib.bgp import verify_bgp_convergence
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
#TODO: select markers based on daemons used during test # TODO: select markers based on daemons used during test
# pytest module level markers # pytest module level markers
""" """
pytestmark = pytest.mark.bfdd # single marker pytestmark = pytest.mark.bfdd # single marker

View File

@ -53,7 +53,7 @@ from lib.bgp import verify_bgp_convergence
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
#TODO: select markers based on daemons used during test # TODO: select markers based on daemons used during test
# pytest module level markers # pytest module level markers
""" """
pytestmark = pytest.mark.bfdd # single marker pytestmark = pytest.mark.bfdd # single marker

View File

@ -55,7 +55,7 @@ from lib.bgp import verify_bgp_convergence
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
#TODO: select markers based on daemons used during test # TODO: select markers based on daemons used during test
# pytest module level markers # pytest module level markers
""" """
pytestmark = pytest.mark.bfdd # single marker pytestmark = pytest.mark.bfdd # single marker

View File

@ -165,6 +165,7 @@ class TemplateTopo(Topo):
f_in.close() f_in.close()
f_out.close() f_out.close()
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__)

View File

@ -73,7 +73,7 @@ from functools import partial
# Save the Current Working Directory to find configuration files. # Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__)) CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, '../')) sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413 # pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
@ -87,8 +87,10 @@ from mininet.topo import Topo
# Global multi-dimensional dictionary containing all expected outputs # Global multi-dimensional dictionary containing all expected outputs
outputs = {} outputs = {}
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"
def build(self, *_args, **_opts): def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self) tgen = get_topogen(self)
@ -96,36 +98,36 @@ class TemplateTopo(Topo):
# #
# Define FRR Routers # Define FRR Routers
# #
for router in ['rt1', 'rt2', 'rt3', 'rt4', 'rt5', 'rt6']: for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
tgen.add_router(router) tgen.add_router(router)
# #
# Define connections # Define connections
# #
switch = tgen.add_switch('s1') switch = tgen.add_switch("s1")
switch.add_link(tgen.gears['rt1'], nodeif="eth-sw1") switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
switch.add_link(tgen.gears['rt2'], nodeif="eth-sw1") switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
switch.add_link(tgen.gears['rt3'], nodeif="eth-sw1") switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
switch = tgen.add_switch('s2') switch = tgen.add_switch("s2")
switch.add_link(tgen.gears['rt2'], nodeif="eth-rt4") switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4")
switch.add_link(tgen.gears['rt4'], nodeif="eth-rt2") switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2")
switch = tgen.add_switch('s4') switch = tgen.add_switch("s4")
switch.add_link(tgen.gears['rt3'], nodeif="eth-rt5") switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5")
switch.add_link(tgen.gears['rt5'], nodeif="eth-rt3") switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3")
switch = tgen.add_switch('s6') switch = tgen.add_switch("s6")
switch.add_link(tgen.gears['rt4'], nodeif="eth-rt5") switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
switch.add_link(tgen.gears['rt5'], nodeif="eth-rt4") switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
switch = tgen.add_switch('s7') switch = tgen.add_switch("s7")
switch.add_link(tgen.gears['rt4'], nodeif="eth-rt6") switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
switch.add_link(tgen.gears['rt6'], nodeif="eth-rt4") switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
switch = tgen.add_switch('s8') switch = tgen.add_switch("s8")
switch.add_link(tgen.gears['rt5'], nodeif="eth-rt6") switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
switch.add_link(tgen.gears['rt6'], nodeif="eth-rt5") switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
def setup_module(mod): def setup_module(mod):
@ -138,16 +140,15 @@ def setup_module(mod):
# For all registered routers, load the zebra configuration file # For all registered routers, load the zebra configuration file
for rname, router in router_list.items(): for rname, router in router_list.items():
router.load_config( router.load_config(
TopoRouter.RD_ZEBRA, TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
os.path.join(CWD, '{}/zebra.conf'.format(rname))
) )
router.load_config( router.load_config(
TopoRouter.RD_ISIS, TopoRouter.RD_ISIS, os.path.join(CWD, "{}/isisd.conf".format(rname))
os.path.join(CWD, '{}/isisd.conf'.format(rname))
) )
tgen.start_router() tgen.start_router()
def teardown_module(mod): def teardown_module(mod):
"Teardown the pytest environment" "Teardown the pytest environment"
tgen = get_topogen() tgen = get_topogen()
@ -155,6 +156,7 @@ def teardown_module(mod):
# This function tears down the whole topology. # This function tears down the whole topology.
tgen.stop_topology() tgen.stop_topology()
def router_compare_json_output(rname, command, reference): def router_compare_json_output(rname, command, reference):
"Compare router JSON output" "Compare router JSON output"
@ -170,6 +172,7 @@ def router_compare_json_output(rname, command, reference):
assertmsg = '"{}" JSON output mismatches the expected result'.format(rname) assertmsg = '"{}" JSON output mismatches the expected result'.format(rname)
assert diff is None, assertmsg assert diff is None, assertmsg
# #
# Step 1 # Step 1
# #
@ -184,13 +187,14 @@ def test_isis_adjacencies_step1():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
for rname in ['rt1', 'rt2', 'rt3', 'rt4', 'rt5', 'rt6']: for rname in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, rname,
"show yang operational-data /frr-interface:lib isisd", "show yang operational-data /frr-interface:lib isisd",
"step1/show_yang_interface_isis_adjacencies.ref", "step1/show_yang_interface_isis_adjacencies.ref",
) )
def test_rib_ipv4_step1(): def test_rib_ipv4_step1():
logger.info("Test (step 1): verify IPv4 RIB") logger.info("Test (step 1): verify IPv4 RIB")
tgen = get_topogen() tgen = get_topogen()
@ -199,11 +203,12 @@ def test_rib_ipv4_step1():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
for rname in ['rt1', 'rt2', 'rt3', 'rt4', 'rt5', 'rt6']: for rname in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ip route isis json", "step1/show_ip_route.ref" rname, "show ip route isis json", "step1/show_ip_route.ref"
) )
def test_rib_ipv6_step1(): def test_rib_ipv6_step1():
logger.info("Test (step 1): verify IPv6 RIB") logger.info("Test (step 1): verify IPv6 RIB")
tgen = get_topogen() tgen = get_topogen()
@ -212,11 +217,12 @@ def test_rib_ipv6_step1():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
for rname in ['rt1', 'rt2', 'rt3', 'rt4', 'rt5', 'rt6']: for rname in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ipv6 route isis json", "step1/show_ipv6_route.ref" rname, "show ipv6 route isis json", "step1/show_ipv6_route.ref"
) )
# #
# Step 2 # Step 2
# #
@ -235,15 +241,20 @@ def test_rib_ipv4_step2():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
logger.info('Disabling setting the attached-bit on RT2 and RT4') logger.info("Disabling setting the attached-bit on RT2 and RT4")
tgen.net['rt2'].cmd('vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"') tgen.net["rt2"].cmd(
tgen.net['rt4'].cmd('vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"') 'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"'
)
tgen.net["rt4"].cmd(
'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit send"'
)
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ip route isis json", "step2/show_ip_route.ref" rname, "show ip route isis json", "step2/show_ip_route.ref"
) )
def test_rib_ipv6_step2(): def test_rib_ipv6_step2():
logger.info("Test (step 2): verify IPv6 RIB") logger.info("Test (step 2): verify IPv6 RIB")
tgen = get_topogen() tgen = get_topogen()
@ -252,11 +263,12 @@ def test_rib_ipv6_step2():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ipv6 route isis json", "step2/show_ipv6_route.ref" rname, "show ipv6 route isis json", "step2/show_ipv6_route.ref"
) )
# #
# Step 3 # Step 3
# #
@ -265,7 +277,7 @@ def test_rib_ipv6_step2():
# -disble processing a LSP with attach bit set # -disble processing a LSP with attach bit set
# #
# Expected changes: # Expected changes:
# -RT1 and RT6 should not install a default route # -RT1 and RT6 should not install a default route
# #
def test_rib_ipv4_step3(): def test_rib_ipv4_step3():
logger.info("Test (step 3): verify IPv4 RIB") logger.info("Test (step 3): verify IPv4 RIB")
@ -275,19 +287,24 @@ def test_rib_ipv4_step3():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
logger.info('Enable setting the attached-bit on RT2 and RT4') logger.info("Enable setting the attached-bit on RT2 and RT4")
tgen.net['rt2'].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"') tgen.net["rt2"].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"')
tgen.net['rt4'].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"') tgen.net["rt4"].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit send"')
logger.info('Disable processing received attached-bit in LSP on RT1 and RT6') logger.info("Disable processing received attached-bit in LSP on RT1 and RT6")
tgen.net['rt1'].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"') tgen.net["rt1"].cmd(
tgen.net['rt6'].cmd('vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"') 'vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"'
)
tgen.net["rt6"].cmd(
'vtysh -c "conf t" -c "router isis 1" -c "attached-bit receive ignore"'
)
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ip route isis json", "step3/show_ip_route.ref" rname, "show ip route isis json", "step3/show_ip_route.ref"
) )
def test_rib_ipv6_step3(): def test_rib_ipv6_step3():
logger.info("Test (step 3): verify IPv6 RIB") logger.info("Test (step 3): verify IPv6 RIB")
tgen = get_topogen() tgen = get_topogen()
@ -296,11 +313,12 @@ def test_rib_ipv6_step3():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ipv6 route isis json", "step3/show_ipv6_route.ref" rname, "show ipv6 route isis json", "step3/show_ipv6_route.ref"
) )
# #
# Step 4 # Step 4
# #
@ -319,13 +337,21 @@ def test_rib_ipv4_step4():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
logger.info('restore default processing on received attached-bit in LSP on RT1 and RT6') logger.info(
tgen.net['rt1'].cmd('vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"') "restore default processing on received attached-bit in LSP on RT1 and RT6"
tgen.net['rt6'].cmd('vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"') )
tgen.net["rt1"].cmd(
'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"'
)
tgen.net["rt6"].cmd(
'vtysh -c "conf t" -c "router isis 1" -c "no attached-bit receive ignore"'
)
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ip route isis json", "step4/show_ip_route.ref") rname, "show ip route isis json", "step4/show_ip_route.ref"
)
def test_rib_ipv6_step4(): def test_rib_ipv6_step4():
logger.info("Test (step 4): verify IPv6 RIB") logger.info("Test (step 4): verify IPv6 RIB")
@ -335,19 +361,22 @@ def test_rib_ipv6_step4():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
router_compare_json_output( router_compare_json_output(
rname, "show ipv6 route isis json", "step4/show_ipv6_route.ref") rname, "show ipv6 route isis json", "step4/show_ipv6_route.ref"
)
# Memory leak test template # Memory leak test template
def test_memory_leak(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."
tgen = get_topogen() tgen = get_topogen()
if not tgen.is_memleak_enabled(): if not tgen.is_memleak_enabled():
pytest.skip('Memory leak test/report is disabled') pytest.skip("Memory leak test/report is disabled")
tgen.report_memory_leaks() tgen.report_memory_leaks()
if __name__ == '__main__':
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:] args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args)) sys.exit(pytest.main(args))

View File

@ -167,6 +167,7 @@ class TemplateTopo(Topo):
f_in.close() f_in.close()
f_out.close() f_out.close()
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__)

View File

@ -85,7 +85,7 @@ from functools import partial
# Save the Current Working Directory to find configuration files. # Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__)) CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, '../')) sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413 # pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
@ -101,6 +101,7 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.pathd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"
def build(self, *_args, **_opts): def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self) tgen = get_topogen(self)
@ -108,48 +109,49 @@ class TemplateTopo(Topo):
# #
# Define FRR Routers # Define FRR Routers
# #
for router in ['rt1', 'rt2', 'rt3', 'rt4', 'rt5', 'rt6', 'dst']: for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "dst"]:
tgen.add_router(router) tgen.add_router(router)
# #
# Define connections # Define connections
# #
switch = tgen.add_switch('s1') switch = tgen.add_switch("s1")
switch.add_link(tgen.gears['rt1'], nodeif="eth-sw1") switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
switch.add_link(tgen.gears['rt2'], nodeif="eth-sw1") switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
switch.add_link(tgen.gears['rt3'], nodeif="eth-sw1") switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
switch = tgen.add_switch('s2') switch = tgen.add_switch("s2")
switch.add_link(tgen.gears['rt2'], nodeif="eth-rt4-1") switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
switch.add_link(tgen.gears['rt4'], nodeif="eth-rt2-1") switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
switch = tgen.add_switch('s3') switch = tgen.add_switch("s3")
switch.add_link(tgen.gears['rt2'], nodeif="eth-rt4-2") switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
switch.add_link(tgen.gears['rt4'], nodeif="eth-rt2-2") switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
switch = tgen.add_switch('s4') switch = tgen.add_switch("s4")
switch.add_link(tgen.gears['rt3'], nodeif="eth-rt5-1") switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
switch.add_link(tgen.gears['rt5'], nodeif="eth-rt3-1") switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
switch = tgen.add_switch('s5') switch = tgen.add_switch("s5")
switch.add_link(tgen.gears['rt3'], nodeif="eth-rt5-2") switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
switch.add_link(tgen.gears['rt5'], nodeif="eth-rt3-2") switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
switch = tgen.add_switch('s6') switch = tgen.add_switch("s6")
switch.add_link(tgen.gears['rt4'], nodeif="eth-rt5") switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
switch.add_link(tgen.gears['rt5'], nodeif="eth-rt4") switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
switch = tgen.add_switch('s7') switch = tgen.add_switch("s7")
switch.add_link(tgen.gears['rt4'], nodeif="eth-rt6") switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
switch.add_link(tgen.gears['rt6'], nodeif="eth-rt4") switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
switch = tgen.add_switch('s8') switch = tgen.add_switch("s8")
switch.add_link(tgen.gears['rt5'], nodeif="eth-rt6") switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
switch.add_link(tgen.gears['rt6'], nodeif="eth-rt5") switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
switch = tgen.add_switch("s9")
switch.add_link(tgen.gears["rt6"], nodeif="eth-dst")
switch.add_link(tgen.gears["dst"], nodeif="eth-rt6")
switch = tgen.add_switch('s9')
switch.add_link(tgen.gears['rt6'], nodeif="eth-dst")
switch.add_link(tgen.gears['dst'], nodeif="eth-rt6")
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
@ -167,24 +169,21 @@ def setup_module(mod):
# For all registered routers, load the zebra configuration file # For all registered routers, load the zebra configuration file
for rname, router in router_list.iteritems(): for rname, router in router_list.iteritems():
router.load_config( router.load_config(
TopoRouter.RD_ZEBRA, TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
os.path.join(CWD, '{}/zebra.conf'.format(rname))
) )
router.load_config( router.load_config(
TopoRouter.RD_ISIS, TopoRouter.RD_ISIS, os.path.join(CWD, "{}/isisd.conf".format(rname))
os.path.join(CWD, '{}/isisd.conf'.format(rname))
) )
router.load_config( router.load_config(
TopoRouter.RD_PATH, TopoRouter.RD_PATH, os.path.join(CWD, "{}/pathd.conf".format(rname))
os.path.join(CWD, '{}/pathd.conf'.format(rname))
) )
router.load_config( router.load_config(
TopoRouter.RD_BGP, TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
os.path.join(CWD, '{}/bgpd.conf'.format(rname))
) )
tgen.start_router() tgen.start_router()
def teardown_module(mod): def teardown_module(mod):
"Teardown the pytest environment" "Teardown the pytest environment"
tgen = get_topogen() tgen = get_topogen()
@ -192,6 +191,7 @@ def teardown_module(mod):
# This function tears down the whole topology. # This function tears down the whole topology.
tgen.stop_topology() tgen.stop_topology()
def setup_testcase(msg): def setup_testcase(msg):
logger.info(msg) logger.info(msg)
tgen = get_topogen() tgen = get_topogen()
@ -202,9 +202,11 @@ def setup_testcase(msg):
return tgen return tgen
def print_cmd_result(rname, command): def print_cmd_result(rname, command):
print(get_topogen().gears[rname].vtysh_cmd(command, isjson=False)) print(get_topogen().gears[rname].vtysh_cmd(command, isjson=False))
def compare_json_test(router, command, reference, exact): def compare_json_test(router, command, reference, exact):
output = router.vtysh_cmd(command, isjson=True) output = router.vtysh_cmd(command, isjson=True)
result = topotest.json_cmp(output, reference) result = topotest.json_cmp(output, reference)
@ -212,9 +214,10 @@ def compare_json_test(router, command, reference, exact):
# Note: topotest.json_cmp() just checks on inclusion of keys. # Note: topotest.json_cmp() just checks on inclusion of keys.
# For exact matching also compare the other way around. # For exact matching also compare the other way around.
if not result and exact: if not result and exact:
return topotest.json_cmp(reference, output) return topotest.json_cmp(reference, output)
else: else:
return result return result
def cmp_json_output(rname, command, reference, exact=False): def cmp_json_output(rname, command, reference, exact=False):
"Compare router JSON output" "Compare router JSON output"
@ -222,78 +225,136 @@ def cmp_json_output(rname, command, reference, exact=False):
logger.info('Comparing router "%s" "%s" output', rname, command) logger.info('Comparing router "%s" "%s" output', rname, command)
tgen = get_topogen() tgen = get_topogen()
filename = '{}/{}/{}'.format(CWD, rname, reference) filename = "{}/{}/{}".format(CWD, rname, reference)
expected = json.loads(open(filename).read()) expected = json.loads(open(filename).read())
# Run test function until we get an result. Wait at most 60 seconds. # Run test function until we get an result. Wait at most 60 seconds.
test_func = partial(compare_json_test, test_func = partial(compare_json_test, tgen.gears[rname], command, expected, exact)
tgen.gears[rname], command, expected, exact)
_, diff = topotest.run_and_expect(test_func, None, count=120, wait=0.5) _, diff = topotest.run_and_expect(test_func, None, count=120, wait=0.5)
assertmsg = '"{}" JSON output mismatches the expected result'.format(rname) assertmsg = '"{}" JSON output mismatches the expected result'.format(rname)
assert diff is None, assertmsg assert diff is None, assertmsg
def cmp_json_output_exact(rname, command, reference): def cmp_json_output_exact(rname, command, reference):
return cmp_json_output(rname, command, reference, True) return cmp_json_output(rname, command, reference, True)
def add_candidate_path(rname, endpoint, pref, name, segment_list='default'):
get_topogen().net[rname].cmd(''' \ def add_candidate_path(rname, endpoint, pref, name, segment_list="default"):
get_topogen().net[rname].cmd(
""" \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "segment-routing" \ -c "segment-routing" \
-c "traffic-eng" \ -c "traffic-eng" \
-c "policy color 1 endpoint ''' + endpoint + '''" \ -c "policy color 1 endpoint """
-c "candidate-path preference ''' + str(pref) + ''' name ''' + name + ''' explicit segment-list ''' + segment_list + '''"''') + endpoint
+ """" \
-c "candidate-path preference """
+ str(pref)
+ """ name """
+ name
+ """ explicit segment-list """
+ segment_list
+ '''"'''
)
def delete_candidate_path(rname, endpoint, pref): def delete_candidate_path(rname, endpoint, pref):
get_topogen().net[rname].cmd(''' \ get_topogen().net[rname].cmd(
""" \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "segment-routing" \ -c "segment-routing" \
-c "traffic-eng" \ -c "traffic-eng" \
-c "policy color 1 endpoint ''' + endpoint + '''" \ -c "policy color 1 endpoint """
-c "no candidate-path preference ''' + str(pref) + '''"''') + endpoint
+ """" \
-c "no candidate-path preference """
+ str(pref)
+ '''"'''
)
def add_segment(rname, name, index, label): def add_segment(rname, name, index, label):
get_topogen().net[rname].cmd(''' \ get_topogen().net[rname].cmd(
""" \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "segment-routing" \ -c "segment-routing" \
-c "traffic-eng" \ -c "traffic-eng" \
-c "segment-list ''' + name + '''" \ -c "segment-list """
-c "index ''' + str(index) + ''' mpls label ''' + str(label) + '''"''') + name
+ """" \
-c "index """
+ str(index)
+ """ mpls label """
+ str(label)
+ '''"'''
)
def delete_segment(rname, name, index): def delete_segment(rname, name, index):
get_topogen().net[rname].cmd(''' \ get_topogen().net[rname].cmd(
""" \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "segment-routing" \ -c "segment-routing" \
-c "traffic-eng" \ -c "traffic-eng" \
-c "segment-list ''' + name + '''" \ -c "segment-list """
-c "no index ''' + str(index) + '''"''') + name
+ """" \
-c "no index """
+ str(index)
+ '''"'''
)
def create_sr_policy(rname, endpoint, bsid): def create_sr_policy(rname, endpoint, bsid):
get_topogen().net[rname].cmd(''' \ get_topogen().net[rname].cmd(
""" \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "segment-routing" \ -c "segment-routing" \
-c "traffic-eng" \ -c "traffic-eng" \
-c "policy color 1 endpoint ''' + endpoint + '''" \ -c "policy color 1 endpoint """
+ endpoint
+ """" \
-c "name default" \ -c "name default" \
-c "binding-sid ''' + str(bsid) + '''"''') -c "binding-sid """
+ str(bsid)
+ '''"'''
)
def delete_sr_policy(rname, endpoint): def delete_sr_policy(rname, endpoint):
get_topogen().net[rname].cmd(''' \ get_topogen().net[rname].cmd(
""" \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "segment-routing" \ -c "segment-routing" \
-c "traffic-eng" \ -c "traffic-eng" \
-c "no policy color 1 endpoint ''' + endpoint + '''"''') -c "no policy color 1 endpoint """
+ endpoint
+ '''"'''
)
def create_prefix_sid(rname, prefix, sid): def create_prefix_sid(rname, prefix, sid):
get_topogen().net[rname].cmd(''' \ get_topogen().net[rname].cmd(
""" \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "router isis 1" \ -c "router isis 1" \
-c "segment-routing prefix ''' + prefix + " index " + str(sid) + '''"''') -c "segment-routing prefix """
+ prefix
+ " index "
+ str(sid)
+ '''"'''
)
def delete_prefix_sid(rname, prefix): def delete_prefix_sid(rname, prefix):
get_topogen().net[rname].cmd(''' \ get_topogen().net[rname].cmd(
''' \
vtysh -c "conf t" \ vtysh -c "conf t" \
-c "router isis 1" \ -c "router isis 1" \
-c "no segment-routing prefix "''' + prefix) -c "no segment-routing prefix "'''
+ prefix
)
# #
# Step 1 # Step 1
@ -303,37 +364,42 @@ def delete_prefix_sid(rname, prefix):
def test_srte_init_step1(): def test_srte_init_step1():
setup_testcase("Test (step 1): wait for IS-IS convergence / label distribution") setup_testcase("Test (step 1): wait for IS-IS convergence / label distribution")
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
cmp_json_output(rname, cmp_json_output(
"show mpls table json", rname, "show mpls table json", "step1/show_mpls_table_without_candidate.ref"
"step1/show_mpls_table_without_candidate.ref") )
def test_srte_add_candidate_check_mpls_table_step1(): def test_srte_add_candidate_check_mpls_table_step1():
setup_testcase("Test (step 1): check MPLS table regarding the added Candidate Path") setup_testcase("Test (step 1): check MPLS table regarding the added Candidate Path")
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
add_candidate_path(rname, endpoint, 100, 'default') add_candidate_path(rname, endpoint, 100, "default")
cmp_json_output(rname, cmp_json_output(
"show mpls table json", rname, "show mpls table json", "step1/show_mpls_table_with_candidate.ref"
"step1/show_mpls_table_with_candidate.ref") )
delete_candidate_path(rname, endpoint, 100) delete_candidate_path(rname, endpoint, 100)
def test_srte_reinstall_sr_policy_check_mpls_table_step1(): def test_srte_reinstall_sr_policy_check_mpls_table_step1():
setup_testcase("Test (step 1): check MPLS table after the SR Policy was removed and reinstalled") setup_testcase(
"Test (step 1): check MPLS table after the SR Policy was removed and reinstalled"
)
for rname, endpoint, bsid in [('rt1', '6.6.6.6', 1111), ('rt6', '1.1.1.1', 6666)]: for rname, endpoint, bsid in [("rt1", "6.6.6.6", 1111), ("rt6", "1.1.1.1", 6666)]:
add_candidate_path(rname, endpoint, 100, 'default') add_candidate_path(rname, endpoint, 100, "default")
delete_sr_policy(rname, endpoint) delete_sr_policy(rname, endpoint)
cmp_json_output(rname, cmp_json_output(
"show mpls table json", rname, "show mpls table json", "step1/show_mpls_table_without_candidate.ref"
"step1/show_mpls_table_without_candidate.ref") )
create_sr_policy(rname, endpoint, bsid) create_sr_policy(rname, endpoint, bsid)
add_candidate_path(rname, endpoint, 100, 'default') add_candidate_path(rname, endpoint, 100, "default")
cmp_json_output(rname, cmp_json_output(
"show mpls table json", rname, "show mpls table json", "step1/show_mpls_table_with_candidate.ref"
"step1/show_mpls_table_with_candidate.ref") )
delete_candidate_path(rname, endpoint, 100) delete_candidate_path(rname, endpoint, 100)
# #
# Step 2 # Step 2
# #
@ -342,28 +408,41 @@ def test_srte_reinstall_sr_policy_check_mpls_table_step1():
def test_srte_bare_policy_step2(): def test_srte_bare_policy_step2():
setup_testcase("Test (step 2): bare SR Policy should not be operational") setup_testcase("Test (step 2): bare SR Policy should not be operational")
for rname in ['rt1', 'rt6']: for rname in ["rt1", "rt6"]:
cmp_json_output_exact(rname, cmp_json_output_exact(
"show yang operational-data /frr-pathd:pathd pathd", rname,
"step2/show_operational_data.ref") "show yang operational-data /frr-pathd:pathd pathd",
"step2/show_operational_data.ref",
)
def test_srte_add_candidate_check_operational_data_step2(): def test_srte_add_candidate_check_operational_data_step2():
setup_testcase("Test (step 2): add single Candidate Path, SR Policy should be operational") setup_testcase(
"Test (step 2): add single Candidate Path, SR Policy should be operational"
)
for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
add_candidate_path(rname, endpoint, 100, "default")
cmp_json_output(
rname,
"show yang operational-data /frr-pathd:pathd pathd",
"step2/show_operational_data_with_candidate.ref",
)
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]:
add_candidate_path(rname, endpoint, 100, 'default')
cmp_json_output(rname,
"show yang operational-data /frr-pathd:pathd pathd",
"step2/show_operational_data_with_candidate.ref")
def test_srte_config_remove_candidate_check_operational_data_step2(): def test_srte_config_remove_candidate_check_operational_data_step2():
setup_testcase("Test (step 2): remove single Candidate Path, SR Policy should not be operational anymore") setup_testcase(
"Test (step 2): remove single Candidate Path, SR Policy should not be operational anymore"
)
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
delete_candidate_path(rname, endpoint, 100) delete_candidate_path(rname, endpoint, 100)
cmp_json_output_exact(rname, cmp_json_output_exact(
"show yang operational-data /frr-pathd:pathd pathd", rname,
"step2/show_operational_data.ref") "show yang operational-data /frr-pathd:pathd pathd",
"step2/show_operational_data.ref",
)
# #
# Step 3 # Step 3
@ -373,53 +452,62 @@ def test_srte_config_remove_candidate_check_operational_data_step2():
def test_srte_add_two_candidates_step3(): def test_srte_add_two_candidates_step3():
setup_testcase("Test (step 3): second Candidate Path has higher Priority") setup_testcase("Test (step 3): second Candidate Path has higher Priority")
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
for pref, cand_name in [('100', 'first'), ('200', 'second')]: for pref, cand_name in [("100", "first"), ("200", "second")]:
add_candidate_path(rname, endpoint, pref, cand_name) add_candidate_path(rname, endpoint, pref, cand_name)
cmp_json_output(rname, cmp_json_output(
"show yang operational-data /frr-pathd:pathd pathd", rname,
"step3/show_operational_data_with_two_candidates.ref") "show yang operational-data /frr-pathd:pathd pathd",
"step3/show_operational_data_with_two_candidates.ref",
)
# cleanup # cleanup
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
for pref in ['100', '200']: for pref in ["100", "200"]:
delete_candidate_path(rname, endpoint, pref) delete_candidate_path(rname, endpoint, pref)
def test_srte_add_two_candidates_with_reverse_priority_step3(): def test_srte_add_two_candidates_with_reverse_priority_step3():
setup_testcase("Test (step 3): second Candidate Path has lower Priority") setup_testcase("Test (step 3): second Candidate Path has lower Priority")
# Use reversed priorities here # Use reversed priorities here
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
for pref, cand_name in [('200', 'first'), ('100', 'second')]: for pref, cand_name in [("200", "first"), ("100", "second")]:
add_candidate_path(rname, endpoint, pref, cand_name) add_candidate_path(rname, endpoint, pref, cand_name)
cmp_json_output(rname, cmp_json_output(
"show yang operational-data /frr-pathd:pathd pathd", rname,
"step3/show_operational_data_with_two_candidates.ref") "show yang operational-data /frr-pathd:pathd pathd",
"step3/show_operational_data_with_two_candidates.ref",
)
# cleanup # cleanup
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
for pref in ['100', '200']: for pref in ["100", "200"]:
delete_candidate_path(rname, endpoint, pref) delete_candidate_path(rname, endpoint, pref)
def test_srte_remove_best_candidate_step3(): def test_srte_remove_best_candidate_step3():
setup_testcase("Test (step 3): delete the Candidate Path with higher priority") setup_testcase("Test (step 3): delete the Candidate Path with higher priority")
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
for pref, cand_name in [('100', 'first'), ('200', 'second')]: for pref, cand_name in [("100", "first"), ("200", "second")]:
add_candidate_path(rname, endpoint, pref, cand_name) add_candidate_path(rname, endpoint, pref, cand_name)
# Delete candidate with higher priority # Delete candidate with higher priority
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
delete_candidate_path(rname, endpoint, 200) delete_candidate_path(rname, endpoint, 200)
# Candidate with lower priority should get active now # Candidate with lower priority should get active now
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
cmp_json_output(rname, cmp_json_output(
"show yang operational-data /frr-pathd:pathd pathd", rname,
"step3/show_operational_data_with_single_candidate.ref") "show yang operational-data /frr-pathd:pathd pathd",
"step3/show_operational_data_with_single_candidate.ref",
)
# cleanup # cleanup
delete_candidate_path(rname, endpoint, 100) delete_candidate_path(rname, endpoint, 100)
# #
# Step 4 # Step 4
# #
@ -428,38 +516,38 @@ def test_srte_remove_best_candidate_step3():
def test_srte_change_segment_list_check_mpls_table_step4(): def test_srte_change_segment_list_check_mpls_table_step4():
setup_testcase("Test (step 4): check MPLS table for changed Segment List") setup_testcase("Test (step 4): check MPLS table for changed Segment List")
for rname, endpoint in [('rt1', '6.6.6.6'), ('rt6', '1.1.1.1')]: for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]:
add_candidate_path(rname, endpoint, 100, 'default') add_candidate_path(rname, endpoint, 100, "default")
# now change the segment list name # now change the segment list name
add_candidate_path(rname, endpoint, 100, 'default', 'test') add_candidate_path(rname, endpoint, 100, "default", "test")
cmp_json_output(rname, cmp_json_output(rname, "show mpls table json", "step4/show_mpls_table.ref")
"show mpls table json",
"step4/show_mpls_table.ref")
delete_candidate_path(rname, endpoint, 100) delete_candidate_path(rname, endpoint, 100)
def test_srte_segment_list_add_segment_check_mpls_table_step4():
setup_testcase("Test (step 4): check MPLS table for added (then changed and finally deleted) segment")
add_candidate_path('rt1', '6.6.6.6', 100, 'default', 'test') def test_srte_segment_list_add_segment_check_mpls_table_step4():
setup_testcase(
"Test (step 4): check MPLS table for added (then changed and finally deleted) segment"
)
add_candidate_path("rt1", "6.6.6.6", 100, "default", "test")
# first add a new segment # first add a new segment
add_segment('rt1', 'test', 25, 16050) add_segment("rt1", "test", 25, 16050)
cmp_json_output('rt1', cmp_json_output(
"show mpls table json", "rt1", "show mpls table json", "step4/show_mpls_table_add_segment.ref"
"step4/show_mpls_table_add_segment.ref") )
# ... then change it ... # ... then change it ...
add_segment('rt1', 'test', 25, 16030) add_segment("rt1", "test", 25, 16030)
cmp_json_output('rt1', cmp_json_output(
"show mpls table json", "rt1", "show mpls table json", "step4/show_mpls_table_change_segment.ref"
"step4/show_mpls_table_change_segment.ref") )
# ... and finally delete it # ... and finally delete it
delete_segment('rt1', 'test', 25) delete_segment("rt1", "test", 25)
cmp_json_output('rt1', cmp_json_output("rt1", "show mpls table json", "step4/show_mpls_table.ref")
"show mpls table json", delete_candidate_path("rt1", "6.6.6.6", 100)
"step4/show_mpls_table.ref")
delete_candidate_path('rt1', '6.6.6.6', 100)
# #
# Step 5 # Step 5
@ -467,68 +555,81 @@ def test_srte_segment_list_add_segment_check_mpls_table_step4():
# Checking the nexthop using a single SR Policy and a Candidate Path with configured route-map # Checking the nexthop using a single SR Policy and a Candidate Path with configured route-map
# #
def test_srte_route_map_with_sr_policy_check_nextop_step5(): def test_srte_route_map_with_sr_policy_check_nextop_step5():
setup_testcase("Test (step 5): recursive nexthop learned through BGP neighbour should be aligned with SR Policy from route-map") setup_testcase(
"Test (step 5): recursive nexthop learned through BGP neighbour should be aligned with SR Policy from route-map"
)
# (re-)build the SR Policy two times to ensure that reinstalling still works # (re-)build the SR Policy two times to ensure that reinstalling still works
for i in [1,2]: for i in [1, 2]:
cmp_json_output('rt1', cmp_json_output(
"show ip route bgp json", "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref"
"step5/show_ip_route_bgp_inactive_srte.ref") )
delete_sr_policy('rt1', '6.6.6.6') delete_sr_policy("rt1", "6.6.6.6")
cmp_json_output('rt1', cmp_json_output(
"show ip route bgp json", "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref"
"step5/show_ip_route_bgp_inactive_srte.ref") )
create_sr_policy('rt1', '6.6.6.6', 1111) create_sr_policy("rt1", "6.6.6.6", 1111)
cmp_json_output('rt1', cmp_json_output(
"show ip route bgp json", "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref"
"step5/show_ip_route_bgp_inactive_srte.ref") )
add_candidate_path('rt1', '6.6.6.6', 100, 'default') add_candidate_path("rt1", "6.6.6.6", 100, "default")
cmp_json_output('rt1', cmp_json_output(
"show ip route bgp json", "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref"
"step5/show_ip_route_bgp_active_srte.ref") )
delete_candidate_path("rt1", "6.6.6.6", 100)
delete_candidate_path('rt1', '6.6.6.6', 100)
def test_srte_route_map_with_sr_policy_reinstall_prefix_sid_check_nextop_step5(): def test_srte_route_map_with_sr_policy_reinstall_prefix_sid_check_nextop_step5():
setup_testcase("Test (step 5): remove and re-install prefix SID on fist path element and check SR Policy activity") setup_testcase(
"Test (step 5): remove and re-install prefix SID on fist path element and check SR Policy activity"
)
# first add a candidate path so the SR Policy is active # first add a candidate path so the SR Policy is active
add_candidate_path('rt1', '6.6.6.6', 100, 'default') add_candidate_path("rt1", "6.6.6.6", 100, "default")
cmp_json_output('rt1', cmp_json_output(
"show yang operational-data /frr-pathd:pathd pathd", "rt1",
"step5/show_operational_data_active.ref") "show yang operational-data /frr-pathd:pathd pathd",
"step5/show_operational_data_active.ref",
)
# delete prefix SID from first element of the configured path and check # delete prefix SID from first element of the configured path and check
# if the SR Policy is inactive since the label can't be resolved anymore # if the SR Policy is inactive since the label can't be resolved anymore
delete_prefix_sid('rt5', "5.5.5.5/32") delete_prefix_sid("rt5", "5.5.5.5/32")
cmp_json_output('rt1', cmp_json_output(
"show yang operational-data /frr-pathd:pathd pathd", "rt1",
"step5/show_operational_data_inactive.ref") "show yang operational-data /frr-pathd:pathd pathd",
cmp_json_output('rt1', "step5/show_operational_data_inactive.ref",
"show ip route bgp json", )
"step5/show_ip_route_bgp_inactive_srte.ref") cmp_json_output(
"rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref"
)
# re-create the prefix SID and check if the SR Policy is active # re-create the prefix SID and check if the SR Policy is active
create_prefix_sid('rt5', "5.5.5.5/32", 50) create_prefix_sid("rt5", "5.5.5.5/32", 50)
cmp_json_output('rt1', cmp_json_output(
"show yang operational-data /frr-pathd:pathd pathd", "rt1",
"step5/show_operational_data_active.ref") "show yang operational-data /frr-pathd:pathd pathd",
cmp_json_output('rt1', "step5/show_operational_data_active.ref",
"show ip route bgp json", )
"step5/show_ip_route_bgp_active_srte.ref") cmp_json_output(
"rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref"
)
# Memory leak test template # Memory leak test template
def test_memory_leak(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."
tgen = get_topogen() tgen = get_topogen()
if not tgen.is_memleak_enabled(): if not tgen.is_memleak_enabled():
pytest.skip('Memory leak test/report is disabled') pytest.skip("Memory leak test/report is disabled")
tgen.report_memory_leaks() tgen.report_memory_leaks()
if __name__ == '__main__':
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:] args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args)) sys.exit(pytest.main(args))

View File

@ -86,6 +86,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.isisd] pytestmark = [pytest.mark.isisd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -179,6 +179,7 @@ class TemplateTopo(Topo):
f_in.close() f_in.close()
f_out.close() f_out.close()
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__)

View File

@ -45,6 +45,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.isisd] pytestmark = [pytest.mark.isisd]
class ISISTopo1(Topo): class ISISTopo1(Topo):
"Simple two layer ISIS vrf topology" "Simple two layer ISIS vrf topology"

View File

@ -47,6 +47,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.isisd] pytestmark = [pytest.mark.isisd]
class ISISTopo1(Topo): class ISISTopo1(Topo):
"Simple two layer ISIS topology" "Simple two layer ISIS topology"

View File

@ -80,6 +80,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -80,6 +80,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -81,6 +81,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -82,6 +82,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -2516,8 +2516,9 @@ def verify_best_path_as_per_admin_distance(
@retry(attempts=5, wait=2, return_is_str=True, initial_wait=2) @retry(attempts=5, wait=2, return_is_str=True, initial_wait=2)
def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, def verify_bgp_rib(
aspath=None, multi_nh=None): tgen, addr_type, dut, input_dict, next_hop=None, aspath=None, multi_nh=None
):
""" """
This API is to verify whether bgp rib has any This API is to verify whether bgp rib has any
matching route for a nexthop. matching route for a nexthop.
@ -2663,25 +2664,35 @@ aspath=None, multi_nh=None):
if not isinstance(next_hop, list): if not isinstance(next_hop, list):
next_hop = [next_hop] next_hop = [next_hop]
list1 = next_hop list1 = next_hop
found_hops = [rib_r["ip"] for rib_r in found_hops = [
rib_routes_json["routes"][ rib_r["ip"]
st_rt][0]["nexthops"]] for rib_r in rib_routes_json["routes"][st_rt][0][
"nexthops"
]
]
list2 = found_hops list2 = found_hops
missing_list_of_nexthops = \ missing_list_of_nexthops = set(list2).difference(list1)
set(list2).difference(list1) additional_nexthops_in_required_nhs = set(
additional_nexthops_in_required_nhs = \ list1
set(list1).difference(list2) ).difference(list2)
if list2: if list2:
if additional_nexthops_in_required_nhs: if additional_nexthops_in_required_nhs:
logger.info("Missing nexthop %s for route"\ logger.info(
" %s in RIB of router %s\n", \ "Missing nexthop %s for route"
additional_nexthops_in_required_nhs, \ " %s in RIB of router %s\n",
st_rt, dut)
errormsg=("Nexthop {} is Missing for "\
"route {} in RIB of router {}\n".format(
additional_nexthops_in_required_nhs, additional_nexthops_in_required_nhs,
st_rt, dut)) st_rt,
dut,
)
errormsg = (
"Nexthop {} is Missing for "
"route {} in RIB of router {}\n".format(
additional_nexthops_in_required_nhs,
st_rt,
dut,
)
)
return errormsg return errormsg
else: else:
nh_found = True nh_found = True

View File

@ -94,7 +94,9 @@ def create_router_ospf(tgen, topo, input_dict=None, build=False, load_config=Tru
return result return result
def __create_ospf_global(tgen, input_dict, router, build=False, load_config=True, ospf="ospf"): def __create_ospf_global(
tgen, input_dict, router, build=False, load_config=True, ospf="ospf"
):
""" """
Helper API to create ospf global configuration. Helper API to create ospf global configuration.

View File

@ -1564,26 +1564,30 @@ def verify_pim_interface(tgen, topo, dut, interface=None, interface_ip=None):
logger.info("[DUT: %s]: Verifying PIM interface status:", dut) logger.info("[DUT: %s]: Verifying PIM interface status:", dut)
rnode = tgen.routers()[dut] rnode = tgen.routers()[dut]
show_ip_pim_interface_json = rnode.\ show_ip_pim_interface_json = rnode.vtysh_cmd(
vtysh_cmd("show ip pim interface json", isjson=True) "show ip pim interface json", isjson=True
)
logger.info("show_ip_pim_interface_json: \n %s", logger.info("show_ip_pim_interface_json: \n %s", show_ip_pim_interface_json)
show_ip_pim_interface_json)
if interface_ip: if interface_ip:
if interface in show_ip_pim_interface_json: if interface in show_ip_pim_interface_json:
pim_intf_json = show_ip_pim_interface_json[interface] pim_intf_json = show_ip_pim_interface_json[interface]
if pim_intf_json["address"] != interface_ip: if pim_intf_json["address"] != interface_ip:
errormsg = ("[DUT %s]: PIM interface " errormsg = (
"ip is not correct " "[DUT %s]: PIM interface "
"[FAILED]!! Expected : %s, Found : %s" "ip is not correct "
%(dut, pim_intf_json["address"],interface_ip)) "[FAILED]!! Expected : %s, Found : %s"
% (dut, pim_intf_json["address"], interface_ip)
)
return errormsg return errormsg
else: else:
logger.info("[DUT %s]: PIM interface " logger.info(
"ip is correct " "[DUT %s]: PIM interface "
"[Passed]!! Expected : %s, Found : %s" "ip is correct "
%(dut, pim_intf_json["address"],interface_ip)) "[Passed]!! Expected : %s, Found : %s"
% (dut, pim_intf_json["address"], interface_ip)
)
return True return True
else: else:
for destLink, data in topo["routers"][dut]["links"].items(): for destLink, data in topo["routers"][dut]["links"].items():
@ -1595,24 +1599,36 @@ def verify_pim_interface(tgen, topo, dut, interface=None, interface_ip=None):
pim_intf_ip = data["ipv4"].split("/")[0] pim_intf_ip = data["ipv4"].split("/")[0]
if pim_interface in show_ip_pim_interface_json: if pim_interface in show_ip_pim_interface_json:
pim_intf_json = show_ip_pim_interface_json\ pim_intf_json = show_ip_pim_interface_json[pim_interface]
[pim_interface]
# Verifying PIM interface # Verifying PIM interface
if pim_intf_json["address"] != pim_intf_ip and \ if (
pim_intf_json["state"] != "up": pim_intf_json["address"] != pim_intf_ip
errormsg = ("[DUT %s]: PIM interface: %s " and pim_intf_json["state"] != "up"
"PIM interface ip: %s, status check " ):
"[FAILED]!! Expected : %s, Found : %s" errormsg = (
%(dut, pim_interface, pim_intf_ip, "[DUT %s]: PIM interface: %s "
pim_interface, pim_intf_json["state"])) "PIM interface ip: %s, status check "
"[FAILED]!! Expected : %s, Found : %s"
% (
dut,
pim_interface,
pim_intf_ip,
pim_interface,
pim_intf_json["state"],
)
)
return errormsg return errormsg
logger.info("[DUT %s]: PIM interface: %s, " logger.info(
"interface ip: %s, status: %s" "[DUT %s]: PIM interface: %s, "
" [PASSED]!!", "interface ip: %s, status: %s"
dut, pim_interface, pim_intf_ip, " [PASSED]!!",
pim_intf_json["state"]) dut,
pim_interface,
pim_intf_ip,
pim_intf_json["state"],
)
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
return True return True
@ -3420,30 +3436,36 @@ def verify_igmp_interface(tgen, topo, dut, igmp_iface, interface_ip):
if router != dut: if router != dut:
continue continue
logger.info("[DUT: %s]: Verifying PIM interface status:", logger.info("[DUT: %s]: Verifying PIM interface status:", dut)
dut)
rnode = tgen.routers()[dut] rnode = tgen.routers()[dut]
show_ip_igmp_interface_json = \ show_ip_igmp_interface_json = run_frr_cmd(
run_frr_cmd(rnode, "show ip igmp interface json", isjson=True) rnode, "show ip igmp interface json", isjson=True
)
if igmp_iface in show_ip_igmp_interface_json: if igmp_iface in show_ip_igmp_interface_json:
igmp_intf_json = show_ip_igmp_interface_json[igmp_iface] igmp_intf_json = show_ip_igmp_interface_json[igmp_iface]
# Verifying igmp interface # Verifying igmp interface
if igmp_intf_json["address"] != interface_ip: if igmp_intf_json["address"] != interface_ip:
errormsg = ("[DUT %s]: igmp interface ip is not correct " errormsg = (
"[FAILED]!! Expected : %s, Found : %s" "[DUT %s]: igmp interface ip is not correct "
%(dut, igmp_intf_json["address"], interface_ip)) "[FAILED]!! Expected : %s, Found : %s"
% (dut, igmp_intf_json["address"], interface_ip)
)
return errormsg return errormsg
logger.info("[DUT %s]: igmp interface: %s, " logger.info(
"interface ip: %s" "[DUT %s]: igmp interface: %s, " "interface ip: %s" " [PASSED]!!",
" [PASSED]!!", dut,
dut, igmp_iface, interface_ip) igmp_iface,
interface_ip,
)
else: else:
errormsg = ("[DUT %s]: igmp interface: %s " errormsg = (
"igmp interface ip: %s, is not present " "[DUT %s]: igmp interface: %s "
%(dut, igmp_iface, interface_ip)) "igmp interface ip: %s, is not present "
% (dut, igmp_iface, interface_ip)
)
return errormsg return errormsg
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))

View File

@ -86,12 +86,11 @@ class SnmpTester(object):
def _get_snmp_oid(snmp_output): def _get_snmp_oid(snmp_output):
tokens = snmp_output.strip().split() tokens = snmp_output.strip().split()
# if len(tokens) > 5: # if len(tokens) > 5:
# return None # return None
# third token is the value of the object # third token is the value of the object
return tokens[0].split('.',1)[1] return tokens[0].split(".", 1)[1]
def _parse_multiline(self, snmp_output): def _parse_multiline(self, snmp_output):
results = snmp_output.strip().split("\r\n") results = snmp_output.strip().split("\r\n")
@ -142,7 +141,11 @@ class SnmpTester(object):
print("FAIL: missing oid key {}".format(oid)) print("FAIL: missing oid key {}".format(oid))
return False return False
if results_dict[oid] != values[index]: if results_dict[oid] != values[index]:
print("FAIL{} {} |{}| == |{}|".format(oid, index, results_dict[oid], values[index])) print(
"FAIL{} {} |{}| == |{}|".format(
oid, index, results_dict[oid], values[index]
)
)
return False return False
index += 1 index += 1
return True return True

View File

@ -706,7 +706,7 @@ def test_BSR_CRP_with_blackhole_address_p1(request):
"f1": { "f1": {
"static_routes": [ "static_routes": [
{"network": [BSR1_ADDR, CRP], "next_hop": "blackhole", "delete": True}, {"network": [BSR1_ADDR, CRP], "next_hop": "blackhole", "delete": True},
{"network": BSR1_ADDR, "next_hop": NEXT_HOP1} {"network": BSR1_ADDR, "next_hop": NEXT_HOP1},
] ]
} }
} }
@ -1118,7 +1118,10 @@ def test_static_rp_override_p1(request):
"l1": { "l1": {
"pim": { "pim": {
"rp": [ "rp": [
{"rp_addr": "33.33.33.33", "group_addr_range": ["225.1.1.1/32"],} {
"rp_addr": "33.33.33.33",
"group_addr_range": ["225.1.1.1/32"],
}
] ]
} }
} }
@ -1294,7 +1297,8 @@ def test_bsmp_stress_add_del_restart_p2(request):
assert ( assert (
rp_add1 == rp2[group] rp_add1 == rp2[group]
), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format( ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format(
tc_name, rp_add1, tc_name,
rp_add1,
) )
# Verify if that rp is installed # Verify if that rp is installed
@ -1632,7 +1636,14 @@ def test_iif_join_state_p0(request):
# Add back route for RP to make it reachable # Add back route for RP to make it reachable
step("Add back route for RP to make it reachable") step("Add back route for RP to make it reachable")
input_dict = { input_dict = {
"l1": {"static_routes": [{"network": rp_ip, "next_hop": next_hop_lhr,}]} "l1": {
"static_routes": [
{
"network": rp_ip,
"next_hop": next_hop_lhr,
}
]
}
} }
result = create_static_routes(tgen, input_dict) result = create_static_routes(tgen, input_dict)
assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)

View File

@ -695,7 +695,8 @@ def test_RP_priority_p0(request):
assert ( assert (
rp_add1 == rp2[group] rp_add1 == rp2[group]
), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format( ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format(
tc_name, rp_add1, tc_name,
rp_add1,
) )
# Verify if that rp is installed # Verify if that rp is installed

View File

@ -102,7 +102,7 @@ from lib.pim import (
clear_ip_mroute, clear_ip_mroute,
clear_ip_pim_interface_traffic, clear_ip_pim_interface_traffic,
verify_igmp_config, verify_igmp_config,
clear_ip_mroute_verify clear_ip_mroute_verify,
) )
from lib.topolog import logger from lib.topolog import logger
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json

View File

@ -877,7 +877,7 @@ def test_verify_SPT_switchover_when_RPT_and_SPT_path_is_different_p0(request):
data["src_address"], data["src_address"],
_IGMP_JOIN_RANGE, _IGMP_JOIN_RANGE,
data["iif"], data["iif"],
data["oil"] data["oil"],
) )
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
@ -1122,8 +1122,9 @@ def test_verify_mroute_after_shut_noshut_of_upstream_interface_p1(request):
done_flag = False done_flag = False
for retry in range(1, 11): for retry in range(1, 11):
result = verify_upstream_iif(tgen, "l1", "Unknown", source, IGMP_JOIN_RANGE_2, result = verify_upstream_iif(
expected=False) tgen, "l1", "Unknown", source, IGMP_JOIN_RANGE_2, expected=False
)
if result is not True: if result is not True:
done_flag = True done_flag = True
else: else:
@ -1515,7 +1516,7 @@ def test_verify_mroute_when_FRR_is_FHR_and_LHR_p0(request):
_IGMP_JOIN_RANGE, _IGMP_JOIN_RANGE,
data["iif"], data["iif"],
data["oil"], data["oil"],
expected=False expected=False,
) )
if result is not True: if result is not True:
done_flag = True done_flag = True
@ -1928,9 +1929,10 @@ def test_verify_oil_iif_for_mroute_after_shut_noshut_source_interface_p1(request
"f1-i8-eth2", "f1-i8-eth2",
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n mroutes are" result is not True
" still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n mroutes are" " still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behavior: {}".format(result)) logger.info("Expected Behavior: {}".format(result))

View File

@ -597,9 +597,10 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request):
input_traffic = {"l1": {"traffic_sent": [intf_l1_i1]}} input_traffic = {"l1": {"traffic_sent": [intf_l1_i1]}}
result = verify_multicast_traffic(tgen, input_traffic, expected=False) result = verify_multicast_traffic(tgen, input_traffic, expected=False)
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
" Traffic is not stopped yet \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " " Traffic is not stopped yet \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -612,9 +613,10 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request):
result = verify_igmp_groups( result = verify_igmp_groups(
tgen, dut, intf_l1_i1, IGMP_JOIN_RANGE_1, expected=False tgen, dut, intf_l1_i1, IGMP_JOIN_RANGE_1, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"IGMP groups are not deleted \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "IGMP groups are not deleted \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -655,9 +657,10 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"mroutes are still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -722,9 +725,10 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request):
input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}} input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
result = verify_multicast_traffic(tgen, input_traffic, expected=False) result = verify_multicast_traffic(tgen, input_traffic, expected=False)
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
" Traffic is not stopped yet \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " " Traffic is not stopped yet \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -737,9 +741,10 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request):
result = verify_igmp_groups( result = verify_igmp_groups(
tgen, dut, intf_f1_i8, IGMP_JOIN_RANGE_1, expected=False tgen, dut, intf_f1_i8, IGMP_JOIN_RANGE_1, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"IGMP groups are not deleted \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "IGMP groups are not deleted \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -775,9 +780,10 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"mroutes are still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -959,9 +965,10 @@ def test_verify_oil_when_join_prune_sent_scenario_2_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"mroutes are still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -1022,9 +1029,10 @@ def test_verify_oil_when_join_prune_sent_scenario_2_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"mroutes are still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -1190,9 +1198,10 @@ def test_shut_noshut_source_interface_when_upstream_cleared_from_LHR_p1(request)
result = verify_ip_mroutes( result = verify_ip_mroutes(
tgen, "f1", source_i2, IGMP_JOIN_RANGE_1, intf_f1_i2, intf_f1_r2, expected=False tgen, "f1", source_i2, IGMP_JOIN_RANGE_1, intf_f1_i2, intf_f1_r2, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n mroutes are" result is not True
" still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n mroutes are" " still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behavior: {}".format(result)) logger.info("Expected Behavior: {}".format(result))
@ -1630,7 +1639,14 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request):
input_dict_2 = { input_dict_2 = {
"l1": { "l1": {
"igmp": { "igmp": {
"interfaces": {intf_l1_i1: {"igmp": {"version": "2", "delete": True,}}} "interfaces": {
intf_l1_i1: {
"igmp": {
"version": "2",
"delete": True,
}
}
}
} }
} }
} }
@ -1642,9 +1658,10 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request):
dut = "l1" dut = "l1"
interface = topo["routers"]["l1"]["links"]["i1"]["interface"] interface = topo["routers"]["l1"]["links"]["i1"]["interface"]
result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN_RANGE_1, expected=False) result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN_RANGE_1, expected=False)
assert result is not True, ( assert (
"Testcase {} : Failed \n Groups are not" result is not True
" present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n Groups are not" " present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -1712,7 +1729,14 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request):
input_dict_2 = { input_dict_2 = {
"l1": { "l1": {
"igmp": { "igmp": {
"interfaces": {intf_l1_i1: {"igmp": {"version": "2", "delete": True,}}} "interfaces": {
intf_l1_i1: {
"igmp": {
"version": "2",
"delete": True,
}
}
}
} }
} }
} }
@ -1725,9 +1749,10 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request):
dut = "l1" dut = "l1"
interface = topo["routers"]["l1"]["links"]["i1"]["interface"] interface = topo["routers"]["l1"]["links"]["i1"]["interface"]
result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN_RANGE_1, expected=False) result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN_RANGE_1, expected=False)
assert result is not True, ( assert (
"Testcase {} : Failed \n Groups are not" result is not True
" present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n Groups are not" " present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -1811,7 +1836,14 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request):
input_dict_2 = { input_dict_2 = {
"l1": { "l1": {
"igmp": { "igmp": {
"interfaces": {intf_l1_i1: {"igmp": {"version": "2", "delete": True,}}} "interfaces": {
intf_l1_i1: {
"igmp": {
"version": "2",
"delete": True,
}
}
}
} }
} }
} }
@ -1831,9 +1863,10 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request):
result = verify_ip_mroutes( result = verify_ip_mroutes(
tgen, dut, source, IGMP_JOIN_RANGE_1, iif, oil, expected=False tgen, dut, source, IGMP_JOIN_RANGE_1, iif, oil, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n routes are still" result is not True
" present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n routes are still" " present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -1995,7 +2028,14 @@ def test_verify_remove_add_igmp_commands_when_pim_configured_p0(request):
input_dict_2 = { input_dict_2 = {
"l1": { "l1": {
"igmp": { "igmp": {
"interfaces": {intf_l1_i1: {"igmp": {"version": "2", "delete": True,}}} "interfaces": {
intf_l1_i1: {
"igmp": {
"version": "2",
"delete": True,
}
}
}
} }
} }
} }
@ -2009,9 +2049,10 @@ def test_verify_remove_add_igmp_commands_when_pim_configured_p0(request):
) )
result = verify_igmp_config(tgen, input_dict_1, expected=False) result = verify_igmp_config(tgen, input_dict_1, expected=False)
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"IGMP interface is not removed \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "IGMP interface is not removed \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -2914,9 +2955,10 @@ def test_mroute_after_removing_RP_sending_IGMP_prune_p2(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"mroute still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "mroute still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -3259,9 +3301,10 @@ def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"mroute still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "mroute still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -3287,9 +3330,10 @@ def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request):
IGMP_JOIN_RANGE_1, IGMP_JOIN_RANGE_1,
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"upstream still present \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "upstream still present \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -3311,9 +3355,10 @@ def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request):
result = verify_pim_rp_info( result = verify_pim_rp_info(
tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"RP iif is not updated \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "RP iif is not updated \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -3459,9 +3504,10 @@ def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request):
result = verify_pim_rp_info( result = verify_pim_rp_info(
tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"RP iif is not updated \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "RP iif is not updated \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -3606,9 +3652,10 @@ def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request):
result = verify_pim_rp_info( result = verify_pim_rp_info(
tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n " result is not True
"RP iif is not updated \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n " "RP iif is not updated \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -3873,7 +3920,12 @@ def test_verify_multicast_traffic_when_LHR_connected_to_RP_p1(request):
"l1": { "l1": {
"igmp": { "igmp": {
"interfaces": { "interfaces": {
"l1-i1-eth1": {"igmp": {"version": "2", "delete": True,}} "l1-i1-eth1": {
"igmp": {
"version": "2",
"delete": True,
}
}
} }
} }
} }
@ -4107,9 +4159,10 @@ def test_verify_multicast_traffic_when_LHR_connected_to_RP_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n" result is not True
"mroutes are cleared \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n" "mroutes are cleared \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -4181,9 +4234,10 @@ def test_verify_multicast_traffic_when_LHR_connected_to_RP_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n" result is not True
" mroutes are cleared \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n" " mroutes are cleared \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -4248,9 +4302,10 @@ def test_verify_multicast_traffic_when_LHR_connected_to_RP_p1(request):
result = verify_ip_mroutes( result = verify_ip_mroutes(
tgen, dut, src_address, _IGMP_JOIN_RANGE, iif, oil, expected=False tgen, dut, src_address, _IGMP_JOIN_RANGE, iif, oil, expected=False
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n" result is not True
" mroutes are cleared \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n" " mroutes are cleared \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -4459,9 +4514,10 @@ def test_verify_multicast_traffic_when_FHR_connected_to_RP_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n" result is not True
" mroutes are cleared \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n" " mroutes are cleared \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -4524,9 +4580,10 @@ def test_verify_multicast_traffic_when_FHR_connected_to_RP_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n" result is not True
" mroutes are cleared \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n" " mroutes are cleared \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))
@ -4595,9 +4652,10 @@ def test_verify_multicast_traffic_when_FHR_connected_to_RP_p1(request):
data["oil"], data["oil"],
expected=False, expected=False,
) )
assert result is not True, ( assert (
"Testcase {} : Failed \n" result is not True
" mroutes are cleared \n Error: {}".format(tc_name, result) ), "Testcase {} : Failed \n" " mroutes are cleared \n Error: {}".format(
tc_name, result
) )
logger.info("Expected Behaviour: {}".format(result)) logger.info("Expected Behaviour: {}".format(result))

View File

@ -1009,7 +1009,11 @@ def test_PIM_hello_tx_rx_p1(request):
intf_c1_l1 = topo["routers"]["c1"]["links"]["l1"]["interface"] intf_c1_l1 = topo["routers"]["c1"]["links"]["l1"]["interface"]
step("verify before stats on C1") step("verify before stats on C1")
state_dict = {"c1": {intf_c1_l1: ["helloTx", "helloRx"],}} state_dict = {
"c1": {
intf_c1_l1: ["helloTx", "helloRx"],
}
}
c1_state_before = verify_pim_interface_traffic(tgen, state_dict) c1_state_before = verify_pim_interface_traffic(tgen, state_dict)
assert isinstance( assert isinstance(
@ -1040,7 +1044,11 @@ def test_PIM_hello_tx_rx_p1(request):
), "Testcase{} : Failed Error: {}" "stats incremented".format(tc_name, result) ), "Testcase{} : Failed Error: {}" "stats incremented".format(tc_name, result)
step("verify before stats on l1") step("verify before stats on l1")
l1_state_dict = {"l1": {intf_l1_c1: ["helloTx", "helloRx"],}} l1_state_dict = {
"l1": {
intf_l1_c1: ["helloTx", "helloRx"],
}
}
l1_state_before = verify_pim_interface_traffic(tgen, l1_state_dict) l1_state_before = verify_pim_interface_traffic(tgen, l1_state_dict)
assert isinstance( assert isinstance(
@ -1077,7 +1085,11 @@ def test_PIM_hello_tx_rx_p1(request):
l1_state_after = {} l1_state_after = {}
step("verify before stats on C1") step("verify before stats on C1")
state_dict = {"c1": {intf_c1_l1: ["helloTx", "helloRx"],}} state_dict = {
"c1": {
intf_c1_l1: ["helloTx", "helloRx"],
}
}
c1_state_before = verify_pim_interface_traffic(tgen, state_dict) c1_state_before = verify_pim_interface_traffic(tgen, state_dict)
assert isinstance( assert isinstance(

View File

@ -281,6 +281,7 @@ def teardown_module():
# #
##################################################### #####################################################
def config_to_send_igmp_join_and_traffic(tgen, tc_name): def config_to_send_igmp_join_and_traffic(tgen, tc_name):
""" """
API to do pre-configuration to send IGMP join and multicast API to do pre-configuration to send IGMP join and multicast
@ -961,7 +962,12 @@ def test_add_RP_after_join_received_p1(request):
input_dict = { input_dict = {
"r1": { "r1": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.2.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.2.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
} }
} }
@ -1147,32 +1153,32 @@ def test_reachable_static_RP_after_join_p0(request):
def test_send_join_on_higher_preffered_rp_p1(request): def test_send_join_on_higher_preffered_rp_p1(request):
""" """
TC_11_P1 : Verify PIM join send towards the higher preferred RP TC_11_P1 : Verify PIM join send towards the higher preferred RP
TC_12_P1 : Verify PIM prune send towards the lower preferred RP TC_12_P1 : Verify PIM prune send towards the lower preferred RP
TC_13_P1 : Verify RPF interface is updated in mroute (kernel) when higher TC_13_P1 : Verify RPF interface is updated in mroute (kernel) when higher
preferred overlapping RP configured preferred overlapping RP configured
TC_14_P1 : Verify IIF and OIL in "show ip pim state" updated properly when TC_14_P1 : Verify IIF and OIL in "show ip pim state" updated properly when
higher preferred overlapping RP configured higher preferred overlapping RP configured
TC_15_P1 : Verify upstream interfaces(IIF) and join state are updated when TC_15_P1 : Verify upstream interfaces(IIF) and join state are updated when
higher preferred overlapping RP is configured higher preferred overlapping RP is configured
TC_16_P1 : Verify join is send to lower preferred RP, when higher TC_16_P1 : Verify join is send to lower preferred RP, when higher
preferred RP gets deleted preferred RP gets deleted
TC_17_P1 : Verify prune is send to higher preferred RP when higher TC_17_P1 : Verify prune is send to higher preferred RP when higher
preferred RP gets deleted preferred RP gets deleted
TC_18_P1 : Verify RPF interface updated in mroute when higher preferred RP TC_18_P1 : Verify RPF interface updated in mroute when higher preferred RP
gets deleted gets deleted
TC_19_P1 : Verify IIF and OIL in "show ip pim state" updated when higher TC_19_P1 : Verify IIF and OIL in "show ip pim state" updated when higher
preferred overlapping RP is deleted preferred overlapping RP is deleted
TC_20_P1 : Verfiy PIM upstream IIF updated when higher preferred TC_20_P1 : Verfiy PIM upstream IIF updated when higher preferred
overlapping RP deleted overlapping RP deleted
Topology used: Topology used:
_______r2 _______r2
| |
iperf | iperf |
r0-----r1 r0-----r1
| |
|_______r4 |_______r4
""" """
tgen = get_topogen() tgen = get_topogen()
@ -1241,7 +1247,12 @@ def test_send_join_on_higher_preffered_rp_p1(request):
input_dict = { input_dict = {
"r4": { "r4": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.4.17", "group_addr_range": ["225.1.1.1/32"],}] "rp": [
{
"rp_addr": "1.0.4.17",
"group_addr_range": ["225.1.1.1/32"],
}
]
} }
} }
} }
@ -1483,22 +1494,42 @@ def test_RP_configured_as_LHR_1_p1(request):
input_dict = { input_dict = {
"r1": { "r1": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r2": { "r2": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r3": { "r3": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r4": { "r4": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
} }
@ -1677,22 +1708,42 @@ def test_RP_configured_as_LHR_2_p1(request):
input_dict = { input_dict = {
"r1": { "r1": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r2": { "r2": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r3": { "r3": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r4": { "r4": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.1.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.1.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
} }
@ -1863,22 +1914,42 @@ def test_RP_configured_as_FHR_1_p1(request):
input_dict = { input_dict = {
"r1": { "r1": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r2": { "r2": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r3": { "r3": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r4": { "r4": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
} }
@ -2050,22 +2121,42 @@ def test_RP_configured_as_FHR_2_p2(request):
input_dict = { input_dict = {
"r1": { "r1": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r2": { "r2": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r3": { "r3": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
"r4": { "r4": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.3.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.3.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
}, },
} }
@ -2733,7 +2824,12 @@ def test_multiple_groups_same_RP_address_p2(request):
input_dict = { input_dict = {
"r1": { "r1": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.2.17", "group_addr_range": GROUP_RANGE_ALL,}] "rp": [
{
"rp_addr": "1.0.2.17",
"group_addr_range": GROUP_RANGE_ALL,
}
]
} }
} }
} }
@ -2893,12 +2989,22 @@ def test_multiple_groups_different_RP_address_p2(request):
input_dict = { input_dict = {
"r2": { "r2": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.2.17", "group_addr_range": GROUP_RANGE_LIST_1,}] "rp": [
{
"rp_addr": "1.0.2.17",
"group_addr_range": GROUP_RANGE_LIST_1,
}
]
} }
}, },
"r4": { "r4": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.4.17", "group_addr_range": GROUP_RANGE_LIST_2,}] "rp": [
{
"rp_addr": "1.0.4.17",
"group_addr_range": GROUP_RANGE_LIST_2,
}
]
} }
}, },
} }
@ -3148,12 +3254,22 @@ def test_multiple_groups_different_RP_address_p2(request):
input_dict = { input_dict = {
"r2": { "r2": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.2.17", "group_addr_range": GROUP_RANGE_LIST_1,}] "rp": [
{
"rp_addr": "1.0.2.17",
"group_addr_range": GROUP_RANGE_LIST_1,
}
]
} }
}, },
"r4": { "r4": {
"pim": { "pim": {
"rp": [{"rp_addr": "1.0.4.17", "group_addr_range": GROUP_RANGE_LIST_2,}] "rp": [
{
"rp_addr": "1.0.4.17",
"group_addr_range": GROUP_RANGE_LIST_2,
}
]
} }
}, },
} }

View File

@ -50,6 +50,7 @@ import pytest
pytestmark = [pytest.mark.ospfd] pytestmark = [pytest.mark.ospfd]
class OspfSrTopo(Topo): class OspfSrTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -166,6 +166,7 @@ def test_ospf_initial_convergence_step1():
"step1/show_ip_route_initial.ref", "step1/show_ip_route_initial.ref",
) )
def test_ospf_link_protection_step2(): def test_ospf_link_protection_step2():
logger.info("Test (step 2): check OSPF link protection") logger.info("Test (step 2): check OSPF link protection")
tgen = get_topogen() tgen = get_topogen()
@ -175,9 +176,7 @@ def test_ospf_link_protection_step2():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
# enable TI-LFA link protection on all interfaces # enable TI-LFA link protection on all interfaces
tgen.net["rt1"].cmd( tgen.net["rt1"].cmd('vtysh -c "conf t" -c "router ospf" -c "fast-reroute ti-lfa"')
'vtysh -c "conf t" -c "router ospf" -c "fast-reroute ti-lfa"'
)
router_compare_json_output( router_compare_json_output(
"rt1", "rt1",
@ -197,6 +196,7 @@ def test_ospf_link_protection_step2():
"step2/show_ip_route_initial.ref", "step2/show_ip_route_initial.ref",
) )
def test_ospf_node_protection_step3(): def test_ospf_node_protection_step3():
logger.info("Test (step 3): check OSPF node protection") logger.info("Test (step 3): check OSPF node protection")
tgen = get_topogen() tgen = get_topogen()
@ -228,6 +228,7 @@ def test_ospf_node_protection_step3():
"step3/show_ip_route_initial.ref", "step3/show_ip_route_initial.ref",
) )
# Memory leak test template # Memory leak test template
def test_memory_leak(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."
@ -237,6 +238,7 @@ def test_memory_leak():
tgen.report_memory_leaks() tgen.report_memory_leaks()
if __name__ == "__main__": if __name__ == "__main__":
args = ["-s"] + sys.argv[1:] args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args)) sys.exit(pytest.main(args))

View File

@ -47,6 +47,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.ospfd] pytestmark = [pytest.mark.ospfd]
class OSPFTopo(Topo): class OSPFTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -47,6 +47,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.ospfd] pytestmark = [pytest.mark.ospfd]
class OSPFTopo(Topo): class OSPFTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -384,15 +384,14 @@ def test_linux_ipv6_kernel_routingTable():
% (i, diff) % (i, diff)
) )
else: else:
logger.error( logger.error("r{} failed - no nhid ref file: {}".format(i, refTableFile))
"r{} failed - no nhid ref file: {}".format(i, refTableFile)
)
assert False, ( assert False, (
"Linux Kernel IPv6 Routing Table verification failed for router r%s\n" "Linux Kernel IPv6 Routing Table verification failed for router r%s\n"
% (i) % (i)
) )
def test_shutdown_check_stderr(): def test_shutdown_check_stderr():
tgen = get_topogen() tgen = get_topogen()

View File

@ -49,15 +49,14 @@ from lib.common_config import (
shutdown_bringup_interface, shutdown_bringup_interface,
topo_daemons, topo_daemons,
verify_rib, verify_rib,
stop_router, start_router, stop_router,
start_router,
create_static_routes, create_static_routes,
start_router_daemons, start_router_daemons,
kill_router_daemons kill_router_daemons,
) )
from lib.ospf import ( from lib.ospf import verify_ospf_neighbor, verify_ospf_rib, create_router_ospf
verify_ospf_neighbor, verify_ospf_rib,
create_router_ospf)
from lib.topolog import logger from lib.topolog import logger
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
@ -69,8 +68,13 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
topo = None topo = None
NETWORK = { NETWORK = {
"ipv4": ["11.0.20.1/32", "11.0.20.2/32", "11.0.20.3/32", "11.0.20.4/32", "ipv4": [
"11.0.20.5/32"] "11.0.20.1/32",
"11.0.20.2/32",
"11.0.20.3/32",
"11.0.20.4/32",
"11.0.20.5/32",
]
} }
""" """
Topology: Topology:
@ -102,6 +106,7 @@ try:
except IOError: except IOError:
assert False, "Could not read file {}".format(jsonFile) assert False, "Could not read file {}".format(jsonFile)
class CreateTopo(Topo): class CreateTopo(Topo):
""" """
Test topology builder. Test topology builder.
@ -190,78 +195,70 @@ def test_ospf_chaos_tc31_p1(request):
step( step(
"Create static routes(10.0.20.1/32) in R1 and redistribute " "Create static routes(10.0.20.1/32) in R1 and redistribute "
"to OSPF using route map.") "to OSPF using route map."
)
# Create Static routes # Create Static routes
input_dict = { input_dict = {
"r0": { "r0": {
"static_routes": [ "static_routes": [
{ {
"network": NETWORK['ipv4'][0], "network": NETWORK["ipv4"][0],
"no_of_ip": 5, "no_of_ip": 5,
"next_hop": 'Null0', "next_hop": "Null0",
} }
] ]
} }
} }
result = create_static_routes(tgen, input_dict) result = create_static_routes(tgen, input_dict)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
ospf_red_r0 = { ospf_red_r0 = {"r0": {"ospf": {"redistribute": [{"redist_type": "static"}]}}}
"r0": {
"ospf": {
"redistribute": [{
"redist_type": "static"
}]
}
}
}
result = create_router_ospf(tgen, topo, ospf_red_r0) result = create_router_ospf(tgen, topo, ospf_red_r0)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
step("Verify OSPF neighbors after base config is done.") step("Verify OSPF neighbors after base config is done.")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step("Verify that route is advertised to R1.") step("Verify that route is advertised to R1.")
dut = 'r1' dut = "r1"
protocol = 'ospf' protocol = "ospf"
nh = topo['routers']['r0']['links']['r1']['ipv4'].split('/')[0] nh = topo["routers"]["r0"]["links"]["r1"]["ipv4"].split("/")[0]
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib( result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
step("Kill OSPFd daemon on R0.") step("Kill OSPFd daemon on R0.")
kill_router_daemons(tgen, "r0", ["ospfd"]) kill_router_daemons(tgen, "r0", ["ospfd"])
step("Verify OSPF neighbors are down after killing ospfd in R0") step("Verify OSPF neighbors are down after killing ospfd in R0")
dut = 'r0' dut = "r0"
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False)
expected=False) assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
assert ospf_covergence is not True, ("setup_module :Failed \n Error:" ospf_covergence
" {}".format(ospf_covergence)) )
step("Verify that route advertised to R1 are deleted from RIB and FIB.") step("Verify that route advertised to R1 are deleted from RIB and FIB.")
dut = 'r1' dut = "r1"
protocol = 'ospf' protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, expected=False) result = verify_ospf_rib(tgen, dut, input_dict, expected=False)
assert result is not True, "Testcase {} : Failed \n Error: {}".format( assert result is not True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result) tc_name, result
)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(
expected=False) tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False
)
assert result is not True, "Testcase {} : Failed \n Error: {}".format( assert result is not True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result) tc_name, result
)
step("Bring up OSPFd daemon on R0.") step("Bring up OSPFd daemon on R0.")
start_router_daemons(tgen, "r0", ["ospfd"]) start_router_daemons(tgen, "r0", ["ospfd"])
@ -269,33 +266,32 @@ def test_ospf_chaos_tc31_p1(request):
step("Verify OSPF neighbors are up after bringing back ospfd in R0") step("Verify OSPF neighbors are up after bringing back ospfd in R0")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step( step(
"All the neighbours are up and routes are installed before the" "All the neighbours are up and routes are installed before the"
" restart. Verify OSPF route table and ip route table.") " restart. Verify OSPF route table and ip route table."
dut = 'r1' )
protocol = 'ospf' dut = "r1"
protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
step("Kill OSPFd daemon on R1.") step("Kill OSPFd daemon on R1.")
kill_router_daemons(tgen, "r1", ["ospfd"]) kill_router_daemons(tgen, "r1", ["ospfd"])
step("Verify OSPF neighbors are down after killing ospfd in R1") step("Verify OSPF neighbors are down after killing ospfd in R1")
dut = 'r1' dut = "r1"
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False)
expected=False) assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
assert ospf_covergence is not True, ("setup_module :Failed \n Error:" ospf_covergence
" {}".format(ospf_covergence)) )
step("Bring up OSPFd daemon on R1.") step("Bring up OSPFd daemon on R1.")
start_router_daemons(tgen, "r1", ["ospfd"]) start_router_daemons(tgen, "r1", ["ospfd"])
@ -303,23 +299,22 @@ def test_ospf_chaos_tc31_p1(request):
step("Verify OSPF neighbors are up after bringing back ospfd in R1") step("Verify OSPF neighbors are up after bringing back ospfd in R1")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step( step(
"All the neighbours are up and routes are installed before the" "All the neighbours are up and routes are installed before the"
" restart. Verify OSPF route table and ip route table.") " restart. Verify OSPF route table and ip route table."
)
dut = 'r1' dut = "r1"
protocol = 'ospf' protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
write_test_footer(tc_name) write_test_footer(tc_name)
@ -335,104 +330,91 @@ def test_ospf_chaos_tc32_p1(request):
step( step(
"Create static routes(10.0.20.1/32) in R1 and redistribute " "Create static routes(10.0.20.1/32) in R1 and redistribute "
"to OSPF using route map.") "to OSPF using route map."
)
# Create Static routes # Create Static routes
input_dict = { input_dict = {
"r0": { "r0": {
"static_routes": [ "static_routes": [
{ {
"network": NETWORK['ipv4'][0], "network": NETWORK["ipv4"][0],
"no_of_ip": 5, "no_of_ip": 5,
"next_hop": 'Null0', "next_hop": "Null0",
} }
] ]
} }
} }
result = create_static_routes(tgen, input_dict) result = create_static_routes(tgen, input_dict)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
ospf_red_r0 = { ospf_red_r0 = {"r0": {"ospf": {"redistribute": [{"redist_type": "static"}]}}}
"r0": {
"ospf": {
"redistribute": [{
"redist_type": "static"
}]
}
}
}
result = create_router_ospf(tgen, topo, ospf_red_r0) result = create_router_ospf(tgen, topo, ospf_red_r0)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
step("Verify OSPF neighbors after base config is done.") step("Verify OSPF neighbors after base config is done.")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step("Verify that route is advertised to R1.") step("Verify that route is advertised to R1.")
dut = 'r1' dut = "r1"
protocol = 'ospf' protocol = "ospf"
nh = topo['routers']['r0']['links']['r1']['ipv4'].split('/')[0] nh = topo["routers"]["r0"]["links"]["r1"]["ipv4"].split("/")[0]
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
step("Restart frr on R0") step("Restart frr on R0")
stop_router(tgen, 'r0') stop_router(tgen, "r0")
start_router(tgen, 'r0') start_router(tgen, "r0")
step("Verify OSPF neighbors are up after restarting R0") step("Verify OSPF neighbors are up after restarting R0")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step( step(
"All the neighbours are up and routes are installed before the" "All the neighbours are up and routes are installed before the"
" restart. Verify OSPF route table and ip route table.") " restart. Verify OSPF route table and ip route table."
dut = 'r1' )
protocol = 'ospf' dut = "r1"
protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
step("Restart frr on R1") step("Restart frr on R1")
stop_router(tgen, 'r1') stop_router(tgen, "r1")
start_router(tgen, 'r1') start_router(tgen, "r1")
step("Verify OSPF neighbors are up after restarting R1") step("Verify OSPF neighbors are up after restarting R1")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step( step(
"All the neighbours are up and routes are installed before the" "All the neighbours are up and routes are installed before the"
" restart. Verify OSPF route table and ip route table.") " restart. Verify OSPF route table and ip route table."
dut = 'r1' )
protocol = 'ospf' dut = "r1"
protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
write_test_footer(tc_name) write_test_footer(tc_name)
@ -453,70 +435,62 @@ def test_ospf_chaos_tc34_p1(request):
step( step(
"Create static routes(10.0.20.1/32) in R1 and redistribute " "Create static routes(10.0.20.1/32) in R1 and redistribute "
"to OSPF using route map.") "to OSPF using route map."
)
# Create Static routes # Create Static routes
input_dict = { input_dict = {
"r0": { "r0": {
"static_routes": [ "static_routes": [
{ {
"network": NETWORK['ipv4'][0], "network": NETWORK["ipv4"][0],
"no_of_ip": 5, "no_of_ip": 5,
"next_hop": 'Null0', "next_hop": "Null0",
} }
] ]
} }
} }
result = create_static_routes(tgen, input_dict) result = create_static_routes(tgen, input_dict)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
ospf_red_r0 = { ospf_red_r0 = {"r0": {"ospf": {"redistribute": [{"redist_type": "static"}]}}}
"r0": {
"ospf": {
"redistribute": [{
"redist_type": "static"
}]
}
}
}
result = create_router_ospf(tgen, topo, ospf_red_r0) result = create_router_ospf(tgen, topo, ospf_red_r0)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
step("Verify OSPF neighbors after base config is done.") step("Verify OSPF neighbors after base config is done.")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step("Verify that route is advertised to R1.") step("Verify that route is advertised to R1.")
dut = 'r1' dut = "r1"
protocol = 'ospf' protocol = "ospf"
nh = topo['routers']['r0']['links']['r1']['ipv4'].split('/')[0] nh = topo["routers"]["r0"]["links"]["r1"]["ipv4"].split("/")[0]
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
step("Kill staticd daemon on R0.") step("Kill staticd daemon on R0.")
kill_router_daemons(tgen, "r0", ["staticd"]) kill_router_daemons(tgen, "r0", ["staticd"])
step("Verify that route advertised to R1 are deleted from RIB and FIB.") step("Verify that route advertised to R1 are deleted from RIB and FIB.")
dut = 'r1' dut = "r1"
protocol = 'ospf' protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, expected=False) result = verify_ospf_rib(tgen, dut, input_dict, expected=False)
assert result is not True, "Testcase {} : Failed \n Error: {}".format( assert result is not True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result) tc_name, result
)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(
expected=False) tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False
)
assert result is not True, "Testcase {} : Failed \n Error: {}".format( assert result is not True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result) tc_name, result
)
step("Bring up staticd daemon on R0.") step("Bring up staticd daemon on R0.")
start_router_daemons(tgen, "r0", ["staticd"]) start_router_daemons(tgen, "r0", ["staticd"])
@ -524,22 +498,21 @@ def test_ospf_chaos_tc34_p1(request):
step("Verify OSPF neighbors are up after bringing back ospfd in R0") step("Verify OSPF neighbors are up after bringing back ospfd in R0")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step( step(
"All the neighbours are up and routes are installed before the" "All the neighbours are up and routes are installed before the"
" restart. Verify OSPF route table and ip route table.") " restart. Verify OSPF route table and ip route table."
dut = 'r1' )
protocol = 'ospf' dut = "r1"
protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
step("Kill staticd daemon on R1.") step("Kill staticd daemon on R1.")
kill_router_daemons(tgen, "r1", ["staticd"]) kill_router_daemons(tgen, "r1", ["staticd"])
@ -550,23 +523,22 @@ def test_ospf_chaos_tc34_p1(request):
step("Verify OSPF neighbors are up after bringing back ospfd in R1") step("Verify OSPF neighbors are up after bringing back ospfd in R1")
# Api call verify whether OSPF is converged # Api call verify whether OSPF is converged
ospf_covergence = verify_ospf_neighbor(tgen, topo) ospf_covergence = verify_ospf_neighbor(tgen, topo)
assert ospf_covergence is True, ("setup_module :Failed \n Error:" assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
" {}".format(ospf_covergence)) ospf_covergence
)
step( step(
"All the neighbours are up and routes are installed before the" "All the neighbours are up and routes are installed before the"
" restart. Verify OSPF route table and ip route table.") " restart. Verify OSPF route table and ip route table."
)
dut = 'r1' dut = "r1"
protocol = 'ospf' protocol = "ospf"
result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh) result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh)
assert result is True, "Testcase {} : Failed \n Error: {}".format( assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
tc_name, result)
result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh)
next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
tc_name, result)
write_test_footer(tc_name) write_test_footer(tc_name)

View File

@ -146,7 +146,6 @@ def setup_module(mod):
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
logger.info("Running setup_module() done") logger.info("Running setup_module() done")
@ -397,10 +396,7 @@ def test_ospf_p2mp_tc1_p0(request):
"links": { "links": {
"r3": { "r3": {
"interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "interface": topo["routers"]["r0"]["links"]["r3"]["interface"],
"ospf": { "ospf": {"area": "0.0.0.0", "networkType": "POINTOMULTIPOINT"},
"area": "0.0.0.0",
"networkType":"POINTOMULTIPOINT"
},
} }
} }
} }

View File

@ -82,6 +82,7 @@ class NetworkTopo(Topo):
## ##
##################################################### #####################################################
def setup_module(module): def setup_module(module):
"Setup topology" "Setup topology"
tgen = Topogen(NetworkTopo, module.__name__) tgen = Topogen(NetworkTopo, module.__name__)

View File

@ -45,6 +45,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.pimd] pytestmark = [pytest.mark.pimd]
class PIMTopo(Topo): class PIMTopo(Topo):
def build(self, *_args, **_opts): def build(self, *_args, **_opts):
"Build function" "Build function"

View File

@ -24,6 +24,7 @@ markers =
sharpd: Tests that run against SHARPD sharpd: Tests that run against SHARPD
staticd: Tests that run against STATICD staticd: Tests that run against STATICD
vrrpd: Tests that run against VRRPD vrrpd: Tests that run against VRRPD
snmp: Tests that run against snmp changes
[topogen] [topogen]
# Default configuration values # Default configuration values

View File

@ -46,6 +46,8 @@ from lib.snmptest import SnmpTester
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from mininet.topo import Topo from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp]
class TemplateTopo(Topo): class TemplateTopo(Topo):
"Test topology builder" "Test topology builder"

View File

@ -35,6 +35,7 @@ import time
import os import os
import pytest import pytest
import platform import platform
# Save the Current Working Directory to find configuration files. # Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__)) CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../"))
@ -44,6 +45,7 @@ sys.path.append(os.path.join(CWD, "../lib/"))
from mininet.topo import Topo from mininet.topo import Topo
from lib.topogen import Topogen, get_topogen from lib.topogen import Topogen, get_topogen
from lib.topotest import version_cmp from lib.topotest import version_cmp
# Import topoJson from lib, to create topology and initial configuration # Import topoJson from lib, to create topology and initial configuration
from lib.common_config import ( from lib.common_config import (
start_topology, start_topology,
@ -121,9 +123,11 @@ def setup_module(mod):
# Creating configuration from JSON # Creating configuration from JSON
build_config_from_json(tgen, topo) build_config_from_json(tgen, topo)
if version_cmp(platform.release(), '4.19') < 0: if version_cmp(platform.release(), "4.19") < 0:
error_msg = ('These tests will not run. (have kernel "{}", ' error_msg = (
'requires kernel >= 4.19)'.format(platform.release())) 'These tests will not run. (have kernel "{}", '
"requires kernel >= 4.19)".format(platform.release())
)
pytest.skip(error_msg) pytest.skip(error_msg)
# Checking BGP convergence # Checking BGP convergence

View File

@ -163,9 +163,11 @@ def setup_module(mod):
# Creating configuration from JSON # Creating configuration from JSON
build_config_from_json(tgen, topo) build_config_from_json(tgen, topo)
if version_cmp(platform.release(), '4.19') < 0: if version_cmp(platform.release(), "4.19") < 0:
error_msg = ('These tests will not run. (have kernel "{}", ' error_msg = (
'requires kernel >= 4.19)'.format(platform.release())) 'These tests will not run. (have kernel "{}", '
"requires kernel >= 4.19)".format(platform.release())
)
pytest.skip(error_msg) pytest.skip(error_msg)
# Checking BGP convergence # Checking BGP convergence
@ -854,12 +856,12 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
write_test_footer(tc_name) write_test_footer(tc_name)
@ -1129,9 +1131,10 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
write_test_footer(tc_name) write_test_footer(tc_name)
@ -1339,7 +1342,15 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request):
" value and all the nexthop populated in RIB and FIB again" " value and all the nexthop populated in RIB and FIB again"
) )
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type],}]}} input_dict_4 = {
"r2": {
"static_routes": [
{
"network": PREFIX1[addr_type],
}
]
}
}
nh = NEXT_HOP_IP["nh1"][addr_type] nh = NEXT_HOP_IP["nh1"][addr_type]
result = verify_rib( result = verify_rib(
tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True
@ -1468,9 +1479,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request):
protocol=protocol, protocol=protocol,
fib=True, fib=True,
) )
assert result is True, ( assert (
"Testcase {} : Failed \nError: Route " result is True
" is missing in RIB".format(tc_name) ), "Testcase {} : Failed \nError: Route " " is missing in RIB".format(
tc_name
) )
write_test_footer(tc_name) write_test_footer(tc_name)

View File

@ -88,6 +88,7 @@ NEXT_HOP_IP = {}
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
class CreateTopo(Topo): class CreateTopo(Topo):
""" """
Test CreateTopo - topology 1. Test CreateTopo - topology 1.
@ -126,9 +127,11 @@ def setup_module(mod):
# Creating configuration from JSON # Creating configuration from JSON
build_config_from_json(tgen, topo) build_config_from_json(tgen, topo)
if version_cmp(platform.release(), '4.19') < 0: if version_cmp(platform.release(), "4.19") < 0:
error_msg = ('These tests will not run. (have kernel "{}", ' error_msg = (
'requires kernel >= 4.19)'.format(platform.release())) 'These tests will not run. (have kernel "{}", '
"requires kernel >= 4.19)".format(platform.release())
)
pytest.skip(error_msg) pytest.skip(error_msg)
# Checking BGP convergence # Checking BGP convergence

View File

@ -125,9 +125,11 @@ def setup_module(mod):
# Creating configuration from JSON # Creating configuration from JSON
build_config_from_json(tgen, topo) build_config_from_json(tgen, topo)
if version_cmp(platform.release(), '4.19') < 0: if version_cmp(platform.release(), "4.19") < 0:
error_msg = ('These tests will not run. (have kernel "{}", ' error_msg = (
'requires kernel >= 4.19)'.format(platform.release())) 'These tests will not run. (have kernel "{}", '
"requires kernel >= 4.19)".format(platform.release())
)
pytest.skip(error_msg) pytest.skip(error_msg)
# Checking BGP convergence # Checking BGP convergence

View File

@ -165,9 +165,11 @@ def setup_module(mod):
# Creating configuration from JSON # Creating configuration from JSON
build_config_from_json(tgen, topo) build_config_from_json(tgen, topo)
if version_cmp(platform.release(), '4.19') < 0: if version_cmp(platform.release(), "4.19") < 0:
error_msg = ('These tests will not run. (have kernel "{}", ' error_msg = (
'requires kernel >= 4.19)'.format(platform.release())) 'These tests will not run. (have kernel "{}", '
"requires kernel >= 4.19)".format(platform.release())
)
pytest.skip(error_msg) pytest.skip(error_msg)
# Checking BGP convergence # Checking BGP convergence
@ -884,9 +886,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
step("BGP neighbor remove and add") step("BGP neighbor remove and add")
@ -907,9 +910,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
dut = "r3" dut = "r3"
@ -917,9 +921,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
step("Remove the redistribute static knob") step("Remove the redistribute static knob")
@ -1274,9 +1279,10 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
step("BGP neighbor remove and add") step("BGP neighbor remove and add")
@ -1297,9 +1303,10 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
dut = "r3" dut = "r3"
@ -1307,9 +1314,10 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request):
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}} input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type]}]}}
result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol) result = verify_rib(tgen, addr_type, dut, input_dict_4, protocol=protocol)
assert result is True, ( assert (
"Testcase {} : Failed \n" result is True
"Error: Routes are still present in RIB".format(tc_name) ), "Testcase {} : Failed \n" "Error: Routes are still present in RIB".format(
tc_name
) )
step("Remove the redistribute static knob") step("Remove the redistribute static knob")
@ -1557,7 +1565,15 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request):
" value and all the nexthop populated in RIB and FIB again" " value and all the nexthop populated in RIB and FIB again"
) )
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
input_dict_4 = {"r2": {"static_routes": [{"network": PREFIX1[addr_type],}]}} input_dict_4 = {
"r2": {
"static_routes": [
{
"network": PREFIX1[addr_type],
}
]
}
}
nh = NEXT_HOP_IP["nh1"][addr_type] nh = NEXT_HOP_IP["nh1"][addr_type]
result = verify_rib( result = verify_rib(
tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True tgen, addr_type, dut, input_dict_4, next_hop=nh, protocol=protocol, fib=True
@ -1686,9 +1702,10 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request):
protocol=protocol, protocol=protocol,
fib=True, fib=True,
) )
assert result is True, ( assert (
"Testcase {} : Failed \nError: Route " result is True
" is missing in RIB".format(tc_name) ), "Testcase {} : Failed \nError: Route " " is missing in RIB".format(
tc_name
) )
step("Remove the redistribute static knob") step("Remove the redistribute static knob")

View File

@ -149,9 +149,11 @@ def setup_module(mod):
# Creating configuration from JSON # Creating configuration from JSON
build_config_from_json(tgen, topo) build_config_from_json(tgen, topo)
if version_cmp(platform.release(), '4.19') < 0: if version_cmp(platform.release(), "4.19") < 0:
error_msg = ('These tests will not run. (have kernel "{}", ' error_msg = (
'requires kernel >= 4.19)'.format(platform.release())) 'These tests will not run. (have kernel "{}", '
"requires kernel >= 4.19)".format(platform.release())
)
pytest.skip(error_msg) pytest.skip(error_msg)
# Checking BGP convergence # Checking BGP convergence

View File

@ -69,6 +69,7 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
from lib.topotest import version_cmp from lib.topotest import version_cmp
# Reading the data from JSON File for topology creation # Reading the data from JSON File for topology creation
jsonFile = "{}/static_routes_topo4_ibgp.json".format(CWD) jsonFile = "{}/static_routes_topo4_ibgp.json".format(CWD)
try: try:
@ -85,6 +86,7 @@ NEXT_HOP_IP = {}
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
class CreateTopo(Topo): class CreateTopo(Topo):
""" """
Test CreateTopo - topology 1. Test CreateTopo - topology 1.
@ -123,9 +125,11 @@ def setup_module(mod):
# Creating configuration from JSON # Creating configuration from JSON
build_config_from_json(tgen, topo) build_config_from_json(tgen, topo)
if version_cmp(platform.release(), '4.19') < 0: if version_cmp(platform.release(), "4.19") < 0:
error_msg = ('These tests will not run. (have kernel "{}", ' error_msg = (
'requires kernel >= 4.19)'.format(platform.release())) 'These tests will not run. (have kernel "{}", '
"requires kernel >= 4.19)".format(platform.release())
)
pytest.skip(error_msg) pytest.skip(error_msg)
# Checking BGP convergence # Checking BGP convergence

View File

@ -76,9 +76,11 @@ def setup_module(mod):
router_list = tgen.routers() router_list = tgen.routers()
for rname, router in router_list.items(): for rname, router in router_list.items():
router.load_config( router.load_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))) TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
)
router.load_config( router.load_config(
TopoRouter.RD_SHARP, os.path.join(CWD, "{}/sharpd.conf".format(rname))) TopoRouter.RD_SHARP, os.path.join(CWD, "{}/sharpd.conf".format(rname))
)
# Initialize all routers. # Initialize all routers.
tgen.start_router() tgen.start_router()
@ -159,6 +161,7 @@ def test_zebra_kernel_override():
_, result = topotest.run_and_expect(test_func, None, count=2, wait=0.5) _, result = topotest.run_and_expect(test_func, None, count=2, wait=0.5)
assert result is None, '"r1" JSON output mismatches' assert result is None, '"r1" JSON output mismatches'
def test_route_map_usage(): def test_route_map_usage():
"Test that FRR only reruns over routes associated with the routemap" "Test that FRR only reruns over routes associated with the routemap"
logger.info("Test that FRR runs on selected re's on route-map changes") logger.info("Test that FRR runs on selected re's on route-map changes")
@ -174,7 +177,9 @@ def test_route_map_usage():
r1.vtysh_cmd("conf\nroute-map static permit 10\nset src 192.168.215.1") r1.vtysh_cmd("conf\nroute-map static permit 10\nset src 192.168.215.1")
r1.vtysh_cmd("conf\naccess-list 5 seq 5 permit 10.0.0.44/32") r1.vtysh_cmd("conf\naccess-list 5 seq 5 permit 10.0.0.44/32")
r1.vtysh_cmd("conf\naccess-list 10 seq 5 permit 10.0.1.0/24") r1.vtysh_cmd("conf\naccess-list 10 seq 5 permit 10.0.1.0/24")
r1.vtysh_cmd("conf\nroute-map sharp permit 10\nmatch ip address 10\nset src 192.168.214.1") r1.vtysh_cmd(
"conf\nroute-map sharp permit 10\nmatch ip address 10\nset src 192.168.214.1"
)
r1.vtysh_cmd("conf\nroute-map sharp permit 20\nset src 192.168.213.1") r1.vtysh_cmd("conf\nroute-map sharp permit 20\nset src 192.168.213.1")
r1.vtysh_cmd("conf\nip protocol static route-map static") r1.vtysh_cmd("conf\nip protocol static route-map static")
r1.vtysh_cmd("conf\nip protocol sharp route-map sharp") r1.vtysh_cmd("conf\nip protocol sharp route-map sharp")
@ -186,47 +191,57 @@ def test_route_map_usage():
static_rmapfile = "%s/r1/static_rmap.ref" % (thisDir) static_rmapfile = "%s/r1/static_rmap.ref" % (thisDir)
expected = open(static_rmapfile).read().rstrip() expected = open(static_rmapfile).read().rstrip()
expected = ('\n'.join(expected.splitlines()) + '\n').rstrip() expected = ("\n".join(expected.splitlines()) + "\n").rstrip()
actual = r1.vtysh_cmd("show route-map static") actual = r1.vtysh_cmd("show route-map static")
actual = ('\n'.join(actual.splitlines()) + '\n').rstrip() actual = ("\n".join(actual.splitlines()) + "\n").rstrip()
logger.info("Does the show route-map static command run the correct number of times") logger.info(
"Does the show route-map static command run the correct number of times"
)
diff = topotest.get_textdiff(actual, expected, diff = topotest.get_textdiff(
title1 = "Actual Route-map output", actual,
title2 = "Expected Route-map output") expected,
title1="Actual Route-map output",
title2="Expected Route-map output",
)
if diff: if diff:
logger.info("Actual:") logger.info("Actual:")
logger.info(actual) logger.info(actual)
logger.info("Expected:") logger.info("Expected:")
logger.info(expected) logger.info(expected)
srun = r1.vtysh_cmd("show run") srun = r1.vtysh_cmd("show run")
srun = ('\n'.join(srun.splitlines()) + '\n').rstrip() srun = ("\n".join(srun.splitlines()) + "\n").rstrip()
logger.info("Show run") logger.info("Show run")
logger.info(srun) logger.info(srun)
assert 0, "r1 static route processing:\n" assert 0, "r1 static route processing:\n"
sharp_rmapfile = "%s/r1/sharp_rmap.ref" % (thisDir) sharp_rmapfile = "%s/r1/sharp_rmap.ref" % (thisDir)
expected = open(sharp_rmapfile).read().rstrip() expected = open(sharp_rmapfile).read().rstrip()
expected = ('\n'.join(expected.splitlines()) + '\n').rstrip() expected = ("\n".join(expected.splitlines()) + "\n").rstrip()
actual = r1.vtysh_cmd("show route-map sharp") actual = r1.vtysh_cmd("show route-map sharp")
actual = ('\n'.join(actual.splitlines()) + '\n').rstrip() actual = ("\n".join(actual.splitlines()) + "\n").rstrip()
logger.info("Does the show route-map sharp command run the correct number of times") logger.info("Does the show route-map sharp command run the correct number of times")
diff = topotest.get_textdiff(actual, expected, diff = topotest.get_textdiff(
title1 = "Actual Route-map output", actual,
title2 = "Expected Route-map output") expected,
title1="Actual Route-map output",
title2="Expected Route-map output",
)
if diff: if diff:
logger.info("Actual:") logger.info("Actual:")
logger.info(actual) logger.info(actual)
logger.info("Expected:") logger.info("Expected:")
logger.info(expected) logger.info(expected)
srun = r1.vtysh_cmd("show run") srun = r1.vtysh_cmd("show run")
srun = ('\n'.join(srun.splitlines()) + '\n').rstrip() srun = ("\n".join(srun.splitlines()) + "\n").rstrip()
logger.info("Show run:") logger.info("Show run:")
logger.info(srun) logger.info(srun)
assert 0, "r1 sharp route-map processing:\n" assert 0, "r1 sharp route-map processing:\n"
logger.info("Add a extension to the static route-map to see the static route go away") logger.info(
"Add a extension to the static route-map to see the static route go away"
)
r1.vtysh_cmd("conf\nroute-map sharp deny 5\nmatch ip address 5") r1.vtysh_cmd("conf\nroute-map sharp deny 5\nmatch ip address 5")
sleep(2) sleep(2)
# we are only checking the kernel here as that this will give us the implied # we are only checking the kernel here as that this will give us the implied
@ -236,9 +251,9 @@ def test_route_map_usage():
logger.info("Test that the routes installed are correct") logger.info("Test that the routes installed are correct")
sharp_ipfile = "%s/r1/iproute.ref" % (thisDir) sharp_ipfile = "%s/r1/iproute.ref" % (thisDir)
expected = open(sharp_ipfile).read().rstrip() expected = open(sharp_ipfile).read().rstrip()
expected = ('\n'.join(expected.splitlines()) + '\n').rstrip() expected = ("\n".join(expected.splitlines()) + "\n").rstrip()
actual = r1.run("ip route show") actual = r1.run("ip route show")
actual = ('\n'.join(actual.splitlines()) + '\n').rstrip() actual = ("\n".join(actual.splitlines()) + "\n").rstrip()
actual = re.sub(r" nhid [0-9][0-9]", "", actual) actual = re.sub(r" nhid [0-9][0-9]", "", actual)
actual = re.sub(r" proto sharp", " proto XXXX", actual) actual = re.sub(r" proto sharp", " proto XXXX", actual)
actual = re.sub(r" proto static", " proto XXXX", actual) actual = re.sub(r" proto static", " proto XXXX", actual)
@ -250,9 +265,9 @@ def test_route_map_usage():
actual = re.sub(r" proto XXXX ", " proto XXXX ", actual) actual = re.sub(r" proto XXXX ", " proto XXXX ", actual)
actual = re.sub(r" metric", " metric", actual) actual = re.sub(r" metric", " metric", actual)
actual = re.sub(r" link ", " link ", actual) actual = re.sub(r" link ", " link ", actual)
diff = topotest.get_textdiff(actual, expected, diff = topotest.get_textdiff(
title1 = "Actual ip route show", actual, expected, title1="Actual ip route show", title2="Expected ip route show"
title2 = "Expected ip route show") )
if diff: if diff:
logger.info("Actual:") logger.info("Actual:")
@ -260,11 +275,12 @@ def test_route_map_usage():
logger.info("Expected:") logger.info("Expected:")
logger.info(expected) logger.info(expected)
srun = r1.vtysh_cmd("show run") srun = r1.vtysh_cmd("show run")
srun = ('\n'.join(srun.splitlines()) + '\n').rstrip() srun = ("\n".join(srun.splitlines()) + "\n").rstrip()
logger.info("Show run:") logger.info("Show run:")
logger.info(srun) logger.info(srun)
assert 0, "r1 ip route show is not correct:" assert 0, "r1 ip route show is not correct:"
def test_memory_leak(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."
tgen = get_topogen() tgen = get_topogen()