diff options
Diffstat (limited to 'tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py')
| -rw-r--r-- | tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py | 50 |
1 files changed, 9 insertions, 41 deletions
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py index 0172f589c5..7c09e71ef8 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py @@ -26,7 +26,6 @@ import os import sys import time import pytest -import json from copy import deepcopy from ipaddress import IPv4Address @@ -37,9 +36,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo from lib.topogen import Topogen, get_topogen -import ipaddress # Import topoJson from lib, to create topology and initial configuration from lib.common_config import ( @@ -47,40 +44,24 @@ from lib.common_config import ( write_test_header, write_test_footer, reset_config_on_routers, - verify_rib, - create_static_routes, step, - create_route_maps, - shutdown_bringup_interface, create_interfaces_cfg, topo_daemons, ) from lib.topolog import logger -from lib.topojson import build_topo_from_json, build_config_from_json +from lib.topojson import build_config_from_json +from lib.topotest import frr_unicode from lib.ospf import ( - verify_ospf_neighbor, - config_ospf_interface, - clear_ospf, - verify_ospf_rib, - create_router_ospf, verify_ospf_interface, - verify_ospf_database, ) -pytestmark = [pytest.mark.ospfd, pytest.mark.staticd] +pytestmark = [pytest.mark.ospfd, pytest.mark.staticd] # Global variables topo = None -# Reading the data from JSON File for topology creation -jsonFile = "{}/ospf_p2mp.json".format(CWD) -try: - with open(jsonFile, "r") as topoJson: - topo = json.load(topoJson) -except IOError: - assert False, "Could not read file {}".format(jsonFile) """ TOPOOLOGY = @@ -103,28 +84,12 @@ TESTCASES = """ -class CreateTopo(Topo): - """ - Test topology builder. - - * `Topo`: Topology object - """ - - def build(self, *_args, **_opts): - """Build function.""" - tgen = get_topogen(self) - - # Building topology from json file - build_topo_from_json(tgen, topo) - - def setup_module(mod): """ Sets up the pytest environment * `mod`: module name """ - global topo testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("=" * 40) @@ -132,7 +97,10 @@ def setup_module(mod): logger.info("Running setup_module to create topology") # This function initiates the topology build with Topogen... - tgen = Topogen(CreateTopo, mod.__name__) + json_file = "{}/ospf_p2mp.json".format(CWD) + tgen = Topogen(json_file, mod.__name__) + global topo + topo = tgen.json_topo # ... and here it calls Mininet initialization functions. # get list of daemons needs to be started for this suite. @@ -228,7 +196,7 @@ def test_ospf_p2mp_tc1_p0(request): topo_modify_change_ip = deepcopy(topo) intf_ip = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] = str( - IPv4Address(unicode(intf_ip.split("/")[0])) + 3 + IPv4Address(frr_unicode(intf_ip.split("/")[0])) + 3 ) + "/{}".format(intf_ip.split("/")[1]) build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False) @@ -279,7 +247,7 @@ def test_ospf_p2mp_tc1_p0(request): topo_modify_change_ip = deepcopy(topo) intf_ip = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv4"] = str( - IPv4Address(unicode(intf_ip.split("/")[0])) + 3 + IPv4Address(frr_unicode(intf_ip.split("/")[0])) + 3 ) + "/{}".format(int(intf_ip.split("/")[1]) + 1) build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False) |
