summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2021-07-29 11:38:55 +0200
committerChristian Hopps <chopps@labn.net>2021-09-04 15:04:46 +0200
commite82b531df94b9fd7bc456df8a1b7c58f2770eff9 (patch)
treec5b8812d719c905bec58db38a2f0800be675c0e5 /tests
parenttests: fix pylint test errors (diff)
downloadfrr-e82b531df94b9fd7bc456df8a1b7c58f2770eff9.tar.xz
frr-e82b531df94b9fd7bc456df8a1b7c58f2770eff9.zip
tests: remove legacy Topo class (fixes many pylint errors)
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/all_protocol_startup/test_all_protocol_startup.py86
-rw-r--r--tests/topotests/bfd_topo2/test_bfd_topo2.py23
-rw-r--r--tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py34
-rw-r--r--tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py17
-rw-r--r--tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py17
-rw-r--r--tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py30
-rw-r--r--tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py21
-rw-r--r--tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py18
-rw-r--r--tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py19
-rw-r--r--tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py21
-rw-r--r--tests/topotests/bgp_auth/test_bgp_auth.py114
-rw-r--r--tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py27
-rw-r--r--tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py29
-rw-r--r--tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py17
-rw-r--r--tests/topotests/bgp_communities_topo1/test_bgp_communities.py28
-rw-r--r--tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py28
-rw-r--r--tests/topotests/bgp_community_alias/test_bgp-community-alias.py16
-rw-r--r--tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py89
-rw-r--r--tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py25
-rw-r--r--tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py20
-rw-r--r--tests/topotests/bgp_default_route/test_bgp_default-originate.py17
-rw-r--r--tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py17
-rw-r--r--tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py17
-rw-r--r--tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py17
-rw-r--r--tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py17
-rw-r--r--tests/topotests/bgp_disable_addpath_rx/r1/bgpd.conf2
-rw-r--r--tests/topotests/bgp_disable_addpath_rx/r2/bgpd.conf4
-rw-r--r--tests/topotests/bgp_disable_addpath_rx/r3/bgpd.conf2
-rw-r--r--tests/topotests/bgp_disable_addpath_rx/r4/bgpd.conf2
-rw-r--r--tests/topotests/bgp_disable_addpath_rx/test_disable_addpath_rx.py28
-rw-r--r--tests/topotests/bgp_distance_change/test_bgp_distance_change.py17
-rw-r--r--tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py18
-rw-r--r--tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py34
-rw-r--r--tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py46
-rw-r--r--tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py28
-rw-r--r--tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py28
-rw-r--r--tests/topotests/bgp_ecmp_topo3/test_ibgp_ecmp_topo3.py56
-rw-r--r--tests/topotests/bgp_evpn_mh/test_evpn_mh.py207
-rwxr-xr-xtests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py36
-rw-r--r--tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py27
-rwxr-xr-xtests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py72
-rw-r--r--tests/topotests/bgp_features/test_bgp_features.py78
-rw-r--r--tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py28
-rw-r--r--tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py36
-rw-r--r--tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py35
-rw-r--r--tests/topotests/bgp_gshut/test_bgp_gshut.py35
-rw-r--r--tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py36
-rw-r--r--tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py35
-rw-r--r--tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_ibgp_nbr.py28
-rw-r--r--tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_nbr.py28
-rw-r--r--tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_unnumbered_nbr.py28
-rw-r--r--tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_nbr.py28
-rw-r--r--tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_unnumbered_nbr.py28
-rw-r--r--tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py22
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py80
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py92
-rw-r--r--tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py28
-rw-r--r--tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py30
-rw-r--r--tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py99
-rwxr-xr-xtests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py23
-rw-r--r--tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py23
-rw-r--r--tests/topotests/bgp_lu_topo1/test_bgp_lu.py42
-rw-r--r--tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py17
-rw-r--r--tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py17
-rwxr-xr-xtests/topotests/bgp_minimum_holdtime/test_bgp_minimum_holdtime.py17
-rw-r--r--tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py28
-rw-r--r--tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py28
-rw-r--r--tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py278
-rw-r--r--tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py30
-rw-r--r--tests/topotests/bgp_peer_group/test_bgp_peer-group.py19
-rwxr-xr-xtests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py42
-rw-r--r--tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py30
-rw-r--r--tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py32
-rwxr-xr-xtests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py24
-rw-r--r--tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py28
-rw-r--r--tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py23
-rw-r--r--tests/topotests/bgp_rfapi_basic_sanity/customize.py54
-rw-r--r--tests/topotests/bgp_rmap_extcommunity_none/test_bgp_rmap_extcommunity_none.py18
-rw-r--r--tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py30
-rw-r--r--tests/topotests/bgp_route_map/test_route_map_topo1.py28
-rw-r--r--tests/topotests/bgp_route_map/test_route_map_topo2.py31
-rw-r--r--tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py59
-rw-r--r--tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py23
-rw-r--r--tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py19
-rwxr-xr-xtests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py136
-rwxr-xr-xtests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py38
-rw-r--r--tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py23
-rw-r--r--tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py17
-rw-r--r--tests/topotests/bgp_update_delay/test_bgp_update_delay.py36
-rw-r--r--tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py31
-rw-r--r--tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py18
-rw-r--r--tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py22
-rw-r--r--tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py30
-rw-r--r--tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py13
-rw-r--r--tests/topotests/config_timing/test_config_timing.py12
-rw-r--r--tests/topotests/eigrp_topo1/test_eigrp_topo1.py47
-rw-r--r--tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py65
-rw-r--r--tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py31
-rw-r--r--tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py17
-rw-r--r--tests/topotests/example_test/test_template.py59
-rwxr-xr-xtests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py32
-rwxr-xr-xtests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py32
-rwxr-xr-xtests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py32
-rwxr-xr-xtests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py2
-rwxr-xr-xtests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py64
-rwxr-xr-xtests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py2
-rwxr-xr-xtests/topotests/isis_snmp/test_isis_snmp.py62
-rwxr-xr-xtests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py82
-rw-r--r--tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py76
-rwxr-xr-xtests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py2
-rw-r--r--tests/topotests/isis_topo1/test_isis_topo1.py72
-rw-r--r--tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py72
-rw-r--r--tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py46
-rw-r--r--tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py46
-rw-r--r--tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py62
-rw-r--r--tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py62
-rw-r--r--tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py62
-rw-r--r--tests/topotests/ldp_topo1/test_ldp_topo1.py132
-rw-r--r--tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py62
-rw-r--r--tests/topotests/lib/ltemplate.py2
-rw-r--r--tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py46
-rwxr-xr-xtests/topotests/msdp_topo1/test_msdp_topo1.py60
-rw-r--r--tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py30
-rw-r--r--tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py27
-rwxr-xr-xtests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py33
-rwxr-xr-xtests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py30
-rwxr-xr-xtests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py30
-rwxr-xr-xtests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py28
-rwxr-xr-xtests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py20
-rw-r--r--tests/topotests/nhrp_topo/test_nhrp_topo.py39
-rw-r--r--tests/topotests/ospf6_topo1/test_ospf6_topo1.py75
-rwxr-xr-xtests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py74
-rw-r--r--tests/topotests/ospf6_topo2/test_ospf6_topo2.py34
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py28
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py28
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_authentication.py28
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_chaos.py29
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py29
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py29
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_lan.py28
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_nssa.py28
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py30
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py28
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py29
-rw-r--r--tests/topotests/ospf_basic_functionality/test_ospf_single_area.py28
-rw-r--r--tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py24
-rw-r--r--tests/topotests/ospf_gr_helper/test_ospf_gr_helper.py31
-rwxr-xr-xtests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py70
-rwxr-xr-xtests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py82
-rw-r--r--tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py76
-rw-r--r--tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py32
-rw-r--r--tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py52
-rw-r--r--tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py56
-rw-r--r--tests/topotests/ospf_topo1/test_ospf_topo1.py58
-rw-r--r--tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py44
-rw-r--r--tests/topotests/ospf_topo2/test_ospf_topo2.py36
-rw-r--r--tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py28
-rw-r--r--tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py29
-rw-r--r--tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py28
-rw-r--r--tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py29
-rw-r--r--tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py29
-rw-r--r--tests/topotests/pbr_topo1/test_pbr_topo1.py24
-rw-r--r--tests/topotests/pim_basic/test_pim.py74
-rw-r--r--tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py34
-rw-r--r--tests/topotests/rip_topo1/test_rip_topo1.py110
-rw-r--r--tests/topotests/ripng_topo1/test_ripng_topo1.py105
-rw-r--r--tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py32
-rw-r--r--tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py28
-rw-r--r--tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py29
-rw-r--r--tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py30
-rw-r--r--tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py29
-rw-r--r--tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py28
-rw-r--r--tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py29
-rw-r--r--tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py28
174 files changed, 2503 insertions, 4356 deletions
diff --git a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
index 41597c449..52526e0c7 100644
--- a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
+++ b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
@@ -34,8 +34,6 @@ import pytest
import glob
from time import sleep
-from lib.micronet_compat import Mininet, Topo
-
from functools import partial
pytestmark = [
@@ -50,6 +48,7 @@ pytestmark = [
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest
+from lib.topogen import Topogen, get_topogen
fatal_error = ""
@@ -61,24 +60,10 @@ fatal_error = ""
#####################################################
-class NetworkTopo(Topo):
- "All Protocol Startup Test"
-
- def build(self, **_opts):
-
- # Setup Routers
- router = {}
- #
- # Setup Main Router
- router[1] = topotest.addRouter(self, "r1")
- #
-
- # Setup Switches
- switch = {}
- #
- for i in range(0, 10):
- switch[i] = self.addSwitch("sw%s" % i)
- self.addLink(switch[i], router[1], intfName2="r1-eth%s" % i)
+def build_topo(tgen):
+ router = tgen.add_router("r1")
+ for i in range(0, 10):
+ tgen.add_switch("sw%d" % i).add_link(router)
#####################################################
@@ -89,21 +74,16 @@ class NetworkTopo(Topo):
def setup_module(module):
- global topo, net
global fatal_error
print("\n\n** %s: Setup Topology" % module.__name__)
print("******************************************\n")
- print("Cleanup old Mininet runs")
- os.system("sudo mn -c > /dev/null 2>&1")
- os.system("sudo rm /tmp/r* > /dev/null 2>&1")
-
thisDir = os.path.dirname(os.path.realpath(__file__))
- topo = NetworkTopo()
+ tgen = Topogen(build_topo, module.__name__)
+ tgen.start_topology()
- net = Mininet(controller=None, topo=topo)
- net.start()
+ net = tgen.net
if net["r1"].get_routertype() != "frr":
fatal_error = "Test is only implemented for FRR"
@@ -133,25 +113,22 @@ def setup_module(module):
net["r%s" % i].loadConf("nhrpd", "%s/r%s/nhrpd.conf" % (thisDir, i))
net["r%s" % i].loadConf("babeld", "%s/r%s/babeld.conf" % (thisDir, i))
net["r%s" % i].loadConf("pbrd", "%s/r%s/pbrd.conf" % (thisDir, i))
- net["r%s" % i].startRouter()
+ tgen.gears["r%s" % i].start()
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def teardown_module(module):
- global net
-
print("\n\n** %s: Shutdown Topology" % module.__name__)
print("******************************************\n")
-
- # End - Shutdown network
- net.stop()
+ tgen = get_topogen()
+ tgen.stop_topology()
def test_router_running():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -172,7 +149,7 @@ def test_router_running():
def test_error_messages_vtysh():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -228,7 +205,7 @@ def test_error_messages_vtysh():
def test_error_messages_daemons():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -319,7 +296,7 @@ def test_error_messages_daemons():
def test_converge_protocols():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -408,6 +385,7 @@ def test_converge_protocols():
def route_get_nhg_id(route_str):
+ net = get_topogen().net
output = net["r1"].cmd('vtysh -c "show ip route %s nexthop-group"' % route_str)
match = re.search(r"Nexthop Group ID: (\d+)", output)
assert match is not None, (
@@ -419,6 +397,7 @@ def route_get_nhg_id(route_str):
def verify_nexthop_group(nhg_id, recursive=False, ecmp=0):
+ net = get_topogen().net
# Verify NHG is valid/installed
output = net["r1"].cmd('vtysh -c "show nexthop-group rib %d"' % nhg_id)
@@ -457,7 +436,7 @@ def verify_route_nexthop_group(route_str, recursive=False, ecmp=0):
def test_nexthop_groups():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -606,7 +585,7 @@ def test_nexthop_groups():
def test_rip_status():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -666,7 +645,7 @@ def test_rip_status():
def test_ripng_status():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -733,7 +712,7 @@ def test_ripng_status():
def test_ospfv2_interfaces():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -818,7 +797,7 @@ def test_ospfv2_interfaces():
def test_isis_interfaces():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -884,7 +863,7 @@ def test_isis_interfaces():
def test_bgp_summary():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1045,7 +1024,7 @@ def test_bgp_summary():
def test_bgp_ipv6_summary():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1140,6 +1119,7 @@ def test_bgp_ipv6_summary():
def test_nht():
+ net = get_topogen().net
print("\n\n**** Test that nexthop tracking is at least nominally working ****\n")
thisDir = os.path.dirname(os.path.realpath(__file__))
@@ -1188,7 +1168,7 @@ def test_nht():
def test_bgp_ipv4():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1258,7 +1238,7 @@ def test_bgp_ipv4():
def test_bgp_ipv6():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1327,7 +1307,7 @@ def test_bgp_ipv6():
def test_route_map():
global fatal_error
- global net
+ net = get_topogen().net
if fatal_error != "":
pytest.skip(fatal_error)
@@ -1370,7 +1350,7 @@ def test_route_map():
def test_nexthop_groups_with_route_maps():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1467,7 +1447,7 @@ def test_nexthop_groups_with_route_maps():
def test_nexthop_group_replace():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1500,7 +1480,7 @@ def test_nexthop_group_replace():
def test_mpls_interfaces():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1569,7 +1549,7 @@ def test_mpls_interfaces():
def test_shutdown_check_stderr():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -1632,7 +1612,7 @@ def test_shutdown_check_stderr():
def test_shutdown_check_memleak():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
diff --git a/tests/topotests/bfd_topo2/test_bfd_topo2.py b/tests/topotests/bfd_topo2/test_bfd_topo2.py
index 00431ea1f..57ce0cdf0 100644
--- a/tests/topotests/bfd_topo2/test_bfd_topo2.py
+++ b/tests/topotests/bfd_topo2/test_bfd_topo2.py
@@ -46,28 +46,6 @@ from lib.topolog import logger
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.ospfd]
-def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # Create 4 routers.
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
-
-
-
def setup_module(mod):
"Sets up the pytest environment"
topodef = {
@@ -76,7 +54,6 @@ def setup_module(mod):
"s3": ("r2", "r4"),
}
tgen = Topogen(topodef, mod.__name__)
- # tgen = Topogen(build, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py b/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py
index 125cc183c..06b20c443 100644
--- a/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py
+++ b/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py
@@ -49,33 +49,27 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd]
-class BFDTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(BFDTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py b/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py
index 4fa6828ef..517154987 100644
--- a/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py
+++ b/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py
@@ -50,20 +50,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py b/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py
index f4b988954..74c9e83ce 100644
--- a/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py
+++ b/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py
@@ -53,20 +53,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py b/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py
index 6566a860b..4e82a61e1 100644
--- a/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py
+++ b/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py
@@ -45,27 +45,25 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class BgpAggregateAddressTopo1(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
-
- r1 = tgen.add_router("r1")
- r2 = tgen.add_router("r2")
- peer1 = tgen.add_exabgp_peer(
- "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
- )
- switch = tgen.add_switch("s1")
- switch.add_link(r1)
- switch.add_link(peer1)
+def build_topo(tgen):
+ r1 = tgen.add_router("r1")
+ r2 = tgen.add_router("r2")
+ peer1 = tgen.add_exabgp_peer(
+ "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
+ )
+
+ switch = tgen.add_switch("s1")
+ switch.add_link(r1)
+ switch.add_link(peer1)
- switch = tgen.add_switch("s2")
- switch.add_link(r1)
- switch.add_link(r2)
+ switch = tgen.add_switch("s2")
+ switch.add_link(r1)
+ switch.add_link(r2)
def setup_module(mod):
- tgen = Topogen(BgpAggregateAddressTopo1, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router = tgen.gears["r1"]
diff --git a/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py b/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py
index 99c31a355..76eafbce4 100644
--- a/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py
+++ b/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py
@@ -43,22 +43,19 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class BgpAggregatorAsnZero(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
-
- r1 = tgen.add_router("r1")
- peer1 = tgen.add_exabgp_peer(
- "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
- )
+def build_topo(tgen):
+ r1 = tgen.add_router("r1")
+ peer1 = tgen.add_exabgp_peer(
+ "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
+ )
- switch = tgen.add_switch("s1")
- switch.add_link(r1)
- switch.add_link(peer1)
+ switch = tgen.add_switch("s1")
+ switch.add_link(r1)
+ switch.add_link(peer1)
def setup_module(mod):
- tgen = Topogen(BgpAggregatorAsnZero, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router = tgen.gears["r1"]
diff --git a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py
index 4c0142fd0..5613b75d7 100644
--- a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py
+++ b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py
@@ -94,19 +94,11 @@ NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
-class BGPALLOWASIN(Topo):
- """
- Test BGPALLOWASIN - topology 1
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- """Build function"""
- tgen = get_topogen(self)
+def build_topo(tgen):
+ """Build function"""
- # Building topology from json file
- build_topo_from_json(tgen, topo)
+ # Building topology from json file
+ build_topo_from_json(tgen, topo)
def setup_module(mod):
@@ -128,7 +120,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(BGPALLOWASIN, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py b/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py
index 046f3f80a..2f7a9cc58 100644
--- a/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py
+++ b/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py
@@ -48,21 +48,18 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py b/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py
index 3c264a7da..875ff38d8 100644
--- a/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py
+++ b/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py
@@ -43,22 +43,19 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class BgpAggregatorAsnZero(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ r1 = tgen.add_router("r1")
+ peer1 = tgen.add_exabgp_peer(
+ "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
+ )
- r1 = tgen.add_router("r1")
- peer1 = tgen.add_exabgp_peer(
- "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
- )
-
- switch = tgen.add_switch("s1")
- switch.add_link(r1)
- switch.add_link(peer1)
+ switch = tgen.add_switch("s1")
+ switch.add_link(r1)
+ switch.add_link(peer1)
def setup_module(mod):
- tgen = Topogen(BgpAggregatorAsnZero, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router = tgen.gears["r1"]
diff --git a/tests/topotests/bgp_auth/test_bgp_auth.py b/tests/topotests/bgp_auth/test_bgp_auth.py
index b13f3d6e2..48ba0cca5 100644
--- a/tests/topotests/bgp_auth/test_bgp_auth.py
+++ b/tests/topotests/bgp_auth/test_bgp_auth.py
@@ -74,76 +74,64 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
class InvalidCLIError(Exception):
"""Raise when the CLI command is wrong"""
-
pass
-
-class TemplateTopo(Topo):
- "Test topology builder"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- #
- # Create routers
- tgen.add_router("R1")
- tgen.add_router("R2")
- tgen.add_router("R3")
-
- # R1-R2 1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["R1"])
- switch.add_link(tgen.gears["R2"])
-
- # R1-R3 1
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["R1"])
- switch.add_link(tgen.gears["R3"])
-
- # R2-R3 1
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["R2"])
- switch.add_link(tgen.gears["R3"])
-
- # R1-R2 2
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["R1"])
- switch.add_link(tgen.gears["R2"])
-
- # R1-R3 2
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["R1"])
- switch.add_link(tgen.gears["R3"])
-
- # R2-R3 2
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["R2"])
- switch.add_link(tgen.gears["R3"])
-
- # R1-R2 3
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["R1"])
- switch.add_link(tgen.gears["R2"])
-
- # R1-R3 2
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["R1"])
- switch.add_link(tgen.gears["R3"])
-
- # R2-R3 2
- switch = tgen.add_switch("s9")
- switch.add_link(tgen.gears["R2"])
- switch.add_link(tgen.gears["R3"])
+def build_topo(tgen):
+ # Create routers
+ tgen.add_router("R1")
+ tgen.add_router("R2")
+ tgen.add_router("R3")
+
+ # R1-R2 1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["R1"])
+ switch.add_link(tgen.gears["R2"])
+
+ # R1-R3 1
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["R1"])
+ switch.add_link(tgen.gears["R3"])
+
+ # R2-R3 1
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["R2"])
+ switch.add_link(tgen.gears["R3"])
+
+ # R1-R2 2
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["R1"])
+ switch.add_link(tgen.gears["R2"])
+
+ # R1-R3 2
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["R1"])
+ switch.add_link(tgen.gears["R3"])
+
+ # R2-R3 2
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["R2"])
+ switch.add_link(tgen.gears["R3"])
+
+ # R1-R2 3
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["R1"])
+ switch.add_link(tgen.gears["R2"])
+
+ # R1-R3 2
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["R1"])
+ switch.add_link(tgen.gears["R3"])
+
+ # R2-R3 2
+ switch = tgen.add_switch("s9")
+ switch.add_link(tgen.gears["R2"])
+ switch.add_link(tgen.gears["R3"])
def setup_module(mod):
"Sets up the pytest environment"
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
diff --git a/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py b/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py
index b9ad57f8b..ee241b653 100644
--- a/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py
+++ b/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py
@@ -79,13 +79,6 @@ from lib.topolog import logger
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/bgp_basic_functionality.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global Variable
KEEPALIVETIMER = 2
@@ -104,21 +97,6 @@ NETWORK = {
}
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -138,7 +116,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 = "{}/bgp_basic_functionality.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py b/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py
index 7e78722da..aaa65004f 100644
--- a/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py
+++ b/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py
@@ -43,28 +43,25 @@ from lib.common_config import step
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py b/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py
index 2c1546a3b..252475616 100644
--- a/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py
+++ b/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py
@@ -48,20 +48,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_communities_topo1/test_bgp_communities.py b/tests/topotests/bgp_communities_topo1/test_bgp_communities.py
index df579bc01..be0d87d22 100644
--- a/tests/topotests/bgp_communities_topo1/test_bgp_communities.py
+++ b/tests/topotests/bgp_communities_topo1/test_bgp_communities.py
@@ -69,14 +69,6 @@ from copy import deepcopy
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/bgp_communities.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@@ -84,21 +76,6 @@ NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
NEXT_HOP_IP = {}
-class BGPCOMMUNITIES(Topo):
- """
- Test BGPCOMMUNITIES - topology 1
-
- * `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
@@ -118,7 +95,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(BGPCOMMUNITIES, mod.__name__)
+ json_file = "{}/bgp_communities.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py b/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py
index d18e65bd6..80bcae631 100644
--- a/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py
+++ b/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py
@@ -73,14 +73,6 @@ from copy import deepcopy
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/bgp_communities_topo2.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@@ -90,21 +82,6 @@ NETWORK = {
}
-class BGPCOMMUNITIES(Topo):
- """
- Test BGPCOMMUNITIES - topology 1
-
- * `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
@@ -124,7 +101,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(BGPCOMMUNITIES, mod.__name__)
+ json_file = "{}/bgp_communities_topo2.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_community_alias/test_bgp-community-alias.py b/tests/topotests/bgp_community_alias/test_bgp-community-alias.py
index 2ef30249e..cc8166029 100644
--- a/tests/topotests/bgp_community_alias/test_bgp-community-alias.py
+++ b/tests/topotests/bgp_community_alias/test_bgp-community-alias.py
@@ -43,20 +43,18 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py b/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py
index eee9294df..472a0b955 100644
--- a/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py
+++ b/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py
@@ -62,55 +62,52 @@ from time import sleep
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
-
- tgen.add_router("z1")
- tgen.add_router("y1")
- tgen.add_router("y2")
- tgen.add_router("y3")
- tgen.add_router("x1")
- tgen.add_router("c1")
-
- # 10.0.1.0/30
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["c1"])
- switch.add_link(tgen.gears["x1"])
-
- # 10.0.2.0/30
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["x1"])
- switch.add_link(tgen.gears["y1"])
-
- # 10.0.3.0/30
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["y1"])
- switch.add_link(tgen.gears["y2"])
-
- # 10.0.4.0/30
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["y1"])
- switch.add_link(tgen.gears["y3"])
-
- # 10.0.5.0/30
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["y2"])
- switch.add_link(tgen.gears["y3"])
-
- # 10.0.6.0/30
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["y2"])
- switch.add_link(tgen.gears["z1"])
-
- # 10.0.7.0/30
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["y3"])
- switch.add_link(tgen.gears["z1"])
+def build_topo(tgen):
+ tgen.add_router("z1")
+ tgen.add_router("y1")
+ tgen.add_router("y2")
+ tgen.add_router("y3")
+ tgen.add_router("x1")
+ tgen.add_router("c1")
+
+ # 10.0.1.0/30
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["c1"])
+ switch.add_link(tgen.gears["x1"])
+
+ # 10.0.2.0/30
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["x1"])
+ switch.add_link(tgen.gears["y1"])
+
+ # 10.0.3.0/30
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["y1"])
+ switch.add_link(tgen.gears["y2"])
+
+ # 10.0.4.0/30
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["y1"])
+ switch.add_link(tgen.gears["y3"])
+
+ # 10.0.5.0/30
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["y2"])
+ switch.add_link(tgen.gears["y3"])
+
+ # 10.0.6.0/30
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["y2"])
+ switch.add_link(tgen.gears["z1"])
+
+ # 10.0.7.0/30
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["y3"])
+ switch.add_link(tgen.gears["z1"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py b/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py
index 9e020ae86..02fcd5445 100644
--- a/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py
+++ b/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py
@@ -142,21 +142,18 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class BgpConditionalAdvertisementTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ r1 = tgen.add_router("r1")
+ r2 = tgen.add_router("r2")
+ r3 = tgen.add_router("r3")
- r1 = tgen.add_router("r1")
- r2 = tgen.add_router("r2")
- r3 = tgen.add_router("r3")
+ switch = tgen.add_switch("s1")
+ switch.add_link(r1)
+ switch.add_link(r2)
- switch = tgen.add_switch("s1")
- switch.add_link(r1)
- switch.add_link(r2)
-
- switch = tgen.add_switch("s2")
- switch.add_link(r2)
- switch.add_link(r3)
+ switch = tgen.add_switch("s2")
+ switch.add_link(r2)
+ switch.add_link(r3)
def setup_module(mod):
@@ -166,7 +163,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
- tgen = Topogen(BgpConditionalAdvertisementTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py b/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py
index a22cd9406..4bcf2ebb4 100644
--- a/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py
+++ b/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py
@@ -50,22 +50,20 @@ from lib.common_config import step
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+def build_topo(tgen):
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_default_route/test_bgp_default-originate.py b/tests/topotests/bgp_default_route/test_bgp_default-originate.py
index 68d9c52f4..9da8d0a49 100644
--- a/tests/topotests/bgp_default_route/test_bgp_default-originate.py
+++ b/tests/topotests/bgp_default_route/test_bgp_default-originate.py
@@ -41,20 +41,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py b/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py
index 11a26570f..e6298dd78 100644
--- a/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py
+++ b/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py
@@ -41,20 +41,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py b/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py
index f8c36f632..8f23cf25b 100644
--- a/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py
+++ b/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py
@@ -44,20 +44,17 @@ from lib.common_config import step
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py b/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py
index 3735fcfb3..728819525 100644
--- a/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py
+++ b/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py
@@ -43,20 +43,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py b/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py
index 05f14f352..4be98c08f 100644
--- a/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py
+++ b/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py
@@ -41,20 +41,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_disable_addpath_rx/r1/bgpd.conf b/tests/topotests/bgp_disable_addpath_rx/r1/bgpd.conf
index 1f3352131..af1353e0e 100644
--- a/tests/topotests/bgp_disable_addpath_rx/r1/bgpd.conf
+++ b/tests/topotests/bgp_disable_addpath_rx/r1/bgpd.conf
@@ -1,7 +1,9 @@
!
router bgp 65001
+ timers 3 10
no bgp ebgp-requires-policy
neighbor 192.168.1.2 remote-as external
+ neighbor 192.168.1.2 timers connect 5
address-family ipv4 unicast
neighbor 192.168.1.2 disable-addpath-rx
exit-address-family
diff --git a/tests/topotests/bgp_disable_addpath_rx/r2/bgpd.conf b/tests/topotests/bgp_disable_addpath_rx/r2/bgpd.conf
index 92d95003e..db68e554d 100644
--- a/tests/topotests/bgp_disable_addpath_rx/r2/bgpd.conf
+++ b/tests/topotests/bgp_disable_addpath_rx/r2/bgpd.conf
@@ -1,8 +1,12 @@
router bgp 65002
+ timers 3 10
no bgp ebgp-requires-policy
neighbor 192.168.1.1 remote-as external
+ neighbor 192.168.1.1 timers connect 5
neighbor 192.168.2.3 remote-as external
+ neighbor 192.168.2.3 timers connect 5
neighbor 192.168.2.4 remote-as external
+ neighbor 192.168.2.4 timers connect 5
address-family ipv4 unicast
neighbor 192.168.1.1 addpath-tx-all-paths
exit-address-family
diff --git a/tests/topotests/bgp_disable_addpath_rx/r3/bgpd.conf b/tests/topotests/bgp_disable_addpath_rx/r3/bgpd.conf
index f5731a108..3ac6a08e4 100644
--- a/tests/topotests/bgp_disable_addpath_rx/r3/bgpd.conf
+++ b/tests/topotests/bgp_disable_addpath_rx/r3/bgpd.conf
@@ -1,6 +1,8 @@
router bgp 65003
+ timers 3 10
no bgp ebgp-requires-policy
neighbor 192.168.2.2 remote-as external
+ neighbor 192.168.2.2 timers connect 5
address-family ipv4 unicast
redistribute connected
exit-address-family
diff --git a/tests/topotests/bgp_disable_addpath_rx/r4/bgpd.conf b/tests/topotests/bgp_disable_addpath_rx/r4/bgpd.conf
index 527b8d348..8ab405fbd 100644
--- a/tests/topotests/bgp_disable_addpath_rx/r4/bgpd.conf
+++ b/tests/topotests/bgp_disable_addpath_rx/r4/bgpd.conf
@@ -1,6 +1,8 @@
router bgp 65004
+ timers 3 10
no bgp ebgp-requires-policy
neighbor 192.168.2.2 remote-as external
+ neighbor 192.168.2.2 timers connect 5
address-family ipv4 unicast
redistribute connected
exit-address-family
diff --git a/tests/topotests/bgp_disable_addpath_rx/test_disable_addpath_rx.py b/tests/topotests/bgp_disable_addpath_rx/test_disable_addpath_rx.py
index 2126d6226..ed88d5df2 100644
--- a/tests/topotests/bgp_disable_addpath_rx/test_disable_addpath_rx.py
+++ b/tests/topotests/bgp_disable_addpath_rx/test_disable_addpath_rx.py
@@ -25,7 +25,6 @@ Test if AddPath RX direction is not negotiated via AddPath capability.
import os
import sys
import json
-import time
import pytest
import functools
@@ -35,32 +34,27 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
-from lib.topolog import logger
-from mininet.topo import Topo
from lib.common_config import step
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_distance_change/test_bgp_distance_change.py b/tests/topotests/bgp_distance_change/test_bgp_distance_change.py
index 2583db01e..9af237986 100644
--- a/tests/topotests/bgp_distance_change/test_bgp_distance_change.py
+++ b/tests/topotests/bgp_distance_change/test_bgp_distance_change.py
@@ -52,20 +52,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py b/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py
index 9460d6bae..c0886de85 100644
--- a/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py
+++ b/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py
@@ -54,21 +54,19 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py b/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py
index 390c8b290..4f33e8124 100644
--- a/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py
+++ b/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py
@@ -60,31 +60,29 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
- for routern in range(1, 7):
- tgen.add_router("r{}".format(routern))
+def build_topo(tgen):
+ for routern in range(1, 7):
+ tgen.add_router("r{}".format(routern))
- # Scenario 1.
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ # Scenario 1.
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- # Scenario 2.
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
+ # Scenario 2.
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
- # Scenario 3.
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r5"])
- switch.add_link(tgen.gears["r6"])
+ # Scenario 3.
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r5"])
+ switch.add_link(tgen.gears["r6"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py b/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py
index 841a76619..66714fd2f 100644
--- a/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py
+++ b/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py
@@ -58,32 +58,26 @@ total_ebgp_peers = 20
#####################################################
-class BGPECMPTopo1(Topo):
- "BGP ECMP Topology 1"
-
- def build(self, **_opts):
- tgen = get_topogen(self)
-
- # Create the BGP router
- router = tgen.add_router("r1")
-
- # Setup Switches - 1 switch per 5 peering routers
- for swNum in range(1, (total_ebgp_peers + 4) / 5 + 1):
- switch = tgen.add_switch("s{}".format(swNum))
- switch.add_link(router)
-
- # Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
- for peerNum in range(1, total_ebgp_peers + 1):
- swNum = (peerNum - 1) / 5 + 1
-
- peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100)
- peer_route = "via 10.0.{}.1".format(swNum)
- peer = tgen.add_exabgp_peer(
- "peer{}".format(peerNum), ip=peer_ip, defaultRoute=peer_route
- )
+def build_topo(tgen):
+ router = tgen.add_router("r1")
+
+ # Setup Switches - 1 switch per 5 peering routers
+ for swNum in range(1, (total_ebgp_peers + 4) // 5 + 1):
+ switch = tgen.add_switch("s{}".format(swNum))
+ switch.add_link(router)
+
+ # Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
+ for peerNum in range(1, total_ebgp_peers + 1):
+ swNum = (peerNum - 1) // 5 + 1
+
+ peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100)
+ peer_route = "via 10.0.{}.1".format(swNum)
+ peer = tgen.add_exabgp_peer(
+ "peer{}".format(peerNum), ip=peer_ip, defaultRoute=peer_route
+ )
- switch = tgen.gears["s{}".format(swNum)]
- switch.add_link(peer)
+ switch = tgen.gears["s{}".format(swNum)]
+ switch.add_link(peer)
#####################################################
@@ -94,7 +88,7 @@ class BGPECMPTopo1(Topo):
def setup_module(module):
- tgen = Topogen(BGPECMPTopo1, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# Starting Routers
diff --git a/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py b/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py
index 7bc3d2912..a82ed8ec8 100644
--- a/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py
+++ b/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py
@@ -71,14 +71,6 @@ 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 and configuration creation
-jsonFile = "{}/ebgp_ecmp_topo2.json".format(CWD)
-
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NEXT_HOPS = {"ipv4": [], "ipv6": []}
@@ -89,21 +81,6 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
BGP_CONVERGENCE = False
-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.
@@ -125,7 +102,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 = "{}/ebgp_ecmp_topo2.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py b/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py
index 15982dad5..561ba0edf 100644
--- a/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py
+++ b/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py
@@ -71,14 +71,6 @@ 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 and configuration creation
-jsonFile = "{}/ibgp_ecmp_topo2.json".format(CWD)
-
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NEXT_HOPS = {"ipv4": [], "ipv6": []}
@@ -89,21 +81,6 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
BGP_CONVERGENCE = False
-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.
@@ -125,7 +102,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 = "{}/ibgp_ecmp_topo2.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/bgp_ecmp_topo3/test_ibgp_ecmp_topo3.py b/tests/topotests/bgp_ecmp_topo3/test_ibgp_ecmp_topo3.py
index 5f3ac4e71..66ebe5b58 100644
--- a/tests/topotests/bgp_ecmp_topo3/test_ibgp_ecmp_topo3.py
+++ b/tests/topotests/bgp_ecmp_topo3/test_ibgp_ecmp_topo3.py
@@ -40,7 +40,7 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen
-from mininet.topo import Topo
+from lib import topojson
from lib.common_config import (
start_topology,
@@ -63,15 +63,6 @@ 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 and configuration creation
-jsonFile = "{}/ibgp_ecmp_topo3.json".format(CWD)
-
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
# Global variables
NEXT_HOPS = {"ipv4": [], "ipv6": []}
NETWORK = {"ipv4": "192.168.1.10/32", "ipv6": "fd00:0:0:1::10/128"}
@@ -79,45 +70,20 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
BGP_CONVERGENCE = False
-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 NEXT_HOPS, INTF_LIST_R3, INTF_LIST_R2, TEST_STATIC
global ADDR_TYPES
testsuite_run_time = time.asctime(time.localtime(time.time()))
logger.info("Testsuite start time: {}".format(testsuite_run_time))
logger.info("=" * 40)
- logger.info("Running setup_module to create topology")
-
- # This function initiates the topology build with Topogen...
- tgen = Topogen(CreateTopo, mod.__name__)
-
- # Starting topology, create tmp files which are loaded to routers
- # to start deamons and then start routers
- start_topology(tgen)
-
- # Creating configuration from JSON
- build_config_from_json(tgen, topo)
+ tgen = topojson.setup_module_from_json(mod.__file__)
+ topo = tgen.json_topo
# Don't run this test if we have any failure.
if tgen.routers_have_failure():
@@ -136,18 +102,7 @@ def setup_module(mod):
def teardown_module():
- """
- Teardown the pytest environment.
-
- * `mod`: module name
- """
-
- logger.info("Running teardown_module to delete topology")
-
- tgen = get_topogen()
-
- # Stop toplogy and Remove tmp files
- tgen.stop_topology()
+ get_topogen().stop_topology()
def static_or_nw(tgen, topo, tc_name, test_type, dut):
@@ -221,12 +176,11 @@ def static_or_nw(tgen, topo, tc_name, test_type, dut):
@pytest.mark.parametrize("test_type", ["redist_static"])
-def test_ecmp_fast_convergence(request, test_type):
+def test_ecmp_fast_convergence(request, test_type, tgen, topo):
"""This test is to verify bgp fast-convergence cli functionality"""
tc_name = request.node.name
write_test_header(tc_name)
- tgen = get_topogen()
# Verifying RIB routes
dut = "r3"
diff --git a/tests/topotests/bgp_evpn_mh/test_evpn_mh.py b/tests/topotests/bgp_evpn_mh/test_evpn_mh.py
index 8cdf3529d..bad4da116 100644
--- a/tests/topotests/bgp_evpn_mh/test_evpn_mh.py
+++ b/tests/topotests/bgp_evpn_mh/test_evpn_mh.py
@@ -62,7 +62,7 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.pimd]
#####################################################
-class NetworkTopo(Topo):
+def build_topo(tgen):
"""
EVPN Multihoming Topology -
1. Two level CLOS
@@ -71,110 +71,105 @@ class NetworkTopo(Topo):
4. Two dual attached hosts per-rack - hostdx1, hostdx2
"""
- def build(self, **_opts):
- "Build function"
-
- tgen = get_topogen(self)
-
- tgen.add_router("spine1")
- tgen.add_router("spine2")
- tgen.add_router("torm11")
- tgen.add_router("torm12")
- tgen.add_router("torm21")
- tgen.add_router("torm22")
- tgen.add_router("hostd11")
- tgen.add_router("hostd12")
- tgen.add_router("hostd21")
- tgen.add_router("hostd22")
-
- # On main router
- # First switch is for a dummy interface (for local network)
-
- ##################### spine1 ########################
- # spine1-eth0 is connected to torm11-eth0
- switch = tgen.add_switch("sw1")
- switch.add_link(tgen.gears["spine1"])
- switch.add_link(tgen.gears["torm11"])
-
- # spine1-eth1 is connected to torm12-eth0
- switch = tgen.add_switch("sw2")
- switch.add_link(tgen.gears["spine1"])
- switch.add_link(tgen.gears["torm12"])
-
- # spine1-eth2 is connected to torm21-eth0
- switch = tgen.add_switch("sw3")
- switch.add_link(tgen.gears["spine1"])
- switch.add_link(tgen.gears["torm21"])
-
- # spine1-eth3 is connected to torm22-eth0
- switch = tgen.add_switch("sw4")
- switch.add_link(tgen.gears["spine1"])
- switch.add_link(tgen.gears["torm22"])
-
- ##################### spine2 ########################
- # spine2-eth0 is connected to torm11-eth1
- switch = tgen.add_switch("sw5")
- switch.add_link(tgen.gears["spine2"])
- switch.add_link(tgen.gears["torm11"])
-
- # spine2-eth1 is connected to torm12-eth1
- switch = tgen.add_switch("sw6")
- switch.add_link(tgen.gears["spine2"])
- switch.add_link(tgen.gears["torm12"])
-
- # spine2-eth2 is connected to torm21-eth1
- switch = tgen.add_switch("sw7")
- switch.add_link(tgen.gears["spine2"])
- switch.add_link(tgen.gears["torm21"])
-
- # spine2-eth3 is connected to torm22-eth1
- switch = tgen.add_switch("sw8")
- switch.add_link(tgen.gears["spine2"])
- switch.add_link(tgen.gears["torm22"])
-
- ##################### torm11 ########################
- # torm11-eth2 is connected to hostd11-eth0
- switch = tgen.add_switch("sw9")
- switch.add_link(tgen.gears["torm11"])
- switch.add_link(tgen.gears["hostd11"])
-
- # torm11-eth3 is connected to hostd12-eth0
- switch = tgen.add_switch("sw10")
- switch.add_link(tgen.gears["torm11"])
- switch.add_link(tgen.gears["hostd12"])
-
- ##################### torm12 ########################
- # torm12-eth2 is connected to hostd11-eth1
- switch = tgen.add_switch("sw11")
- switch.add_link(tgen.gears["torm12"])
- switch.add_link(tgen.gears["hostd11"])
-
- # torm12-eth3 is connected to hostd12-eth1
- switch = tgen.add_switch("sw12")
- switch.add_link(tgen.gears["torm12"])
- switch.add_link(tgen.gears["hostd12"])
-
- ##################### torm21 ########################
- # torm21-eth2 is connected to hostd21-eth0
- switch = tgen.add_switch("sw13")
- switch.add_link(tgen.gears["torm21"])
- switch.add_link(tgen.gears["hostd21"])
-
- # torm21-eth3 is connected to hostd22-eth0
- switch = tgen.add_switch("sw14")
- switch.add_link(tgen.gears["torm21"])
- switch.add_link(tgen.gears["hostd22"])
-
- ##################### torm22 ########################
- # torm22-eth2 is connected to hostd21-eth1
- switch = tgen.add_switch("sw15")
- switch.add_link(tgen.gears["torm22"])
- switch.add_link(tgen.gears["hostd21"])
-
- # torm22-eth3 is connected to hostd22-eth1
- switch = tgen.add_switch("sw16")
- switch.add_link(tgen.gears["torm22"])
- switch.add_link(tgen.gears["hostd22"])
+ tgen.add_router("spine1")
+ tgen.add_router("spine2")
+ tgen.add_router("torm11")
+ tgen.add_router("torm12")
+ tgen.add_router("torm21")
+ tgen.add_router("torm22")
+ tgen.add_router("hostd11")
+ tgen.add_router("hostd12")
+ tgen.add_router("hostd21")
+ tgen.add_router("hostd22")
+
+ # On main router
+ # First switch is for a dummy interface (for local network)
+
+ ##################### spine1 ########################
+ # spine1-eth0 is connected to torm11-eth0
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["spine1"])
+ switch.add_link(tgen.gears["torm11"])
+
+ # spine1-eth1 is connected to torm12-eth0
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["spine1"])
+ switch.add_link(tgen.gears["torm12"])
+
+ # spine1-eth2 is connected to torm21-eth0
+ switch = tgen.add_switch("sw3")
+ switch.add_link(tgen.gears["spine1"])
+ switch.add_link(tgen.gears["torm21"])
+
+ # spine1-eth3 is connected to torm22-eth0
+ switch = tgen.add_switch("sw4")
+ switch.add_link(tgen.gears["spine1"])
+ switch.add_link(tgen.gears["torm22"])
+
+ ##################### spine2 ########################
+ # spine2-eth0 is connected to torm11-eth1
+ switch = tgen.add_switch("sw5")
+ switch.add_link(tgen.gears["spine2"])
+ switch.add_link(tgen.gears["torm11"])
+
+ # spine2-eth1 is connected to torm12-eth1
+ switch = tgen.add_switch("sw6")
+ switch.add_link(tgen.gears["spine2"])
+ switch.add_link(tgen.gears["torm12"])
+
+ # spine2-eth2 is connected to torm21-eth1
+ switch = tgen.add_switch("sw7")
+ switch.add_link(tgen.gears["spine2"])
+ switch.add_link(tgen.gears["torm21"])
+
+ # spine2-eth3 is connected to torm22-eth1
+ switch = tgen.add_switch("sw8")
+ switch.add_link(tgen.gears["spine2"])
+ switch.add_link(tgen.gears["torm22"])
+
+ ##################### torm11 ########################
+ # torm11-eth2 is connected to hostd11-eth0
+ switch = tgen.add_switch("sw9")
+ switch.add_link(tgen.gears["torm11"])
+ switch.add_link(tgen.gears["hostd11"])
+
+ # torm11-eth3 is connected to hostd12-eth0
+ switch = tgen.add_switch("sw10")
+ switch.add_link(tgen.gears["torm11"])
+ switch.add_link(tgen.gears["hostd12"])
+
+ ##################### torm12 ########################
+ # torm12-eth2 is connected to hostd11-eth1
+ switch = tgen.add_switch("sw11")
+ switch.add_link(tgen.gears["torm12"])
+ switch.add_link(tgen.gears["hostd11"])
+
+ # torm12-eth3 is connected to hostd12-eth1
+ switch = tgen.add_switch("sw12")
+ switch.add_link(tgen.gears["torm12"])
+ switch.add_link(tgen.gears["hostd12"])
+
+ ##################### torm21 ########################
+ # torm21-eth2 is connected to hostd21-eth0
+ switch = tgen.add_switch("sw13")
+ switch.add_link(tgen.gears["torm21"])
+ switch.add_link(tgen.gears["hostd21"])
+
+ # torm21-eth3 is connected to hostd22-eth0
+ switch = tgen.add_switch("sw14")
+ switch.add_link(tgen.gears["torm21"])
+ switch.add_link(tgen.gears["hostd22"])
+
+ ##################### torm22 ########################
+ # torm22-eth2 is connected to hostd21-eth1
+ switch = tgen.add_switch("sw15")
+ switch.add_link(tgen.gears["torm22"])
+ switch.add_link(tgen.gears["hostd21"])
+
+ # torm22-eth3 is connected to hostd22-eth1
+ switch = tgen.add_switch("sw16")
+ switch.add_link(tgen.gears["torm22"])
+ switch.add_link(tgen.gears["hostd22"])
#####################################################
@@ -371,7 +366,7 @@ def config_hosts(tgen, hosts):
def setup_module(module):
"Setup topology"
- tgen = Topogen(NetworkTopo, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
krel = platform.release()
diff --git a/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py b/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py
index 7a53173dc..20459adbd 100755
--- a/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py
+++ b/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py
@@ -88,29 +88,23 @@ HOST_SUFFIX = {'host1': '1', 'host2': '2'}
TRIGGERS = ["base", "no_rt5", "no_rt2"]
-class TemplateTopo(Topo):
- """Test topology builder"""
+def build_topo(tgen):
+ # This function only purpose is to define allocation and relationship
+ # between routers and add links.
- def build(self, *_args, **_opts):
- """Build function"""
- tgen = get_topogen(self)
+ # Create routers
+ for pe in PES:
+ tgen.add_router(pe)
+ for host in HOSTS:
+ tgen.add_router(host)
- # This function only purpose is to define allocation and relationship
- # between routers and add links.
+ krel = platform.release()
+ logger.info('Kernel version ' + krel)
- # Create routers
- for pe in PES:
- tgen.add_router(pe)
- for host in HOSTS:
- tgen.add_router(host)
-
- krel = platform.release()
- logger.info('Kernel version ' + krel)
-
- #Add links
- tgen.add_link(tgen.gears['PE1'], tgen.gears['PE2'], 'PE1-eth0', 'PE2-eth0')
- tgen.add_link(tgen.gears['PE1'], tgen.gears['host1'], 'PE1-eth1', 'host1-eth0')
- tgen.add_link(tgen.gears['PE2'], tgen.gears['host2'], 'PE2-eth1', 'host2-eth0')
+ #Add links
+ tgen.add_link(tgen.gears['PE1'], tgen.gears['PE2'], 'PE1-eth0', 'PE2-eth0')
+ tgen.add_link(tgen.gears['PE1'], tgen.gears['host1'], 'PE1-eth1', 'host1-eth0')
+ tgen.add_link(tgen.gears['PE2'], tgen.gears['host2'], 'PE2-eth1', 'host2-eth0')
def setup_module(mod):
@@ -123,7 +117,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
kernelv = platform.release()
diff --git a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
index 02e67b70c..98411938c 100644
--- a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
+++ b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
@@ -48,31 +48,28 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class BGPEVPNTopo(Topo):
- "Test topology builder"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- tgen.add_router("r1")
- tgen.add_router("r2")
+ tgen.add_router("r1")
+ tgen.add_router("r2")
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r1"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r1"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(BGPEVPNTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py
index 0380ac07d..d300561e1 100755
--- a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py
+++ b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py
@@ -49,49 +49,45 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
-class TemplateTopo(Topo):
- "Test topology builder"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- #
- # Create routers
- tgen.add_router("P1")
- tgen.add_router("PE1")
- tgen.add_router("PE2")
- tgen.add_router("host1")
- tgen.add_router("host2")
-
- # Host1-PE1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["host1"])
- switch.add_link(tgen.gears["PE1"])
-
- # PE1-P1
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["PE1"])
- switch.add_link(tgen.gears["P1"])
-
- # P1-PE2
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["P1"])
- switch.add_link(tgen.gears["PE2"])
-
- # PE2-host2
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["PE2"])
- switch.add_link(tgen.gears["host2"])
+def build_topo(tgen):
+ "Build function"
+
+ # This function only purpose is to define allocation and relationship
+ # between routers, switches and hosts.
+ #
+ #
+ # Create routers
+ tgen.add_router("P1")
+ tgen.add_router("PE1")
+ tgen.add_router("PE2")
+ tgen.add_router("host1")
+ tgen.add_router("host2")
+
+ # Host1-PE1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["host1"])
+ switch.add_link(tgen.gears["PE1"])
+
+ # PE1-P1
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["PE1"])
+ switch.add_link(tgen.gears["P1"])
+
+ # P1-PE2
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["P1"])
+ switch.add_link(tgen.gears["PE2"])
+
+ # PE2-host2
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["PE2"])
+ switch.add_link(tgen.gears["host2"])
def setup_module(mod):
"Sets up the pytest environment"
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
diff --git a/tests/topotests/bgp_features/test_bgp_features.py b/tests/topotests/bgp_features/test_bgp_features.py
index 54f61f92e..f2e09fb01 100644
--- a/tests/topotests/bgp_features/test_bgp_features.py
+++ b/tests/topotests/bgp_features/test_bgp_features.py
@@ -56,40 +56,48 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
#####################################################
-class BGPFeaturesTopo1(Topo):
- "BGP Features Topology 1"
-
- def build(self, **_opts):
- tgen = get_topogen(self)
-
- # Create the routers
- for rtrNum in range(1, 6):
- tgen.add_router("r{}".format(rtrNum))
-
- # Setup Switches and connections
- for swNum in range(1, 11):
- tgen.add_switch("sw{}".format(swNum))
-
- # Add connections to stub switches
- tgen.gears["r1"].add_link(tgen.gears["sw6"])
- tgen.gears["r2"].add_link(tgen.gears["sw7"])
- tgen.gears["r3"].add_link(tgen.gears["sw8"])
- tgen.gears["r4"].add_link(tgen.gears["sw9"])
- tgen.gears["r5"].add_link(tgen.gears["sw10"])
-
- # Add connections to R1-R2-R3 core
- tgen.gears["r1"].add_link(tgen.gears["sw1"])
- tgen.gears["r1"].add_link(tgen.gears["sw3"])
- tgen.gears["r2"].add_link(tgen.gears["sw1"])
- tgen.gears["r2"].add_link(tgen.gears["sw2"])
- tgen.gears["r3"].add_link(tgen.gears["sw2"])
- tgen.gears["r3"].add_link(tgen.gears["sw3"])
-
- # Add connections to external R4/R5 Routers
- tgen.gears["r1"].add_link(tgen.gears["sw4"])
- tgen.gears["r4"].add_link(tgen.gears["sw4"])
- tgen.gears["r2"].add_link(tgen.gears["sw5"])
- tgen.gears["r5"].add_link(tgen.gears["sw5"])
+def build_topo(tgen):
+ for rtrNum in range(1, 6):
+ tgen.add_router("r{}".format(rtrNum))
+
+ # create ExaBGP peers
+ for peer_num in range(1, 5):
+ tgen.add_exabgp_peer(
+ "peer{}".format(peer_num),
+ ip="192.168.101.{}".format(peer_num + 2),
+ defaultRoute="via 192.168.101.1",
+ )
+
+ # Setup Switches and connections
+ for swNum in range(1, 11):
+ tgen.add_switch("sw{}".format(swNum))
+
+ # Add connections to stub switches
+ tgen.gears["r1"].add_link(tgen.gears["sw6"])
+ tgen.gears["r2"].add_link(tgen.gears["sw7"])
+ tgen.gears["r3"].add_link(tgen.gears["sw8"])
+ tgen.gears["r4"].add_link(tgen.gears["sw9"])
+ tgen.gears["r5"].add_link(tgen.gears["sw10"])
+
+ # Add connections to R1-R2-R3 core
+ tgen.gears["r1"].add_link(tgen.gears["sw1"])
+ tgen.gears["r1"].add_link(tgen.gears["sw3"])
+ tgen.gears["r2"].add_link(tgen.gears["sw1"])
+ tgen.gears["r2"].add_link(tgen.gears["sw2"])
+ tgen.gears["r3"].add_link(tgen.gears["sw2"])
+ tgen.gears["r3"].add_link(tgen.gears["sw3"])
+
+ # Add connections to external R4/R5 Routers
+ tgen.gears["r1"].add_link(tgen.gears["sw4"])
+ tgen.gears["r4"].add_link(tgen.gears["sw4"])
+ tgen.gears["r2"].add_link(tgen.gears["sw5"])
+ tgen.gears["r5"].add_link(tgen.gears["sw5"])
+
+ # Add ExaBGP peers to sw4
+ tgen.gears["peer1"].add_link(tgen.gears["sw4"])
+ tgen.gears["peer2"].add_link(tgen.gears["sw4"])
+ tgen.gears["peer3"].add_link(tgen.gears["sw4"])
+ tgen.gears["peer4"].add_link(tgen.gears["sw4"])
#####################################################
@@ -100,7 +108,7 @@ class BGPFeaturesTopo1(Topo):
def setup_module(module):
- tgen = Topogen(BGPFeaturesTopo1, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# Starting Routers
diff --git a/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py b/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py
index 6a12ed80d..05ea944eb 100644
--- a/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py
+++ b/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py
@@ -82,24 +82,18 @@ pytestmark = [pytest.mark.bgpd]
#####################################################
-class BGPFLOWSPECTopo1(Topo):
- "BGP EBGP Flowspec Topology 1"
+def build_topo(tgen):
+ tgen.add_router("r1")
- def build(self, **_opts):
- tgen = get_topogen(self)
+ # Setup Control Path Switch 1. r1-eth0
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
- # Setup Routers
- tgen.add_router("r1")
-
- # Setup Control Path Switch 1. r1-eth0
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
-
- ## Add eBGP ExaBGP neighbors
- peer_ip = "10.0.1.101" ## peer
- peer_route = "via 10.0.1.1" ## router
- peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
- switch.add_link(peer)
+ ## Add eBGP ExaBGP neighbors
+ peer_ip = "10.0.1.101" ## peer
+ peer_route = "via 10.0.1.1" ## router
+ peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
+ switch.add_link(peer)
#####################################################
@@ -110,7 +104,7 @@ class BGPFLOWSPECTopo1(Topo):
def setup_module(module):
- tgen = Topogen(BGPFLOWSPECTopo1, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# check for zebra capability
diff --git a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
index bd3f6209a..4ee3b9708 100644
--- a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
+++ b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
@@ -142,15 +142,6 @@ from lib.common_config import (
pytestmark = [pytest.mark.bgpd]
-# Reading the data from JSON File for topology and configuration creation
-jsonFile = "{}/bgp_gr_topojson_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- logger.info("Could not read file:", jsonFile)
-
-
# Global variables
NEXT_HOP_IP = {"ipv4": "192.168.1.10", "ipv6": "fd00:0:0:1::10"}
NEXT_HOP_IP_1 = {"ipv4": "192.168.0.1", "ipv6": "fd00::1"}
@@ -160,28 +151,6 @@ GR_RESTART_TIMER = 20
PREFERRED_NEXT_HOP = "link_local"
-class GenerateTopo(Topo):
- """
- Test topology builder
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to create topology
- # as defined in input json file.
- #
- # Create topology (setup module)
- # Creating 2 routers topology, r1, r2in IBGP
- # Bring up topology
-
- # Building topology from json file
- build_topo_from_json(tgen, topo)
-
-
def setup_module(mod):
"""
Sets up the pytest environment
@@ -203,7 +172,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(GenerateTopo, mod.__name__)
+ json_file = "{}/bgp_gr_topojson_topo1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
index dd44cbf96..5fc361f8f 100644
--- a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
+++ b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
@@ -141,14 +141,6 @@ from lib.common_config import (
pytestmark = [pytest.mark.bgpd]
-# Reading the data from JSON File for topology and configuration creation
-jsonFile = "{}/bgp_gr_topojson_topo2.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- logger.info("Could not read file:", jsonFile)
-
# Global variables
BGP_CONVERGENCE = False
GR_RESTART_TIMER = 5
@@ -159,28 +151,6 @@ NEXT_HOP_4 = ["192.168.1.1", "192.168.4.2"]
NEXT_HOP_6 = ["fd00:0:0:1::1", "fd00:0:0:4::2"]
-class GenerateTopo(Topo):
- """
- Test topology builder
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to create topology
- # as defined in input json file.
- #
- # Create topology (setup module)
- # Creating 2 routers topology, r1, r2in IBGP
- # Bring up topology
-
- # Building topology from json file
- build_topo_from_json(tgen, topo)
-
-
def setup_module(mod):
"""
Sets up the pytest environment
@@ -202,7 +172,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(GenerateTopo, mod.__name__)
+ json_file = "{}/bgp_gr_topojson_topo2.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_gshut/test_bgp_gshut.py b/tests/topotests/bgp_gshut/test_bgp_gshut.py
index d32ba1c1f..a08f74d6c 100644
--- a/tests/topotests/bgp_gshut/test_bgp_gshut.py
+++ b/tests/topotests/bgp_gshut/test_bgp_gshut.py
@@ -78,28 +78,25 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 6):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 6):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
-
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r5"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r5"])
def _run_cmd_and_check(router, cmd, results_file, retries=100, intvl=0.5):
@@ -110,7 +107,7 @@ def _run_cmd_and_check(router, cmd, results_file, retries=100, intvl=0.5):
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py b/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py
index 2595b2099..2bddd9c77 100644
--- a/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py
+++ b/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py
@@ -75,16 +75,9 @@ from lib.bgp import (
)
from lib.topojson import build_topo_from_json, build_config_from_json
-pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
+pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-# Reading the data from JSON File for topology and configuration creation
-jsonFile = "{}/ebgp_gshut_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- logger.info("Could not read file:", jsonFile)
# Global variables
NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"}
@@ -94,28 +87,6 @@ PREFERRED_NEXT_HOP = "link_local"
BGP_CONVERGENCE = False
-class GenerateTopo(Topo):
- """
- Test topology builder
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to create topology
- # as defined in input json file.
- #
- # Create topology (setup module)
- # Creating 2 routers topology, r1, r2in IBGP
- # Bring up topology
-
- # Building topology from json file
- build_topo_from_json(tgen, topo)
-
-
def setup_module(mod):
"""
Sets up the pytest environment
@@ -137,7 +108,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(GenerateTopo, mod.__name__)
+ json_file = "{}/ebgp_gshut_topo1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py b/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py
index 3f3354dc8..90d285f0f 100644
--- a/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py
+++ b/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py
@@ -78,14 +78,6 @@ 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 and configuration creation
-jsonFile = "{}/ibgp_gshut_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- logger.info("Could not read file:", jsonFile)
-
# Global variables
NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"}
NEXT_HOP_IP_1 = {"ipv4": "10.0.3.1", "ipv6": "fd00:0:0:3::1"}
@@ -94,28 +86,6 @@ PREFERRED_NEXT_HOP = "link_local"
BGP_CONVERGENCE = False
-class GenerateTopo(Topo):
- """
- Test topology builder
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to create topology
- # as defined in input json file.
- #
- # Create topology (setup module)
- # Creating 2 routers topology, r1, r2in IBGP
- # Bring up topology
-
- # Building topology from json file
- build_topo_from_json(tgen, topo)
-
-
def setup_module(mod):
"""
Sets up the pytest environment
@@ -137,7 +107,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(GenerateTopo, mod.__name__)
+ json_file = "{}/ibgp_gshut_topo1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_ibgp_nbr.py b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_ibgp_nbr.py
index 4f72cbb30..04945a94a 100644
--- a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_ibgp_nbr.py
+++ b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_ibgp_nbr.py
@@ -39,7 +39,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen
-from mininet.topo import Topo
from lib.common_config import (
start_topology,
@@ -66,13 +65,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/rfc5549_ebgp_ibgp_nbr.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK = {
@@ -121,21 +113,6 @@ unchange is configure on EBGP peers
"""
-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):
"""Set up the pytest environment."""
@@ -147,7 +124,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 = "{}/rfc5549_ebgp_ibgp_nbr.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_nbr.py b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_nbr.py
index 12237fec6..f09da23bc 100644
--- a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_nbr.py
+++ b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_nbr.py
@@ -40,7 +40,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen
-from mininet.topo import Topo
from lib.common_config import (
start_topology,
@@ -71,13 +70,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/rfc5549_ebgp_nbr.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK = {
@@ -137,21 +129,6 @@ TC32. Verify IPv4 route received with IPv6 nexthop can be advertised to
"""
-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):
"""Set up the pytest environment."""
global topo, ADDR_TYPES
@@ -163,7 +140,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 = "{}/rfc5549_ebgp_nbr.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_unnumbered_nbr.py b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_unnumbered_nbr.py
index 2675f3a39..5966ffded 100644
--- a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_unnumbered_nbr.py
+++ b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_unnumbered_nbr.py
@@ -37,7 +37,6 @@ sys.path.append(os.path.join(CWD, "../"))
sys.path.append(os.path.join(CWD, "../../"))
from lib.topogen import Topogen, get_topogen
-from mininet.topo import Topo
from lib.common_config import (
write_test_header,
@@ -62,13 +61,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/rfc5549_ebgp_unnumbered_nbr.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NO_OF_RTES = 2
@@ -124,21 +116,6 @@ shut / no shut of nexthop and BGP peer interfaces
"""
-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):
"""Set up the pytest environment."""
global topo, ADDR_TYPES
@@ -150,7 +127,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 = "{}/rfc5549_ebgp_unnumbered_nbr.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_nbr.py b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_nbr.py
index 871f6b128..9b5e48e08 100644
--- a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_nbr.py
+++ b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_nbr.py
@@ -39,7 +39,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen
-from mininet.topo import Topo
from lib.common_config import (
start_topology,
@@ -67,13 +66,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/rfc5549_ibgp_nbr.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK = {
@@ -121,21 +113,6 @@ 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):
"""Set up the pytest environment."""
@@ -147,7 +124,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 = "{}/rfc5549_ibgp_nbr.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_unnumbered_nbr.py b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_unnumbered_nbr.py
index 5f4292b81..5e804df23 100644
--- a/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_unnumbered_nbr.py
+++ b/tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ibgp_unnumbered_nbr.py
@@ -38,7 +38,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen
-from mininet.topo import Topo
from lib.common_config import (
start_topology,
@@ -58,13 +57,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/rfc5549_ibgp_unnumbered_nbr.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
@@ -107,21 +99,6 @@ 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):
"""Set up the pytest environment."""
@@ -133,7 +110,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 = "{}/rfc5549_ibgp_unnumbered_nbr.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py b/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py
index dc587cd70..04cf0395d 100644
--- a/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py
+++ b/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py
@@ -49,25 +49,21 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class BGPIPV6RTADVTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 2 routers.
+ tgen.add_router("r1")
+ tgen.add_router("r2")
- # Create 2 routers.
- tgen.add_router("r1")
- tgen.add_router("r2")
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(BGPIPV6RTADVTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py
index 6eaf8e07f..f344ee76b 100644
--- a/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py
+++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py
@@ -94,48 +94,44 @@ CWD = os.path.dirname(os.path.realpath(__file__))
TEST = os.path.basename(CWD)
-class ThisTestTopo(Topo):
- "Test topology builder"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- # Create P/PE routers
- tgen.add_router("r1")
- # check for mpls
- if tgen.hasmpls != True:
- logger.info("MPLS not available, tests will be skipped")
- return
- for routern in range(2, 5):
- tgen.add_router("r{}".format(routern))
- # Create CE routers
- for routern in range(1, 4):
- tgen.add_router("ce{}".format(routern))
-
- # CE/PE links
- tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
- tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
- tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
-
- # Create a switch with just one router connected to it to simulate a
- # empty network.
- switch = {}
- switch[0] = tgen.add_switch("sw0")
- switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
- switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
-
- switch[1] = tgen.add_switch("sw1")
- switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
- switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
- switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
-
- switch[1] = tgen.add_switch("sw2")
- switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
- switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
+def build_topo(tgen):
+ "Build function"
+
+ # This function only purpose is to define allocation and relationship
+ # between routers, switches and hosts.
+ #
+ # Create P/PE routers
+ tgen.add_router("r1")
+ # check for mpls
+ if tgen.hasmpls != True:
+ logger.info("MPLS not available, tests will be skipped")
+ return
+ for routern in range(2, 5):
+ tgen.add_router("r{}".format(routern))
+ # Create CE routers
+ for routern in range(1, 4):
+ tgen.add_router("ce{}".format(routern))
+
+ # CE/PE links
+ tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
+ tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
+ tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
+
+ # Create a switch with just one router connected to it to simulate a
+ # empty network.
+ switch = {}
+ switch[0] = tgen.add_switch("sw0")
+ switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
+ switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
+
+ switch[1] = tgen.add_switch("sw1")
+ switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
+ switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
+ switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
+
+ switch[1] = tgen.add_switch("sw2")
+ switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
+ switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
def ltemplatePreRouterStartHook():
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
index 40009b9ba..91291d89e 100644
--- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
@@ -95,54 +95,50 @@ CWD = os.path.dirname(os.path.realpath(__file__))
TEST = os.path.basename(CWD)
-class ThisTestTopo(Topo):
- "Test topology builder"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- # Create P/PE routers
- # check for mpls
- tgen.add_router("r1")
- if tgen.hasmpls != True:
- logger.info("MPLS not available, tests will be skipped")
- return
- mach = platform.machine()
- krel = platform.release()
- if mach[:1] == "a" and topotest.version_cmp(krel, "4.11") < 0:
- logger.info("Need Kernel version 4.11 to run on arm processor")
- return
- for routern in range(2, 5):
- tgen.add_router("r{}".format(routern))
- # Create CE routers
- for routern in range(1, 5):
- tgen.add_router("ce{}".format(routern))
-
- # CE/PE links
- tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
- tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
- tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
- tgen.add_link(tgen.gears["ce4"], tgen.gears["r4"], "ce4-eth0", "r4-eth5")
-
- # Create a switch with just one router connected to it to simulate a
- # empty network.
- switch = {}
- switch[0] = tgen.add_switch("sw0")
- switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
- switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
-
- switch[1] = tgen.add_switch("sw1")
- switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
- switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
- switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
-
- switch[1] = tgen.add_switch("sw2")
- switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
- switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
+def build_topo(tgen):
+ "Build function"
+
+ # This function only purpose is to define allocation and relationship
+ # between routers, switches and hosts.
+ #
+ # Create P/PE routers
+ # check for mpls
+ tgen.add_router("r1")
+ if tgen.hasmpls != True:
+ logger.info("MPLS not available, tests will be skipped")
+ return
+ mach = platform.machine()
+ krel = platform.release()
+ if mach[:1] == "a" and topotest.version_cmp(krel, "4.11") < 0:
+ logger.info("Need Kernel version 4.11 to run on arm processor")
+ return
+ for routern in range(2, 5):
+ tgen.add_router("r{}".format(routern))
+ # Create CE routers
+ for routern in range(1, 5):
+ tgen.add_router("ce{}".format(routern))
+
+ # CE/PE links
+ tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
+ tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
+ tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
+ tgen.add_link(tgen.gears["ce4"], tgen.gears["r4"], "ce4-eth0", "r4-eth5")
+
+ # Create a switch with just one router connected to it to simulate a
+ # empty network.
+ switch = {}
+ switch[0] = tgen.add_switch("sw0")
+ switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
+ switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
+
+ switch[1] = tgen.add_switch("sw1")
+ switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
+ switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
+ switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
+
+ switch[1] = tgen.add_switch("sw2")
+ switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
+ switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
def ltemplatePreRouterStartHook():
diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py
index d138a689e..fb472c449 100644
--- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py
+++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py
@@ -81,13 +81,6 @@ CWD = os_path.dirname(os_path.realpath(__file__))
sys.path.append(os_path.join(CWD, "../"))
sys.path.append(os_path.join(CWD, "../lib/"))
-# Reading the data from JSON File for topology and configuration creation
-jsonFile = "{}/bgp_large_community_topo_1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json_load(topoJson)
-except IOError:
- logger.info("Could not read file:", jsonFile)
# Global variables
bgp_convergence = False
@@ -124,22 +117,6 @@ STANDARD_COMM = {
}
-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
@@ -159,7 +136,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 = "{}/bgp_large_community_topo_1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py
index c9115bf42..a94d20da3 100644
--- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py
+++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py
@@ -97,17 +97,9 @@ from lib.topolog import logger
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify
from lib.topojson import build_topo_from_json, build_config_from_json
-pytestmark = [pytest.mark.bgpd]
-
-# Reading the data from JSON File for topology and configuration creation
-jsonFile = "{}/bgp_large_community_topo_2.json".format(CWD)
+pytestmark = [pytest.mark.bgpd]
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
bgp_convergence = False
@@ -115,21 +107,6 @@ bgp_convergence = False
NETWORKS = {"ipv4": ["200.50.2.0/32"], "ipv6": ["1::1/128"]}
-class GenerateTopo(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
@@ -149,7 +126,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(GenerateTopo, mod.__name__)
+ json_file = "{}/bgp_large_community_topo_2.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py b/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py
index 4ad1dbcaa..799b5f93f 100644
--- a/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py
+++ b/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py
@@ -66,62 +66,57 @@ this scenario, the servers are also routers as they have to announce
anycast IP (VIP) addresses via BGP.
"""
-
-class BgpLinkBwTopo(Topo):
- "Test topology builder"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # Create 10 routers - 1 super-spine, 2 spines, 3 leafs
- # and 4 servers
- routers = {}
- for i in range(1, 11):
- routers[i] = tgen.add_router("r{}".format(i))
-
- # Create 13 "switches" - to interconnect the above routers
- switches = {}
- for i in range(1, 14):
- switches[i] = tgen.add_switch("s{}".format(i))
-
- # Interconnect R1 (super-spine) to R2 and R3 (the two spines)
- switches[1].add_link(tgen.gears["r1"])
- switches[1].add_link(tgen.gears["r2"])
- switches[2].add_link(tgen.gears["r1"])
- switches[2].add_link(tgen.gears["r3"])
-
- # Interconnect R2 (spine in pod-1) to R4 and R5 (the associated
- # leaf switches)
- switches[3].add_link(tgen.gears["r2"])
- switches[3].add_link(tgen.gears["r4"])
- switches[4].add_link(tgen.gears["r2"])
- switches[4].add_link(tgen.gears["r5"])
-
- # Interconnect R3 (spine in pod-2) to R6 (associated leaf)
- switches[5].add_link(tgen.gears["r3"])
- switches[5].add_link(tgen.gears["r6"])
-
- # Interconnect leaf switches to servers
- switches[6].add_link(tgen.gears["r4"])
- switches[6].add_link(tgen.gears["r7"])
- switches[7].add_link(tgen.gears["r4"])
- switches[7].add_link(tgen.gears["r8"])
- switches[8].add_link(tgen.gears["r5"])
- switches[8].add_link(tgen.gears["r9"])
- switches[9].add_link(tgen.gears["r6"])
- switches[9].add_link(tgen.gears["r10"])
-
- # Create empty networks for the servers
- switches[10].add_link(tgen.gears["r7"])
- switches[11].add_link(tgen.gears["r8"])
- switches[12].add_link(tgen.gears["r9"])
- switches[13].add_link(tgen.gears["r10"])
+def build_topo(tgen):
+ "Build function"
+
+ # Create 10 routers - 1 super-spine, 2 spines, 3 leafs
+ # and 4 servers
+ routers = {}
+ for i in range(1, 11):
+ routers[i] = tgen.add_router("r{}".format(i))
+
+ # Create 13 "switches" - to interconnect the above routers
+ switches = {}
+ for i in range(1, 14):
+ switches[i] = tgen.add_switch("s{}".format(i))
+
+ # Interconnect R1 (super-spine) to R2 and R3 (the two spines)
+ switches[1].add_link(tgen.gears["r1"])
+ switches[1].add_link(tgen.gears["r2"])
+ switches[2].add_link(tgen.gears["r1"])
+ switches[2].add_link(tgen.gears["r3"])
+
+ # Interconnect R2 (spine in pod-1) to R4 and R5 (the associated
+ # leaf switches)
+ switches[3].add_link(tgen.gears["r2"])
+ switches[3].add_link(tgen.gears["r4"])
+ switches[4].add_link(tgen.gears["r2"])
+ switches[4].add_link(tgen.gears["r5"])
+
+ # Interconnect R3 (spine in pod-2) to R6 (associated leaf)
+ switches[5].add_link(tgen.gears["r3"])
+ switches[5].add_link(tgen.gears["r6"])
+
+ # Interconnect leaf switches to servers
+ switches[6].add_link(tgen.gears["r4"])
+ switches[6].add_link(tgen.gears["r7"])
+ switches[7].add_link(tgen.gears["r4"])
+ switches[7].add_link(tgen.gears["r8"])
+ switches[8].add_link(tgen.gears["r5"])
+ switches[8].add_link(tgen.gears["r9"])
+ switches[9].add_link(tgen.gears["r6"])
+ switches[9].add_link(tgen.gears["r10"])
+
+ # Create empty networks for the servers
+ switches[10].add_link(tgen.gears["r7"])
+ switches[11].add_link(tgen.gears["r8"])
+ switches[12].add_link(tgen.gears["r9"])
+ switches[13].add_link(tgen.gears["r10"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(BgpLinkBwTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py b/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py
index fdbc5e553..bc4336b6f 100755
--- a/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py
+++ b/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py
@@ -67,27 +67,12 @@ LISTEN_ADDRESSES = {
}
-# Reads data from JSON File for topology and configuration creation.
-jsonFile = "{}/bgp_listen_on_multiple_addresses.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
-
-class TemplateTopo(Topo):
- "Topology builder."
-
- def build(self, *_args, **_opts):
- "Defines the allocation and relationship between routers and switches."
- tgen = get_topogen(self)
- build_topo_from_json(tgen, topo)
-
-
def setup_module(mod):
"Sets up the test environment."
- tgen = Topogen(TemplateTopo, mod.__name__)
+ json_file = "{}/bgp_listen_on_multiple_addresses.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# Adds extra parameters to bgpd so they listen for connections on specific
# multiple addresses.
diff --git a/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py b/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py
index ec4919650..f648e1791 100644
--- a/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py
+++ b/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py
@@ -46,24 +46,21 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_lu_topo1/test_bgp_lu.py b/tests/topotests/bgp_lu_topo1/test_bgp_lu.py
index 258ddb148..6318044ea 100644
--- a/tests/topotests/bgp_lu_topo1/test_bgp_lu.py
+++ b/tests/topotests/bgp_lu_topo1/test_bgp_lu.py
@@ -62,37 +62,33 @@ pytestmark = [pytest.mark.bgpd]
# +-----+ +-----+ +-----+
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # This function only purpose is to define allocation and relationship
+ # between routers, switches and hosts.
+ #
+ #
+ # Create routers
+ tgen.add_router("R1")
+ tgen.add_router("R2")
+ tgen.add_router("R3")
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- #
- # Create routers
- tgen.add_router("R1")
- tgen.add_router("R2")
- tgen.add_router("R3")
+ # R1-R2
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["R1"])
+ switch.add_link(tgen.gears["R2"])
- # R1-R2
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["R1"])
- switch.add_link(tgen.gears["R2"])
-
- # R2-R3
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["R2"])
- switch.add_link(tgen.gears["R3"])
+ # R2-R3
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["R2"])
+ switch.add_link(tgen.gears["R3"])
def setup_module(mod):
"Sets up the pytest environment"
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
diff --git a/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py b/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py
index c80094684..66fcd355e 100644
--- a/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py
+++ b/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py
@@ -50,20 +50,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py b/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py
index 5b762bfe5..07d1cb02b 100644
--- a/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py
+++ b/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py
@@ -46,20 +46,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_minimum_holdtime/test_bgp_minimum_holdtime.py b/tests/topotests/bgp_minimum_holdtime/test_bgp_minimum_holdtime.py
index c5afcdf11..5facdd26e 100755
--- a/tests/topotests/bgp_minimum_holdtime/test_bgp_minimum_holdtime.py
+++ b/tests/topotests/bgp_minimum_holdtime/test_bgp_minimum_holdtime.py
@@ -41,20 +41,17 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py
index 9a20f7d45..ffa1c3fb6 100644
--- a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py
+++ b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py
@@ -145,15 +145,9 @@ from lib.bgp import (
)
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
-jsonFile = "{}/bgp_multi_vrf_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
@@ -185,21 +179,6 @@ LOOPBACK_2 = {
}
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -222,7 +201,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 = "{}/bgp_multi_vrf_topo1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py
index 7fd9fac6e..609fdf358 100644
--- a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py
+++ b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py
@@ -105,14 +105,6 @@ from lib.topojson import build_config_from_json, build_topo_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/bgp_multi_vrf_topo2.json".format(CWD)
-
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
@@ -139,21 +131,6 @@ HOLDDOWNTIMER = 3
PREFERRED_NEXT_HOP = "link_local"
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -176,7 +153,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 = "{}/bgp_multi_vrf_topo2.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py
index a949c5282..25240791c 100644
--- a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py
+++ b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py
@@ -74,8 +74,7 @@ from functools import partial
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest
-from lib.micronet_compat import Mininet
-from lib.micronet_compat import Topo
+from lib.topogen import get_topogen, Topogen
pytestmark = [pytest.mark.bgpd]
@@ -91,38 +90,28 @@ fatal_error = ""
#####################################################
-class NetworkTopo(Topo):
- "BGP Multiview Topology 1"
+def build_topo(tgen):
+ # Setup Routers
+ router = tgen.add_router("r1")
- def build(self, **_opts):
+ # Setup Provider BGP peers
+ peer = {}
+ for i in range(1, 9):
+ peer[i] = tgen.add_exabgp_peer(
+ "peer%s" % i,
+ ip="172.16.1.%s/24" % i,
+ defaultRoute="via 172.16.1.254"
+ )
- exabgpPrivateDirs = ["/etc/exabgp", "/var/run/exabgp", "/var/log"]
+ # First switch is for a dummy interface (for local network)
+ switch = tgen.add_switch("sw0")
+ switch.add_link(router, nodeif="r1-stub")
- # Setup Routers
- router = {}
- for i in range(1, 2):
- router[i] = topotest.addRouter(self, "r%s" % i)
-
- # Setup Provider BGP peers
- peer = {}
- for i in range(1, 9):
- peer[i] = self.addHost(
- "peer%s" % i,
- ip="172.16.1.%s/24" % i,
- defaultRoute="via 172.16.1.254",
- privateDirs=exabgpPrivateDirs,
- )
-
- # Setup Switches
- switch = {}
- # First switch is for a dummy interface (for local network)
- switch[0] = self.addSwitch("sw0")
- self.addLink(switch[0], router[1], intfName2="r1-stub")
- # Second switch is for connection to all peering routers
- switch[1] = self.addSwitch("sw1")
- self.addLink(switch[1], router[1], intfName2="r1-eth0")
- for j in range(1, 9):
- self.addLink(switch[1], peer[j], intfName2="peer%s-eth0" % j)
+ # Second switch is for connection to all peering routers
+ switch = tgen.add_switch("sw1")
+ switch.add_link(router, nodeif="r1-eth0")
+ for j in range(1, 9):
+ switch.add_link(peer[j], nodeif="peer%s-eth0" % j)
#####################################################
@@ -133,87 +122,43 @@ class NetworkTopo(Topo):
def setup_module(module):
- global topo, net
-
- print("\n\n** %s: Setup Topology" % module.__name__)
- print("******************************************\n")
-
- print("Cleanup old Mininet runs")
- os.system("sudo mn -c > /dev/null 2>&1")
-
thisDir = os.path.dirname(os.path.realpath(__file__))
- topo = NetworkTopo()
-
- net = Mininet(controller=None, topo=topo)
- net.start()
+ tgen = Topogen(build_topo, module.__name__)
+ tgen.start_topology()
# Starting Routers
- for i in range(1, 2):
- net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i))
- net["r%s" % i].loadConf("bgpd", "%s/r%s/bgpd.conf" % (thisDir, i))
- net["r%s" % i].startRouter()
+ router = tgen.net["r1"]
+ router.loadConf("zebra", "%s/r1/zebra.conf" % thisDir)
+ router.loadConf("bgpd", "%s/r1/bgpd.conf" % thisDir)
+ tgen.gears["r1"].start()
# Starting PE Hosts and init ExaBGP on each of them
- print("*** Starting BGP on all 8 Peers")
- for i in range(1, 9):
- net["peer%s" % i].cmd("cp %s/exabgp.env /etc/exabgp/exabgp.env" % thisDir)
- net["peer%s" % i].cmd("cp %s/peer%s/* /etc/exabgp/" % (thisDir, i))
- net["peer%s" % i].cmd("chmod 644 /etc/exabgp/*")
- net["peer%s" % i].cmd("chmod 755 /etc/exabgp/*.py")
- net["peer%s" % i].cmd("chown -R exabgp:exabgp /etc/exabgp")
- net["peer%s" % i].cmd("exabgp -e /etc/exabgp/exabgp.env /etc/exabgp/exabgp.cfg")
- print("peer%s" % i),
- print("")
-
- # For debugging after starting FRR daemons, uncomment the next line
- # CLI(net)
+ peer_list = tgen.exabgp_peers()
+ for pname, peer in peer_list.items():
+ peer_dir = os.path.join(thisDir, pname)
+ env_file = os.path.join(thisDir, "exabgp.env")
+ peer.start(peer_dir, env_file)
def teardown_module(module):
- global net
-
- print("\n\n** %s: Shutdown Topology" % module.__name__)
- print("******************************************\n")
-
- # Shutdown - clean up everything
- print("*** Killing BGP on Peer routers")
- # Killing ExaBGP
- for i in range(1, 9):
- net["peer%s" % i].cmd("kill `cat /var/run/exabgp/exabgp.pid`")
-
- # End - Shutdown network
- net.stop()
+ tgen = get_topogen()
+ tgen.stop_topology()
def test_router_running():
- global fatal_error
- global net
-
- # Skip if previous fatal error condition is raised
- if fatal_error != "":
- pytest.skip(fatal_error)
-
- print("\n\n** Check if FRR is running on each Router node")
- print("******************************************\n")
-
- # Starting Routers
- for i in range(1, 2):
- fatal_error = net["r%s" % i].checkRouterRunning()
- assert fatal_error == "", fatal_error
+ tgen = get_topogen()
- # For debugging after starting FRR daemons, uncomment the next line
- # CLI(net)
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
def test_bgp_converge():
"Check for BGP converged on all peers and BGP views"
- global fatal_error
- global net
+ tgen = get_topogen()
- # Skip if previous fatal error condition is raised
- if fatal_error != "":
- pytest.skip(fatal_error)
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
# Wait for BGP to converge (All Neighbors in either Full or TwoWay State)
@@ -224,7 +169,7 @@ def test_bgp_converge():
# Look for any node not yet converged
for i in range(1, 2):
for view in range(1, 4):
- notConverged = net["r%s" % i].cmd(
+ notConverged = tgen.net["r%s" % i].cmd(
'vtysh -c "show ip bgp view %s summary" 2> /dev/null | grep ^[0-9] | grep -vP " 11\s+(\d+)"'
% view
)
@@ -242,7 +187,7 @@ def test_bgp_converge():
break
else:
# Bail out with error if a router fails to converge
- bgpStatus = net["r%s" % i].cmd('vtysh -c "show ip bgp view %s summary"' % view)
+ bgpStatus = tgen.net["r%s" % i].cmd('vtysh -c "show ip bgp view %s summary"' % view)
assert False, "BGP did not converge:\n%s" % bgpStatus
# Wait for an extra 5s to announce all routes
@@ -256,53 +201,92 @@ def test_bgp_converge():
# print("\nwaiting 15s for routes to populate")
# sleep(15)
- # Make sure that all daemons are running
- for i in range(1, 2):
- fatal_error = net["r%s" % i].checkRouterRunning()
- assert fatal_error == "", fatal_error
-
- # For debugging after starting FRR daemons, uncomment the next line
- # CLI(net)
+ tgen.routers_have_failure()
def test_bgp_routingTable():
- global fatal_error
- global net
- # Skip if previous fatal error condition is raised
- if fatal_error != "":
- pytest.skip(fatal_error)
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
thisDir = os.path.dirname(os.path.realpath(__file__))
- print("Verifying BGP Routing Tables")
- def router_json_cmp(router, cmd, data):
- json_data = json.loads(router.cmd("vtysh -c \"{}\" 2> /dev/null".format(cmd)))
- return topotest.json_cmp(json_data, data)
- router = net["r1"]
- for view in range(1, 4):
- json_file = "{}/{}/view_{}.json".format(thisDir, router.name, view)
- expected = json.loads(open(json_file).read())
- test_func = partial(
- router_json_cmp, router, "show ip bgp view {} json".format(view), expected
- )
- _, result = topotest.run_and_expect(test_func, None, count=5, wait=1)
- assertmsg = "Routing Table verification failed for router {}, view {}".format(
- router.name, view
- )
- assert result is None, assertmsg
- # Make sure that all daemons are running
+
+ print("\n\n** Verifying BGP Routing Tables")
+ print("******************************************\n")
+ diffresult = {}
for i in range(1, 2):
- fatal_error = net["r%s" % i].checkRouterRunning()
- assert fatal_error == "", fatal_error
- # For debugging after starting FRR daemons, uncomment the next line
- # CLI(net)
+ for view in range(1, 4):
+ success = 0
+ # This glob pattern should work as long as number of views < 10
+ for refTableFile in glob.glob(
+ "%s/r%s/show_ip_bgp_view_%s*.ref" % (thisDir, i, view)
+ ):
+
+ if os.path.isfile(refTableFile):
+ # Read expected result from file
+ expected = open(refTableFile).read().rstrip()
+ # Fix newlines (make them all the same)
+ expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
+
+ # Actual output from router
+ actual = (
+ tgen.net["r%s" % i]
+ .cmd('vtysh -c "show ip bgp view %s" 2> /dev/null' % view)
+ .rstrip()
+ )
+
+ # Fix inconsitent spaces between 0.99.24 and newer versions
+ actual = re.sub("0 0", "0 0", actual)
+ actual = re.sub(
+ r"([0-9]) 32768", r"\1 32768", actual
+ )
+ # Remove summary line (changed recently)
+ actual = re.sub(r"Total number.*", "", actual)
+ actual = re.sub(r"Displayed.*", "", actual)
+ actual = actual.rstrip()
+ # Fix table version (ignore it)
+ actual = re.sub(r"(BGP table version is )[0-9]+", r"\1XXX", actual)
+
+ # Fix newlines (make them all the same)
+ actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1)
+
+ # Generate Diff
+ diff = topotest.get_textdiff(
+ actual,
+ expected,
+ title1="actual BGP routing table",
+ title2="expected BGP routing table",
+ )
+
+ if diff:
+ diffresult[refTableFile] = diff
+ else:
+ success = 1
+ print("template %s matched: r%s ok" % (refTableFile, i))
+ break
+
+ if not success:
+ resultstr = "No template matched.\n"
+ for f in diffresult.keys():
+ resultstr += (
+ "template %s: r%s failed Routing Table Check for view %s:\n%s\n"
+ % (f, i, view, diffresult[f])
+ )
+ raise AssertionError(
+ "Routing Table verification failed for router r%s, view %s:\n%s"
+ % (i, view, resultstr)
+ )
+
+ tgen.routers_have_failure()
def test_shutdown_check_stderr():
- global fatal_error
- global net
+ tgen = get_topogen()
# Skip if previous fatal error condition is raised
- if fatal_error != "":
- pytest.skip(fatal_error)
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
if os.environ.get("TOPOTESTS_CHECK_STDERR") is None:
print(
@@ -315,36 +299,22 @@ def test_shutdown_check_stderr():
print("\n\n** Verifying unexpected STDERR output from daemons")
print("******************************************\n")
- net["r1"].stopRouter()
+ tgen.net["r1"].stopRouter()
- log = net["r1"].getStdErr("bgpd")
+ log = tgen.net["r1"].getStdErr("bgpd")
if log:
print("\nBGPd StdErr Log:\n" + log)
- log = net["r1"].getStdErr("zebra")
+ log = tgen.net["r1"].getStdErr("zebra")
if log:
print("\nZebra StdErr Log:\n" + log)
def test_shutdown_check_memleak():
- global fatal_error
- global net
-
- # Skip if previous fatal error condition is raised
- if fatal_error != "":
- pytest.skip(fatal_error)
-
- if os.environ.get("TOPOTESTS_CHECK_MEMLEAK") is None:
- print(
- "SKIPPED final check on Memory leaks: Disabled (TOPOTESTS_CHECK_MEMLEAK undefined)\n"
- )
- pytest.skip("Skipping test for memory leaks")
-
- thisDir = os.path.dirname(os.path.realpath(__file__))
+ tgen = get_topogen()
+ if not tgen.is_memleak_enabled():
+ pytest.skip("Memory leak test/report is disabled")
- net["r1"].stopRouter()
- net["r1"].report_memory_leaks(
- os.environ.get("TOPOTESTS_CHECK_MEMLEAK"), os.path.basename(__file__)
- )
+ tgen.report_memory_leaks()
if __name__ == "__main__":
diff --git a/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py b/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py
index 0fc9b7e02..f34ecc30a 100644
--- a/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py
+++ b/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py
@@ -94,37 +94,14 @@ from lib.bgp import (
)
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
-jsonFile = "{}/bgp_path_attributes.json".format(CWD)
+pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Address read from env variables
ADDR_TYPES = check_address_types()
####
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # Building topology and configuration from json file
- build_topo_from_json(tgen, topo)
-
-
def setup_module(mod):
"""
Sets up the pytest environment
@@ -141,7 +118,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 = "{}/bgp_path_attributes.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py
index 70e49d5cd..172426b2c 100644
--- a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py
+++ b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py
@@ -42,21 +42,18 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py b/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py
index c5924c787..4cd14367b 100755
--- a/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py
+++ b/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py
@@ -76,32 +76,30 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-class PeerTypeRelaxTopo(Topo):
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # Set up routers
- tgen.add_router("r1") # DUT
- tgen.add_router("r2")
-
- # Set up peers
- for peern in range(1, 5):
- peer = tgen.add_exabgp_peer(
- "peer{}".format(peern),
- ip="10.0.{}.2/24".format(peern),
- defaultRoute="via 10.0.{}.1".format(peern),
- )
- if peern == 2:
- tgen.add_link(tgen.gears["r2"], peer)
- else:
- tgen.add_link(tgen.gears["r1"], peer)
- tgen.add_link(tgen.gears["r1"], tgen.gears["r2"])
+def build_topo(tgen):
+ "Build function"
+
+ # Set up routers
+ tgen.add_router("r1") # DUT
+ tgen.add_router("r2")
+
+ # Set up peers
+ for peern in range(1, 5):
+ peer = tgen.add_exabgp_peer(
+ "peer{}".format(peern),
+ ip="10.0.{}.2/24".format(peern),
+ defaultRoute="via 10.0.{}.1".format(peern),
+ )
+ if peern == 2:
+ tgen.add_link(tgen.gears["r2"], peer)
+ else:
+ tgen.add_link(tgen.gears["r1"], peer)
+ tgen.add_link(tgen.gears["r1"], tgen.gears["r2"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(PeerTypeRelaxTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
# For all registered routers, load the zebra configuration file
diff --git a/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py b/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py
index 287ff87bf..f046f442e 100644
--- a/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py
+++ b/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py
@@ -73,37 +73,14 @@ from lib.topolog import logger
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify
from lib.topojson import build_topo_from_json, build_config_from_json
-pytestmark = [pytest.mark.bgpd]
-
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/prefix_lists.json".format(CWD)
+pytestmark = [pytest.mark.bgpd]
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
bgp_convergence = False
-class BGPPrefixListTopo(Topo):
- """
- Test BGPPrefixListTopo - topology 1
-
- * `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
@@ -118,7 +95,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(BGPPrefixListTopo, mod.__name__)
+ json_file = "{}/prefix_lists.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py b/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py
index 72df2eab6..8acf7feae 100644
--- a/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py
+++ b/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py
@@ -44,26 +44,24 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, **_opts):
- tgen = get_topogen(self)
- router = tgen.add_router("r1")
- switch = tgen.add_switch("s1")
- switch.add_link(router)
-
- switch = tgen.gears["s1"]
- peer1 = tgen.add_exabgp_peer(
- "peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
- )
- peer2 = tgen.add_exabgp_peer(
- "peer2", ip="10.0.0.102", defaultRoute="via 10.0.0.1"
- )
- switch.add_link(peer1)
- switch.add_link(peer2)
+def build_topo(tgen):
+ router = tgen.add_router("r1")
+ switch = tgen.add_switch("s1")
+ switch.add_link(router)
+
+ switch = tgen.gears["s1"]
+ peer1 = tgen.add_exabgp_peer(
+ "peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
+ )
+ peer2 = tgen.add_exabgp_peer(
+ "peer2", ip="10.0.0.102", defaultRoute="via 10.0.0.1"
+ )
+ switch.add_link(peer1)
+ switch.add_link(peer2)
def setup_module(module):
- tgen = Topogen(TemplateTopo, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
router = tgen.gears["r1"]
diff --git a/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py b/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py
index 6da44faf5..5c85895ed 100755
--- a/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py
+++ b/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py
@@ -44,22 +44,20 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, **_opts):
- tgen = get_topogen(self)
- router = tgen.add_router("r1")
- switch = tgen.add_switch("s1")
- switch.add_link(router)
-
- switch = tgen.gears["s1"]
- peer1 = tgen.add_exabgp_peer(
- "peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
- )
- switch.add_link(peer1)
+def build_topo(tgen):
+ router = tgen.add_router("r1")
+ switch = tgen.add_switch("s1")
+ switch.add_link(router)
+
+ switch = tgen.gears["s1"]
+ peer1 = tgen.add_exabgp_peer(
+ "peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
+ )
+ switch.add_link(peer1)
def setup_module(module):
- tgen = Topogen(TemplateTopo, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
router = tgen.gears["r1"]
diff --git a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py
index 320c7eb78..918c16e34 100644
--- a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py
+++ b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py
@@ -89,14 +89,6 @@ 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 and configuration creation
-jsonFile = "{}/bgp_recursive_route_ebgp_multi_hop.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- logger.info("Could not read file:", jsonFile)
-
# Global variables
BGP_CONVERGENCE = False
KEEP_ALIVE_TIMER = 2
@@ -124,21 +116,6 @@ Loopabck_IP = {
}
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -153,7 +130,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 = "{}/bgp_recursive_route_ebgp_multi_hop.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py b/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py
index f13b068d9..271db0a7c 100644
--- a/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py
+++ b/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py
@@ -53,24 +53,21 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_rfapi_basic_sanity/customize.py b/tests/topotests/bgp_rfapi_basic_sanity/customize.py
index 9166c57df..3cf53a184 100644
--- a/tests/topotests/bgp_rfapi_basic_sanity/customize.py
+++ b/tests/topotests/bgp_rfapi_basic_sanity/customize.py
@@ -81,35 +81,31 @@ CWD = os.path.dirname(os.path.realpath(__file__))
TEST = os.path.basename(CWD)
-class ThisTestTopo(Topo):
- "Test topology builder"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- # Create P/PE routers
- tgen.add_router("r1")
- for routern in range(2, 5):
- tgen.add_router("r{}".format(routern))
- # Create a switch with just one router connected to it to simulate a
- # empty network.
- switch = {}
- switch[0] = tgen.add_switch("sw0")
- switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
- switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
-
- switch[1] = tgen.add_switch("sw1")
- switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
- switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
- switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
-
- switch[2] = tgen.add_switch("sw2")
- switch[2].add_link(tgen.gears["r2"], nodeif="r2-eth2")
- switch[2].add_link(tgen.gears["r3"], nodeif="r3-eth1")
+def build_topo(tgen):
+ "Build function"
+
+ # This function only purpose is to define allocation and relationship
+ # between routers, switches and hosts.
+ #
+ # Create P/PE routers
+ tgen.add_router("r1")
+ for routern in range(2, 5):
+ tgen.add_router("r{}".format(routern))
+ # Create a switch with just one router connected to it to simulate a
+ # empty network.
+ switch = {}
+ switch[0] = tgen.add_switch("sw0")
+ switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
+ switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
+
+ switch[1] = tgen.add_switch("sw1")
+ switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
+ switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
+ switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
+
+ switch[2] = tgen.add_switch("sw2")
+ switch[2].add_link(tgen.gears["r2"], nodeif="r2-eth2")
+ switch[2].add_link(tgen.gears["r3"], nodeif="r3-eth1")
def ltemplatePreRouterStartHook():
diff --git a/tests/topotests/bgp_rmap_extcommunity_none/test_bgp_rmap_extcommunity_none.py b/tests/topotests/bgp_rmap_extcommunity_none/test_bgp_rmap_extcommunity_none.py
index 3c11ba74c..d2a602f9a 100644
--- a/tests/topotests/bgp_rmap_extcommunity_none/test_bgp_rmap_extcommunity_none.py
+++ b/tests/topotests/bgp_rmap_extcommunity_none/test_bgp_rmap_extcommunity_none.py
@@ -41,25 +41,21 @@ sys.path.append(os.path.join(CWD, "../"))
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
-from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py
index 8297085ff..007e640f5 100644
--- a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py
+++ b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py
@@ -70,16 +70,8 @@ from lib.bgp import (
)
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 and configuration creation
-jsonFile = "{}/bgp_aggregation.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- logger.info("Could not read file:", jsonFile)
+pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Global variables
BGP_CONVERGENCE = False
@@ -113,21 +105,6 @@ COMMUNITY = [
]
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -142,7 +119,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 = "{}/bgp_aggregation.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_route_map/test_route_map_topo1.py b/tests/topotests/bgp_route_map/test_route_map_topo1.py
index 17058d178..ba4456e71 100644
--- a/tests/topotests/bgp_route_map/test_route_map_topo1.py
+++ b/tests/topotests/bgp_route_map/test_route_map_topo1.py
@@ -115,13 +115,6 @@ TC_38:
bgp_convergence = False
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
-# Reading the data from JSON File for topology and configuration creation
-jsonFile = "{}/bgp_route_map_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
bgp_convergence = False
@@ -131,22 +124,6 @@ NEXT_HOP = {"ipv4": "10.0.0.2", "ipv6": "fd00::2"}
ADDR_TYPES = check_address_types()
-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
@@ -161,7 +138,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 = "{}/bgp_route_map_topo1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_route_map/test_route_map_topo2.py b/tests/topotests/bgp_route_map/test_route_map_topo2.py
index d4b145e81..ca05ba45d 100644
--- a/tests/topotests/bgp_route_map/test_route_map_topo2.py
+++ b/tests/topotests/bgp_route_map/test_route_map_topo2.py
@@ -147,17 +147,8 @@ from lib.bgp import (
)
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 and configuration creation
-jsonFile = "{}/bgp_route_map_topo2.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Global variables
# Global variables
@@ -169,21 +160,6 @@ BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
-class BGPRmapTopo(Topo):
- """BGPRmapTopo.
-
- BGPRmap topology 1
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- """Build function."""
- tgen = get_topogen(self)
-
- # Building topology and configuration from json file
- build_topo_from_json(tgen, topo)
-
-
def setup_module(mod):
"""setup_module.
@@ -197,7 +173,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(BGPRmapTopo, mod.__name__)
+ json_file = "{}/bgp_route_map_topo2.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py b/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py
index 72c25a3c6..d40ea2ed8 100644
--- a/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py
+++ b/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py
@@ -49,48 +49,37 @@ from lib.topolog import logger
# Required to instantiate the topology builder class.
from lib.micronet_compat import Topo
-pytestmark = [pytest.mark.bgpd]
-
-#####################################################
-##
-## Network Topology Definition
-##
-#####################################################
-
-
-class NetworkTopo(Topo):
- "BGP_RR_IBGP Topology 1"
+pytestmark = [pytest.mark.bgpd]
- def build(self, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- tgen.add_router("tor1")
- tgen.add_router("tor2")
- tgen.add_router("spine1")
+ tgen.add_router("tor1")
+ tgen.add_router("tor2")
+ tgen.add_router("spine1")
- # First switch is for a dummy interface (for local network)
- # on tor1
- # 192.168.1.0/24
- switch = tgen.add_switch("sw1")
- switch.add_link(tgen.gears["tor1"])
+ # First switch is for a dummy interface (for local network)
+ # on tor1
+ # 192.168.1.0/24
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["tor1"])
- # 192.168.2.0/24 - tor1 <-> spine1 connection
- switch = tgen.add_switch("sw2")
- switch.add_link(tgen.gears["tor1"])
- switch.add_link(tgen.gears["spine1"])
+ # 192.168.2.0/24 - tor1 <-> spine1 connection
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["tor1"])
+ switch.add_link(tgen.gears["spine1"])
- # 3rd switch is for a dummy interface (for local netwokr)
- # 192.168.3.0/24 - tor2
- switch = tgen.add_switch("sw3")
- switch.add_link(tgen.gears["tor2"])
+ # 3rd switch is for a dummy interface (for local netwokr)
+ # 192.168.3.0/24 - tor2
+ switch = tgen.add_switch("sw3")
+ switch.add_link(tgen.gears["tor2"])
- # 192.168.4.0/24 - tor2 <-> spine1 connection
- switch = tgen.add_switch("sw4")
- switch.add_link(tgen.gears["tor2"])
- switch.add_link(tgen.gears["spine1"])
+ # 192.168.4.0/24 - tor2 <-> spine1 connection
+ switch = tgen.add_switch("sw4")
+ switch.add_link(tgen.gears["tor2"])
+ switch.add_link(tgen.gears["spine1"])
#####################################################
@@ -102,7 +91,7 @@ class NetworkTopo(Topo):
def setup_module(module):
"Setup topology"
- tgen = Topogen(NetworkTopo, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# This is a sample of configuration loading.
diff --git a/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py b/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py
index 526e1202d..9d3c3a765 100644
--- a/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py
+++ b/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py
@@ -47,24 +47,21 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py b/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py
index 531e1814a..0ef5f61d9 100644
--- a/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py
+++ b/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py
@@ -47,21 +47,18 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py b/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py
index 37486f1d7..7f58c65ab 100755
--- a/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py
+++ b/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py
@@ -50,75 +50,71 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp]
-class TemplateTopo(Topo):
- "Test topology builder"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- #
- # Create routers
- tgen.add_router("r1")
- tgen.add_router("r2")
- tgen.add_router("r3")
- tgen.add_router("r4")
- tgen.add_router("ce1")
- tgen.add_router("ce2")
- tgen.add_router("ce3")
- tgen.add_router("ce4")
-
- # r1-r2
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- # r1-r3
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r3"])
-
- # r1-r4
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r4"])
-
- # r1-ce1
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["ce1"])
-
- # r1-ce3
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["ce3"])
-
- # r1-ce4
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["ce4"])
-
- # r1-dangling
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["r1"])
-
- # r2-r3
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
-
- # r3-r4
- switch = tgen.add_switch("s9")
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
-
- # r4-ce2
- switch = tgen.add_switch("s10")
- switch.add_link(tgen.gears["r4"])
- switch.add_link(tgen.gears["ce2"])
+def build_topo(tgen):
+ "Build function"
+
+ # This function only purpose is to define allocation and relationship
+ # between routers, switches and hosts.
+ #
+ #
+ # Create routers
+ tgen.add_router("r1")
+ tgen.add_router("r2")
+ tgen.add_router("r3")
+ tgen.add_router("r4")
+ tgen.add_router("ce1")
+ tgen.add_router("ce2")
+ tgen.add_router("ce3")
+ tgen.add_router("ce4")
+
+ # r1-r2
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+
+ # r1-r3
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
+
+ # r1-r4
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r4"])
+
+ # r1-ce1
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["ce1"])
+
+ # r1-ce3
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["ce3"])
+
+ # r1-ce4
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["ce4"])
+
+ # r1-dangling
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["r1"])
+
+ # r2-r3
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+
+ # r3-r4
+ switch = tgen.add_switch("s9")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
+
+ # r4-ce2
+ switch = tgen.add_switch("s10")
+ switch.add_link(tgen.gears["r4"])
+ switch.add_link(tgen.gears["ce2"])
def setup_module(mod):
@@ -131,7 +127,7 @@ def setup_module(mod):
pytest.skip(error_msg)
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py
index a50151ab2..60e419ab1 100755
--- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py
+++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py
@@ -42,7 +42,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class Topology(Topo):
+def build_topo(tgen):
"""
CE1 CE3 CE5
(eth0) (eth0) (eth0)
@@ -79,24 +79,22 @@ class Topology(Topo):
(eth0) (eth0) (eth0)
CE2 CE4 CE6
"""
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
- tgen.add_router("r1")
- tgen.add_router("r2")
- tgen.add_router("ce1")
- tgen.add_router("ce2")
- tgen.add_router("ce3")
- tgen.add_router("ce4")
- tgen.add_router("ce5")
- tgen.add_router("ce6")
-
- tgen.add_link(tgen.gears["r1"], tgen.gears["r2"], "eth0", "eth0")
- tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "eth0", "eth1")
- tgen.add_link(tgen.gears["ce2"], tgen.gears["r2"], "eth0", "eth1")
- tgen.add_link(tgen.gears["ce3"], tgen.gears["r1"], "eth0", "eth2")
- tgen.add_link(tgen.gears["ce4"], tgen.gears["r2"], "eth0", "eth2")
- tgen.add_link(tgen.gears["ce5"], tgen.gears["r1"], "eth0", "eth3")
- tgen.add_link(tgen.gears["ce6"], tgen.gears["r2"], "eth0", "eth3")
+ tgen.add_router("r1")
+ tgen.add_router("r2")
+ tgen.add_router("ce1")
+ tgen.add_router("ce2")
+ tgen.add_router("ce3")
+ tgen.add_router("ce4")
+ tgen.add_router("ce5")
+ tgen.add_router("ce6")
+
+ tgen.add_link(tgen.gears["r1"], tgen.gears["r2"], "eth0", "eth0")
+ tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "eth0", "eth1")
+ tgen.add_link(tgen.gears["ce2"], tgen.gears["r2"], "eth0", "eth1")
+ tgen.add_link(tgen.gears["ce3"], tgen.gears["r1"], "eth0", "eth2")
+ tgen.add_link(tgen.gears["ce4"], tgen.gears["r2"], "eth0", "eth2")
+ tgen.add_link(tgen.gears["ce5"], tgen.gears["r1"], "eth0", "eth3")
+ tgen.add_link(tgen.gears["ce6"], tgen.gears["r2"], "eth0", "eth3")
def setup_module(mod):
@@ -104,7 +102,7 @@ def setup_module(mod):
if result is not True:
pytest.skip("Kernel requirements are not met")
- tgen = Topogen(Topology, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
for rname, router in tgen.routers().items():
diff --git a/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py b/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py
index 3e421ad5c..2c14ad9de 100644
--- a/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py
+++ b/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py
@@ -43,24 +43,21 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py b/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py
index 7ca30daf4..db90bbd5d 100644
--- a/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py
+++ b/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py
@@ -54,20 +54,17 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_update_delay/test_bgp_update_delay.py b/tests/topotests/bgp_update_delay/test_bgp_update_delay.py
index a936d44d1..31a887b6c 100644
--- a/tests/topotests/bgp_update_delay/test_bgp_update_delay.py
+++ b/tests/topotests/bgp_update_delay/test_bgp_update_delay.py
@@ -76,32 +76,30 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class TemplateTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
-
- for routern in range(1, 6):
- tgen.add_router("r{}".format(routern))
+CWD = os.path.dirname(os.path.realpath(__file__))
+def build_topo(tgen):
+ for routern in range(1, 6):
+ tgen.add_router("r{}".format(routern))
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r5"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r5"])
def setup_module(mod):
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py
index 63e724cc5..b2e2250a9 100644
--- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py
+++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py
@@ -81,16 +81,8 @@ from lib.bgp import (
)
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
-jsonFile = "{}/bgp_vrf_dynamic_route_leak_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Global variables
NETWORK1_1 = {"ipv4": "11.11.11.1/32", "ipv6": "11:11::1/128"}
@@ -125,21 +117,6 @@ LOOPBACK_2 = {
PREFERRED_NEXT_HOP = "global"
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -147,7 +124,6 @@ def setup_module(mod):
* `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)
@@ -155,7 +131,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 = "{}/bgp_vrf_dynamic_route_leak_topo1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py
index 1241a37cf..8e3e32fc8 100644
--- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py
+++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py
@@ -97,19 +97,11 @@ NETWORK3_4 = {"ipv4": "50.50.50.50/32", "ipv6": "50:50::50/128"}
PREFERRED_NEXT_HOP = "global"
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- """Build function"""
- tgen = get_topogen(self)
+def build_topo(tgen):
+ """Build function"""
- # Building topology from json file
- build_topo_from_json(tgen, topo)
+ # Building topology from json file
+ build_topo_from_json(tgen, topo)
def setup_module(mod):
@@ -127,7 +119,7 @@ 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__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py b/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py
index b818816d9..5d6a5859c 100644
--- a/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py
+++ b/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py
@@ -50,20 +50,16 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd]
-class BGPIPV6RTADVVRFTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 2 routers.
+ tgen.add_router("r1")
+ tgen.add_router("r2")
- # Create 2 routers.
- tgen.add_router("r1")
- tgen.add_router("r2")
-
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
@@ -74,7 +70,7 @@ def setup_module(mod):
if result is not True:
pytest.skip("Kernel requirements are not met")
- tgen = Topogen(BGPIPV6RTADVVRFTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py b/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py
index 9c4c78bf1..d0011f9df 100644
--- a/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py
+++ b/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py
@@ -57,25 +57,19 @@ CustomizeVrfWithNetns = True
#####################################################
-class BGPVRFNETNSTopo1(Topo):
- "BGP EBGP VRF NETNS Topology 1"
+def build_topo(tgen):
+ tgen.add_router("r1")
- def build(self, **_opts):
- tgen = get_topogen(self)
+ # Setup Switches
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
- # Setup Routers
- tgen.add_router("r1")
-
- # Setup Switches
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
-
- # Add eBGP ExaBGP neighbors
- peer_ip = "10.0.1.101"
- peer_route = "via 10.0.1.1"
- peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
- switch = tgen.gears["s1"]
- switch.add_link(peer)
+ # Add eBGP ExaBGP neighbors
+ peer_ip = "10.0.1.101"
+ peer_route = "via 10.0.1.1"
+ peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
+ switch = tgen.gears["s1"]
+ switch.add_link(peer)
#####################################################
@@ -86,7 +80,7 @@ class BGPVRFNETNSTopo1(Topo):
def setup_module(module):
- tgen = Topogen(BGPVRFNETNSTopo1, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# Get r1 reference
diff --git a/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py b/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py
index 7ab2c608b..66a52841f 100644
--- a/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py
+++ b/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py
@@ -41,21 +41,20 @@ from lib.topolog import logger
from lib.micronet_compat import Topo
+
pytestmark = [pytest.mark.bgpd]
-class BGPVRFTopo(Topo):
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- for routern in range(1, 2):
- tgen.add_router("r{}".format(routern))
+ for routern in range(1, 2):
+ tgen.add_router("r{}".format(routern))
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(BGPVRFTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
# For all registered routers, load the zebra configuration file
diff --git a/tests/topotests/config_timing/test_config_timing.py b/tests/topotests/config_timing/test_config_timing.py
index 54dca32e1..b68f52bbd 100644
--- a/tests/topotests/config_timing/test_config_timing.py
+++ b/tests/topotests/config_timing/test_config_timing.py
@@ -49,16 +49,14 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.staticd]
-class TimingTopo(Topo):
- def build(self, *_args, **_opts):
- tgen = get_topogen(self)
- tgen.add_router("r1")
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
+def build_topo(tgen):
+ tgen.add_router("r1")
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
def setup_module(mod):
- tgen = Topogen(TimingTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/eigrp_topo1/test_eigrp_topo1.py b/tests/topotests/eigrp_topo1/test_eigrp_topo1.py
index 982d3f0fa..f97b1f2da 100644
--- a/tests/topotests/eigrp_topo1/test_eigrp_topo1.py
+++ b/tests/topotests/eigrp_topo1/test_eigrp_topo1.py
@@ -55,36 +55,29 @@ from lib.micronet_compat import Topo
#####################################################
-class NetworkTopo(Topo):
- "EIGRP Topology 1"
+def build_topo(tgen):
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- def build(self, **_opts):
- "Build function"
+ # On main router
+ # First switch is for a dummy interface (for local network)
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["r1"])
- tgen = get_topogen(self)
+ # Switches for EIGRP
+ # switch 2 switch is for connection to EIGRP router
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
+ # switch 4 is stub on remote EIGRP router
+ switch = tgen.add_switch("sw4")
+ switch.add_link(tgen.gears["r3"])
- # On main router
- # First switch is for a dummy interface (for local network)
- switch = tgen.add_switch("sw1")
- switch.add_link(tgen.gears["r1"])
-
- # Switches for EIGRP
- # switch 2 switch is for connection to EIGRP router
- switch = tgen.add_switch("sw2")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- # switch 4 is stub on remote EIGRP router
- switch = tgen.add_switch("sw4")
- switch.add_link(tgen.gears["r3"])
-
- # switch 3 is between EIGRP routers
- switch = tgen.add_switch("sw3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ # switch 3 is between EIGRP routers
+ switch = tgen.add_switch("sw3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
#####################################################
@@ -96,7 +89,7 @@ class NetworkTopo(Topo):
def setup_module(module):
"Setup topology"
- tgen = Topogen(NetworkTopo, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# This is a sample of configuration loading.
diff --git a/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py b/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py
index e549d1acb..216494d4e 100644
--- a/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py
+++ b/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py
@@ -59,41 +59,34 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.bgpd]
#####################################################
-class NetworkTopo(Topo):
- "evpn-pim Topology 1"
-
- def build(self, **_opts):
- "Build function"
-
- tgen = get_topogen(self)
-
- tgen.add_router("spine")
- tgen.add_router("leaf1")
- tgen.add_router("leaf2")
- tgen.add_router("host1")
- tgen.add_router("host2")
-
- # On main router
- # First switch is for a dummy interface (for local network)
- # spine-eth0 is connected to leaf1-eth0
- switch = tgen.add_switch("sw1")
- switch.add_link(tgen.gears["spine"])
- switch.add_link(tgen.gears["leaf1"])
-
- # spine-eth1 is connected to leaf2-eth0
- switch = tgen.add_switch("sw2")
- switch.add_link(tgen.gears["spine"])
- switch.add_link(tgen.gears["leaf2"])
-
- # leaf1-eth1 is connected to host1-eth0
- switch = tgen.add_switch("sw3")
- switch.add_link(tgen.gears["leaf1"])
- switch.add_link(tgen.gears["host1"])
-
- # leaf2-eth1 is connected to host2-eth0
- switch = tgen.add_switch("sw4")
- switch.add_link(tgen.gears["leaf2"])
- switch.add_link(tgen.gears["host2"])
+def build_topo(tgen):
+ tgen.add_router("spine")
+ tgen.add_router("leaf1")
+ tgen.add_router("leaf2")
+ tgen.add_router("host1")
+ tgen.add_router("host2")
+
+ # On main router
+ # First switch is for a dummy interface (for local network)
+ # spine-eth0 is connected to leaf1-eth0
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["spine"])
+ switch.add_link(tgen.gears["leaf1"])
+
+ # spine-eth1 is connected to leaf2-eth0
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["spine"])
+ switch.add_link(tgen.gears["leaf2"])
+
+ # leaf1-eth1 is connected to host1-eth0
+ switch = tgen.add_switch("sw3")
+ switch.add_link(tgen.gears["leaf1"])
+ switch.add_link(tgen.gears["host1"])
+
+ # leaf2-eth1 is connected to host2-eth0
+ switch = tgen.add_switch("sw4")
+ switch.add_link(tgen.gears["leaf2"])
+ switch.add_link(tgen.gears["host2"])
#####################################################
@@ -105,7 +98,7 @@ class NetworkTopo(Topo):
def setup_module(module):
"Setup topology"
- tgen = Topogen(NetworkTopo, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
leaf1 = tgen.gears["leaf1"]
diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py
index d72b28e84..83c415c0f 100644
--- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py
+++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py
@@ -85,16 +85,8 @@ from lib.bgp import (
)
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
-jsonFile = "{}/evpn_type5_chaos_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
# Global variables
@@ -139,21 +131,6 @@ BRCTL = {
}
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -161,7 +138,6 @@ def setup_module(mod):
* `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)
@@ -169,7 +145,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 = "{}/evpn_type5_chaos_topo1.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py
index fda39be91..3a101b453 100644
--- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py
+++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py
@@ -142,19 +142,8 @@ BRCTL = {
}
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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 build_topo(tgen):
+ build_topo_from_json(tgen, topo)
def setup_module(mod):
@@ -172,7 +161,7 @@ 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__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/example_test/test_template.py b/tests/topotests/example_test/test_template.py
index 534dd998d..7bd434d75 100644
--- a/tests/topotests/example_test/test_template.py
+++ b/tests/topotests/example_test/test_template.py
@@ -30,19 +30,10 @@ import os
import sys
import pytest
-# Save the Current Working Directory to find configuration files.
-CWD = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.join(CWD, "../"))
-
-# pylint: disable=C0413
# Import topogen and topotest helpers
-from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
-# Required to instantiate the topology builder class.
-from lib.micronet_compat import Topo
-
# TODO: select markers based on daemons used during test
# pytest module level markers
@@ -56,37 +47,40 @@ pytestmark = [
"""
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 2 routers
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- # This function only purpose is to define allocation and relationship
- # between routers, switches and hosts.
- #
- # Example
- #
- # Create 2 routers
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
+ # Create a switch with just one router connected to it to simulate a
+ # empty network.
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
- # Create a switch with just one router connected to it to simulate a
- # empty network.
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
-
- # Create a connection between r1 and r2
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ # Create a connection between r1 and r2
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
"Sets up the pytest environment"
+
+
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
+
+ # The basic topology above could also have be more easily specified using a
+ # dictionary, remove the build_topo function and use the following instead:
+ #
+ # topodef = {
+ # "s1": "r1"
+ # "s2": ("r1", "r2")
+ # }
+ # tgen = Topogen(topodef, mod.__name__)
+
# ... and here it calls initialization functions.
tgen.start_topology()
@@ -94,6 +88,7 @@ def setup_module(mod):
router_list = tgen.routers()
# For all registred routers, load the zebra configuration file
+ # CWD = os.path.dirname(os.path.realpath(__file__))
for rname, router in router_list.items():
router.load_config(
TopoRouter.RD_ZEBRA,
diff --git a/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py b/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py
index b08861637..11b58301d 100755
--- a/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py
+++ b/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py
@@ -79,27 +79,19 @@ bgp_convergence = False
input_dict = {}
-class TemplateTopo(Topo):
- """
- Test topology builder
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- # This function only purpose is to create topology
- # as defined in input json file.
- #
- # Example
- #
- # Creating 2 routers having 2 links in between,
- # one is used to establised BGP neighborship
+ # This function only purpose is to create topology
+ # as defined in input json file.
+ #
+ # Example
+ #
+ # Creating 2 routers having 2 links in between,
+ # one is used to establised BGP neighborship
- # Building topology from json file
- build_topo_from_json(tgen, topo)
+ # Building topology from json file
+ build_topo_from_json(tgen, topo)
def setup_module(mod):
@@ -116,7 +108,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py b/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py
index 4b13dce7d..82cc9bd94 100755
--- a/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py
+++ b/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py
@@ -79,27 +79,19 @@ bgp_convergence = False
input_dict = {}
-class TemplateTopo(Topo):
- """
- Test topology builder
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- # This function only purpose is to create topology
- # as defined in input json file.
- #
- # Example
- #
- # Creating 2 routers having single links in between,
- # which is used to establised BGP neighborship
+ # This function only purpose is to create topology
+ # as defined in input json file.
+ #
+ # Example
+ #
+ # Creating 2 routers having single links in between,
+ # which is used to establised BGP neighborship
- # Building topology from json file
- build_topo_from_json(tgen, topo)
+ # Building topology from json file
+ build_topo_from_json(tgen, topo)
def setup_module(mod):
@@ -116,7 +108,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py b/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py
index 07d13cb71..9ab9f77f0 100755
--- a/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py
+++ b/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py
@@ -81,27 +81,19 @@ bgp_convergence = False
input_dict = {}
-class TemplateTopo(Topo):
- """
- Test topology builder
-
- * `Topo`: Topology object
- """
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- # This function only purpose is to create topology
- # as defined in input json file.
- #
- # Example
- #
- # Creating 2 routers having single links in between,
- # which is used to establised BGP neighborship
+ # This function only purpose is to create topology
+ # as defined in input json file.
+ #
+ # Example
+ #
+ # Creating 2 routers having single links in between,
+ # which is used to establised BGP neighborship
- # Building topology from json file
- build_topo_from_json(tgen, topo)
+ # Building topology from json file
+ build_topo_from_json(tgen, topo)
def setup_module(mod):
@@ -118,7 +110,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py
index 5555b1dca..07391ec2b 100755
--- a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py
+++ b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py
@@ -164,7 +164,7 @@ def build_topo(tgen):
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py b/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py
index df174e953..b86a2cf31 100755
--- a/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py
+++ b/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py
@@ -91,51 +91,47 @@ pytestmark = [pytest.mark.isisd]
outputs = {}
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2")
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3")
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
-
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py b/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py
index e2cb080eb..39a03a3e9 100755
--- a/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py
+++ b/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py
@@ -166,7 +166,7 @@ def build_topo(tgen):
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/isis_snmp/test_isis_snmp.py b/tests/topotests/isis_snmp/test_isis_snmp.py
index 6ca5928fd..cb8705e5b 100755
--- a/tests/topotests/isis_snmp/test_isis_snmp.py
+++ b/tests/topotests/isis_snmp/test_isis_snmp.py
@@ -85,45 +85,41 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.isisd, pytest.mark.ldpd, pytest.mark.snmp]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["ce3", "r1", "r2", "r3", "r4", "r5"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["ce3", "r1", "r2", "r3", "r4", "r5"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r4"])
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r5"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r5"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["ce3"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["ce3"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r4"])
+ switch.add_link(tgen.gears["r5"])
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r4"])
- switch.add_link(tgen.gears["r5"])
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
@@ -135,7 +131,7 @@ def setup_module(mod):
pytest.skip(error_msg)
# This function initiates the topology build with Topogen...
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
diff --git a/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py
index 260457b67..c653d5286 100755
--- a/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py
+++ b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py
@@ -99,64 +99,60 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.pathd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "dst"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "dst"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
- 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):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
frrdir = tgen.config.get(tgen.CONFIG_SECTION, "frrdir")
if not os.path.isfile(os.path.join(frrdir, "pathd")):
diff --git a/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py b/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py
index 8aa187871..a8956bb57 100644
--- a/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py
+++ b/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py
@@ -87,59 +87,55 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.isisd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
-
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py b/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py
index 351bce99e..37ce25312 100755
--- a/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py
+++ b/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py
@@ -178,7 +178,7 @@ def build_topo(tgen):
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/isis_topo1/test_isis_topo1.py b/tests/topotests/isis_topo1/test_isis_topo1.py
index 29021c562..34bc3830f 100644
--- a/tests/topotests/isis_topo1/test_isis_topo1.py
+++ b/tests/topotests/isis_topo1/test_isis_topo1.py
@@ -61,48 +61,44 @@ VERTEX_TYPE_LIST = [
]
-class ISISTopo1(Topo):
- "Simple two layer ISIS topology"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # Add ISIS routers:
- # r1 r2
- # | sw1 | sw2
- # r3 r4
- # | |
- # sw3 sw4
- # \ /
- # r5
- for routern in range(1, 6):
- tgen.add_router("r{}".format(routern))
-
- # r1 <- sw1 -> r3
- sw = tgen.add_switch("sw1")
- sw.add_link(tgen.gears["r1"])
- sw.add_link(tgen.gears["r3"])
-
- # r2 <- sw2 -> r4
- sw = tgen.add_switch("sw2")
- sw.add_link(tgen.gears["r2"])
- sw.add_link(tgen.gears["r4"])
-
- # r3 <- sw3 -> r5
- sw = tgen.add_switch("sw3")
- sw.add_link(tgen.gears["r3"])
- sw.add_link(tgen.gears["r5"])
-
- # r4 <- sw4 -> r5
- sw = tgen.add_switch("sw4")
- sw.add_link(tgen.gears["r4"])
- sw.add_link(tgen.gears["r5"])
+def build_topo(tgen):
+ "Build function"
+
+ # Add ISIS routers:
+ # r1 r2
+ # | sw1 | sw2
+ # r3 r4
+ # | |
+ # sw3 sw4
+ # \ /
+ # r5
+ for routern in range(1, 6):
+ tgen.add_router("r{}".format(routern))
+
+ # r1 <- sw1 -> r3
+ sw = tgen.add_switch("sw1")
+ sw.add_link(tgen.gears["r1"])
+ sw.add_link(tgen.gears["r3"])
+
+ # r2 <- sw2 -> r4
+ sw = tgen.add_switch("sw2")
+ sw.add_link(tgen.gears["r2"])
+ sw.add_link(tgen.gears["r4"])
+
+ # r3 <- sw3 -> r5
+ sw = tgen.add_switch("sw3")
+ sw.add_link(tgen.gears["r3"])
+ sw.add_link(tgen.gears["r5"])
+
+ # r4 <- sw4 -> r5
+ sw = tgen.add_switch("sw4")
+ sw.add_link(tgen.gears["r4"])
+ sw.add_link(tgen.gears["r5"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(ISISTopo1, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
# For all registered routers, load the zebra configuration file
diff --git a/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py b/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py
index 9c15ee342..620fc333b 100644
--- a/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py
+++ b/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py
@@ -61,48 +61,44 @@ VERTEX_TYPE_LIST = [
]
-class ISISTopo1(Topo):
- "Simple two layer ISIS vrf topology"
-
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # Add ISIS routers:
- # r1 r2
- # | sw1 | sw2
- # r3 r4
- # | |
- # sw3 sw4
- # \ /
- # r5
- for routern in range(1, 6):
- tgen.add_router("r{}".format(routern))
-
- # r1 <- sw1 -> r3
- sw = tgen.add_switch("sw1")
- sw.add_link(tgen.gears["r1"])
- sw.add_link(tgen.gears["r3"])
-
- # r2 <- sw2 -> r4
- sw = tgen.add_switch("sw2")
- sw.add_link(tgen.gears["r2"])
- sw.add_link(tgen.gears["r4"])
-
- # r3 <- sw3 -> r5
- sw = tgen.add_switch("sw3")
- sw.add_link(tgen.gears["r3"])
- sw.add_link(tgen.gears["r5"])
-
- # r4 <- sw4 -> r5
- sw = tgen.add_switch("sw4")
- sw.add_link(tgen.gears["r4"])
- sw.add_link(tgen.gears["r5"])
+def build_topo(tgen):
+ "Build function"
+
+ # Add ISIS routers:
+ # r1 r2
+ # | sw1 | sw2
+ # r3 r4
+ # | |
+ # sw3 sw4
+ # \ /
+ # r5
+ for routern in range(1, 6):
+ tgen.add_router("r{}".format(routern))
+
+ # r1 <- sw1 -> r3
+ sw = tgen.add_switch("sw1")
+ sw.add_link(tgen.gears["r1"])
+ sw.add_link(tgen.gears["r3"])
+
+ # r2 <- sw2 -> r4
+ sw = tgen.add_switch("sw2")
+ sw.add_link(tgen.gears["r2"])
+ sw.add_link(tgen.gears["r4"])
+
+ # r3 <- sw3 -> r5
+ sw = tgen.add_switch("sw3")
+ sw.add_link(tgen.gears["r3"])
+ sw.add_link(tgen.gears["r5"])
+
+ # r4 <- sw4 -> r5
+ sw = tgen.add_switch("sw4")
+ sw.add_link(tgen.gears["r4"])
+ sw.add_link(tgen.gears["r5"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(ISISTopo1, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
logger.info("Testing with VRF Lite support")
diff --git a/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py b/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py
index f26c56e54..42ba24f78 100644
--- a/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py
+++ b/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py
@@ -81,39 +81,35 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["r1", "r2", "r3", "r4"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["r1", "r2", "r3", "r4"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s0")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- #
- # Define connections
- #
- switch = tgen.add_switch("s0")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py b/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py
index 5208728a9..78e231b60 100644
--- a/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py
+++ b/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py
@@ -81,39 +81,35 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["r1", "r2", "r3", "r4"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["r1", "r2", "r3", "r4"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s0")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- #
- # Define connections
- #
- switch = tgen.add_switch("s0")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
-
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py b/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py
index f0473257c..a616335d7 100644
--- a/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py
+++ b/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py
@@ -83,50 +83,46 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.isisd, pytest.mark.snmp]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["ce1"])
+ switch.add_link(tgen.gears["r1"])
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["ce1"])
- switch.add_link(tgen.gears["r1"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["ce2"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["ce2"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["ce3"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["ce3"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py b/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py
index 3c26bd5ba..37275ed9e 100644
--- a/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py
+++ b/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py
@@ -83,50 +83,46 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.isisd, pytest.mark.ldpd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["ce1"])
+ switch.add_link(tgen.gears["r1"])
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["ce1"])
- switch.add_link(tgen.gears["r1"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["ce2"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["ce2"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["ce3"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["ce3"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py b/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py
index c5bd97edf..5412fa600 100644
--- a/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py
+++ b/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py
@@ -82,50 +82,46 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["ce1"])
+ switch.add_link(tgen.gears["r1"])
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["ce1"])
- switch.add_link(tgen.gears["r1"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["ce2"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["ce2"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["ce3"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["ce3"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ldp_topo1/test_ldp_topo1.py b/tests/topotests/ldp_topo1/test_ldp_topo1.py
index 62b763ce7..f6d28b66a 100644
--- a/tests/topotests/ldp_topo1/test_ldp_topo1.py
+++ b/tests/topotests/ldp_topo1/test_ldp_topo1.py
@@ -68,7 +68,7 @@ from time import sleep
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest
from lib.micronet_compat import Topo
-from lib.micronet_compat import Mininet
+from lib.topogen import Topogen, get_topogen
fatal_error = ""
@@ -81,73 +81,25 @@ pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
#####################################################
-class NetworkTopo(Topo):
- "LDP Test Topology 1"
+def build_topo(tgen):
- def build(self, **_opts):
-
- # Setup Routers
- router = {}
- for i in range(1, 5):
- router[i] = topotest.addRouter(self, "r%s" % i)
-
- # Setup Switches, add Interfaces and Connections
- switch = {}
- # First switch
- switch[0] = self.addSwitch("sw0")
- self.addLink(
- switch[0],
- router[1],
- intfName2="r1-eth0",
- addr1="80:AA:00:00:00:00",
- addr2="00:11:00:01:00:00",
- )
- self.addLink(
- switch[0],
- router[2],
- intfName2="r2-eth0",
- addr1="80:AA:00:00:00:01",
- addr2="00:11:00:02:00:00",
- )
- # Second switch
- switch[1] = self.addSwitch("sw1")
- self.addLink(
- switch[1],
- router[2],
- intfName2="r2-eth1",
- addr1="80:AA:00:01:00:00",
- addr2="00:11:00:02:00:01",
- )
- self.addLink(
- switch[1],
- router[3],
- intfName2="r3-eth0",
- addr1="80:AA:00:01:00:01",
- addr2="00:11:00:03:00:00",
- )
- self.addLink(
- switch[1],
- router[4],
- intfName2="r4-eth0",
- addr1="80:AA:00:01:00:02",
- addr2="00:11:00:04:00:00",
- )
- # Third switch
- switch[2] = self.addSwitch("sw2")
- self.addLink(
- switch[2],
- router[2],
- intfName2="r2-eth2",
- addr1="80:AA:00:02:00:00",
- addr2="00:11:00:02:00:02",
- )
- self.addLink(
- switch[2],
- router[3],
- intfName2="r3-eth1",
- addr1="80:AA:00:02:00:01",
- addr2="00:11:00:03:00:01",
- )
+ # Setup Routers
+ for i in range(1, 5):
+ tgen.add_router("r%s" % i)
+
+ # First switch
+ switch = tgen.add_switch("sw0")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ # Second switch
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
+ # Third switch
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
#####################################################
@@ -158,48 +110,36 @@ class NetworkTopo(Topo):
def setup_module(module):
- global topo, net
- global fatal_error
-
print("\n\n** %s: Setup Topology" % module.__name__)
print("******************************************\n")
- print("Cleanup old Mininet runs")
- os.system("sudo mn -c > /dev/null 2>&1")
-
thisDir = os.path.dirname(os.path.realpath(__file__))
- topo = NetworkTopo()
+ tgen = Topogen(build_topo, module.__name__)
+ tgen.start_topology()
- net = Mininet(controller=None, topo=topo)
- net.start()
+ net = tgen.net
# Starting Routers
for i in range(1, 5):
net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i))
net["r%s" % i].loadConf("ospfd", "%s/r%s/ospfd.conf" % (thisDir, i))
net["r%s" % i].loadConf("ldpd", "%s/r%s/ldpd.conf" % (thisDir, i))
- fatal_error = net["r%s" % i].startRouter()
-
- if fatal_error != "":
- break
+ tgen.gears["r%s" % i].start()
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def teardown_module(module):
- global net
-
print("\n\n** %s: Shutdown Topology" % module.__name__)
print("******************************************\n")
-
- # End - Shutdown network
- net.stop()
+ tgen = get_topogen()
+ tgen.stop_topology()
def test_router_running():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -220,7 +160,7 @@ def test_router_running():
def test_mpls_interfaces():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -286,7 +226,7 @@ def test_mpls_interfaces():
def test_mpls_ldp_neighbor_establish():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -354,7 +294,7 @@ def test_mpls_ldp_neighbor_establish():
def test_mpls_ldp_discovery():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -423,7 +363,7 @@ def test_mpls_ldp_discovery():
def test_mpls_ldp_neighbor():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -493,7 +433,7 @@ def test_mpls_ldp_neighbor():
def test_mpls_ldp_binding():
global fatal_error
- global net
+ net = get_topogen().net
# Skip this test for now until proper sorting of the output
# is implemented
@@ -585,7 +525,7 @@ def test_mpls_ldp_binding():
def test_zebra_ipv4_routingTable():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -662,7 +602,7 @@ def test_zebra_ipv4_routingTable():
def test_mpls_table():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -741,7 +681,7 @@ def test_mpls_table():
def test_linux_mpls_routes():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -825,7 +765,7 @@ def test_linux_mpls_routes():
def test_shutdown_check_stderr():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -857,7 +797,7 @@ def test_shutdown_check_stderr():
def test_shutdown_check_memleak():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
diff --git a/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py b/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py
index 8dc8039c9..c77c96b17 100644
--- a/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py
+++ b/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py
@@ -83,50 +83,46 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["ce1", "ce2", "ce3", "r1", "r2", "r3"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["ce1"])
+ switch.add_link(tgen.gears["r1"])
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["ce1"])
- switch.add_link(tgen.gears["r1"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["ce2"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["ce2"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["ce3"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["ce3"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/lib/ltemplate.py b/tests/topotests/lib/ltemplate.py
index 1ea033a12..ef2eb8cab 100644
--- a/tests/topotests/lib/ltemplate.py
+++ b/tests/topotests/lib/ltemplate.py
@@ -72,7 +72,7 @@ class LTemplate:
def setup_module(self, mod):
"Sets up the pytest environment"
# This function initiates the topology build with Topogen...
- tgen = Topogen(customize.ThisTestTopo, mod.__name__)
+ tgen = Topogen(customize.build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions.
tgen.start_topology()
diff --git a/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py b/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py
index a10477d28..121f4a7fd 100644
--- a/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py
+++ b/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py
@@ -113,40 +113,36 @@ def close_applications():
p.wait()
-class MSDPMeshTopo1(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 3 routers
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- # Create 3 routers
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ # Create stub networks for multicast traffic.
+ tgen.add_host("h1", "192.168.10.2/24", "via 192.168.10.1")
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["h1"])
- # Create stub networks for multicast traffic.
- tgen.add_host("h1", "192.168.10.2/24", "via 192.168.10.1")
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["h1"])
-
- tgen.add_host("h2", "192.168.30.2/24", "via 192.168.30.1")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["h2"])
+ tgen.add_host("h2", "192.168.30.2/24", "via 192.168.30.1")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["h2"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(MSDPMeshTopo1, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/msdp_topo1/test_msdp_topo1.py b/tests/topotests/msdp_topo1/test_msdp_topo1.py
index 796706a2e..8fad62db7 100755
--- a/tests/topotests/msdp_topo1/test_msdp_topo1.py
+++ b/tests/topotests/msdp_topo1/test_msdp_topo1.py
@@ -113,50 +113,46 @@ def close_applications():
app_clients[host]["fd"].close()
-class MSDPTopo1(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s4")
+ # switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
- switch = tgen.add_switch("s4")
- #switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r4"])
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r4"])
+ # Create a host connected and direct at r4:
+ tgen.add_host("h1", "192.168.4.100/24", "via 192.168.4.1")
+ switch.add_link(tgen.gears["h1"])
- # Create a host connected and direct at r4:
- tgen.add_host("h1", "192.168.4.100/24", "via 192.168.4.1")
- switch.add_link(tgen.gears["h1"])
-
- # Create a host connected and direct at r1:
- switch = tgen.add_switch("s6")
- tgen.add_host("h2", "192.168.10.100/24", "via 192.168.10.1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["h2"])
+ # Create a host connected and direct at r1:
+ switch = tgen.add_switch("s6")
+ tgen.add_host("h2", "192.168.10.100/24", "via 192.168.10.1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["h2"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(MSDPTopo1, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py
index 5cd5cd155..df1cce654 100644
--- a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py
+++ b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py
@@ -113,16 +113,8 @@ from lib.pim import (
from lib.topolog import logger
from lib.topojson import build_topo_from_json, build_config_from_json
-pytestmark = [pytest.mark.pimd, pytest.mark.staticd]
-
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/mcast_pim_bsmp_01.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+pytestmark = [pytest.mark.pimd, pytest.mark.staticd]
TOPOLOGY = """
@@ -151,21 +143,6 @@ BSR1_ADDR = "1.1.2.7/32"
BSR2_ADDR = "10.2.1.1/32"
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -186,7 +163,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 = "{}/mcast_pim_bsmp_01.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.
diff --git a/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py b/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py
index 115d0bff0..64c284f7f 100644
--- a/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py
+++ b/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py
@@ -107,13 +107,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.pimd, pytest.mark.staticd]
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/mcast_pim_bsmp_02.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
TOPOLOGY = """
@@ -142,21 +135,6 @@ BSR1_ADDR = "1.1.2.7/32"
BSR2_ADDR = "10.2.1.1/32"
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -177,7 +155,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 = "{}/mcast_pim_bsmp_02.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.
diff --git a/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py b/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py
index d808a60c0..9eb3d8cc5 100755
--- a/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py
+++ b/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py
@@ -108,16 +108,8 @@ from lib.pim import (
from lib.topolog import logger
from lib.topojson import build_topo_from_json, build_config_from_json
-pytestmark = [pytest.mark.pimd]
-
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/multicast_pim_sm_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+pytestmark = [pytest.mark.pimd]
TOPOLOGY = """
@@ -170,21 +162,6 @@ GROUP_RANGE_3 = [
IGMP_JOIN_RANGE_3 = ["227.1.1.1", "227.1.1.2", "227.1.1.3", "227.1.1.4", "227.1.1.5"]
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -204,11 +181,15 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
- tgen = Topogen(CreateTopo, mod.__name__)
+ testdir = os.path.dirname(os.path.realpath(__file__))
+ json_file = "{}/multicast_pim_sm_topo1.json".format(testdir)
+ 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.
- daemons = topo_daemons(tgen, topo)
+ daemons = topo_daemons(tgen, tgen.json_topo)
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
diff --git a/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py b/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py
index 0b6894220..96886b0d9 100755
--- a/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py
+++ b/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py
@@ -102,16 +102,8 @@ from lib.pim import (
from lib.topolog import logger
from lib.topojson import build_topo_from_json, build_config_from_json
-pytestmark = [pytest.mark.pimd]
-
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/multicast_pim_sm_topo2.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+pytestmark = [pytest.mark.pimd]
TOPOLOGY = """
@@ -164,21 +156,6 @@ GROUP_RANGE_3 = [
IGMP_JOIN_RANGE_3 = ["227.1.1.1", "227.1.1.2", "227.1.1.3", "227.1.1.4", "227.1.1.5"]
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -198,7 +175,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
- tgen = Topogen(CreateTopo, mod.__name__)
+ json_file = "{}/multicast_pim_sm_topo2.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.
diff --git a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py
index f3688e2f5..7c04dba06 100755
--- a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py
+++ b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py
@@ -88,7 +88,6 @@ from lib.common_config import (
add_interfaces_to_vlan,
tcpdump_capture_start,
tcpdump_capture_stop,
- LOGDIR,
check_router_status,
required_linux_kernel_version,
topo_daemons,
@@ -114,13 +113,8 @@ from lib.pim import (
from lib.topolog import logger
from lib.topojson import build_topo_from_json, build_config_from_json
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/multicast_pim_sm_topo3.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+CWD = os.path.dirname(os.path.realpath(__file__))
+pytestmark = pytest.mark.pimd
TOPOLOGY = """
@@ -179,21 +173,6 @@ SAME_VLAN_IP_3 = {"ip": "10.1.1.3", "subnet": "255.255.255.0", "cidr": "24"}
SAME_VLAN_IP_4 = {"ip": "10.1.1.4", "subnet": "255.255.255.0", "cidr": "24"}
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -213,7 +192,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
- tgen = Topogen(CreateTopo, mod.__name__)
+ json_file = "{}/multicast_pim_sm_topo3.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.
diff --git a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py
index d2bddc43b..445dab837 100755
--- a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py
+++ b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py
@@ -101,14 +101,6 @@ from lib.pim import (
from lib.topolog import logger
from lib.topojson import build_topo_from_json, build_config_from_json
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/multicast_pim_sm_topo4.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
TOPOLOGY = """
@@ -149,21 +141,6 @@ NEW_ADDRESS_1_SUBNET = "192.168.20.1/24"
NEW_ADDRESS_2_SUBNET = "192.168.20.2/24"
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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
@@ -183,7 +160,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
- tgen = Topogen(CreateTopo, mod.__name__)
+ json_file = "{}/multicast_pim_sm_topo4.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.
diff --git a/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py b/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py
index b57c5b16d..b1ffd3786 100755
--- a/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py
+++ b/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py
@@ -187,23 +187,11 @@ SOURCE_ADDRESS = "10.0.6.2"
SOURCE = "Static"
-class CreateTopo(Topo):
- """
- Test BasicTopo - topology 1
-
- * `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 build_topo(tgen):
+ """Build function"""
- def dumdum(self):
- """ Dummy """
- print("%s", self.name)
+ # Building topology from json file
+ build_topo_from_json(tgen, TOPO)
def setup_module(mod):
diff --git a/tests/topotests/nhrp_topo/test_nhrp_topo.py b/tests/topotests/nhrp_topo/test_nhrp_topo.py
index 6d3cc3a55..19be9a8ff 100644
--- a/tests/topotests/nhrp_topo/test_nhrp_topo.py
+++ b/tests/topotests/nhrp_topo/test_nhrp_topo.py
@@ -48,26 +48,23 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.nhrpd]
-class NHRPTopo(Topo):
- "Test topology builder"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- # Create 3 routers.
- for routern in range(1, 4):
- tgen.add_router('r{}'.format(routern))
-
- switch = tgen.add_switch('s1')
- switch.add_link(tgen.gears['r1'])
- switch.add_link(tgen.gears['r3'])
- switch = tgen.add_switch('s2')
- switch.add_link(tgen.gears['r2'])
- switch.add_link(tgen.gears['r3'])
- switch = tgen.add_switch('s3')
- switch.add_link(tgen.gears['r2'])
- switch = tgen.add_switch('s4')
- switch.add_link(tgen.gears['r1'])
+def build_topo(tgen):
+ "Build function"
+
+ # Create 3 routers.
+ for routern in range(1, 4):
+ tgen.add_router('r{}'.format(routern))
+
+ switch = tgen.add_switch('s1')
+ switch.add_link(tgen.gears['r1'])
+ switch.add_link(tgen.gears['r3'])
+ switch = tgen.add_switch('s2')
+ switch.add_link(tgen.gears['r2'])
+ switch.add_link(tgen.gears['r3'])
+ switch = tgen.add_switch('s3')
+ switch.add_link(tgen.gears['r2'])
+ switch = tgen.add_switch('s4')
+ switch.add_link(tgen.gears['r1'])
def _populate_iface():
@@ -99,7 +96,7 @@ def _populate_iface():
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(NHRPTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospf6_topo1/test_ospf6_topo1.py b/tests/topotests/ospf6_topo1/test_ospf6_topo1.py
index 4a4ae3d5b..1bc994aaa 100644
--- a/tests/topotests/ospf6_topo1/test_ospf6_topo1.py
+++ b/tests/topotests/ospf6_topo1/test_ospf6_topo1.py
@@ -91,59 +91,46 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
import platform
-pytestmark = [pytest.mark.ospfd]
-
-
-#####################################################
-##
-## Network Topology Definition
-##
-#####################################################
-
-class NetworkTopo(Topo):
- "OSPFv3 (IPv6) Test Topology 1"
-
- def build(self, **_opts):
- "Build function"
+pytestmark = [pytest.mark.ospfd]
- tgen = get_topogen(self)
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+def build_topo(tgen):
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- #
- # Wire up the switches and routers
- # Note that we specify the link names so we match the config files
- #
+ #
+ # Wire up the switches and routers
+ # Note that we specify the link names so we match the config files
+ #
- # Create a empty network for router 1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"], nodeif="r1-stubnet")
+ # Create a empty network for router 1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"], nodeif="r1-stubnet")
- # Create a empty network for router 2
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"], nodeif="r2-stubnet")
+ # Create a empty network for router 2
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"], nodeif="r2-stubnet")
- # Create a empty network for router 3
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r3"], nodeif="r3-stubnet")
+ # Create a empty network for router 3
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-stubnet")
- # Create a empty network for router 4
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet")
+ # Create a empty network for router 4
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet")
- # Interconnect routers 1, 2, and 3
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"], nodeif="r1-sw5")
- switch.add_link(tgen.gears["r2"], nodeif="r2-sw5")
- switch.add_link(tgen.gears["r3"], nodeif="r3-sw5")
+ # Interconnect routers 1, 2, and 3
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"], nodeif="r1-sw5")
+ switch.add_link(tgen.gears["r2"], nodeif="r2-sw5")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-sw5")
- # Interconnect routers 3 and 4
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r3"], nodeif="r3-sw6")
- switch.add_link(tgen.gears["r4"], nodeif="r4-sw6")
+ # Interconnect routers 3 and 4
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-sw6")
+ switch.add_link(tgen.gears["r4"], nodeif="r4-sw6")
#####################################################
@@ -156,7 +143,7 @@ class NetworkTopo(Topo):
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(NetworkTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
logger.info("** %s: Setup Topology" % mod.__name__)
diff --git a/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py b/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py
index 28e89dfa5..174cecfef 100755
--- a/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py
+++ b/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py
@@ -94,59 +94,49 @@ from lib.topolog import logger
from lib.topotest import iproute2_is_vrf_capable
from lib.common_config import required_linux_kernel_version
-pytestmark = [pytest.mark.ospfd]
-
-
-#####################################################
-##
-## Network Topology Definition
-##
-#####################################################
+pytestmark = [pytest.mark.ospfd]
-class NetworkTopo(Topo):
- "OSPFv3 (IPv6) Test Topology 1"
- def build(self, **_opts):
- "Build function"
+def build_topo(tgen):
+ "Build function"
- tgen = get_topogen(self)
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- #
- # Wire up the switches and routers
- # Note that we specify the link names so we match the config files
- #
+ #
+ # Wire up the switches and routers
+ # Note that we specify the link names so we match the config files
+ #
- # Create a empty network for router 1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"], nodeif="r1-stubnet")
+ # Create a empty network for router 1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"], nodeif="r1-stubnet")
- # Create a empty network for router 2
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"], nodeif="r2-stubnet")
+ # Create a empty network for router 2
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"], nodeif="r2-stubnet")
- # Create a empty network for router 3
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r3"], nodeif="r3-stubnet")
+ # Create a empty network for router 3
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-stubnet")
- # Create a empty network for router 4
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet")
+ # Create a empty network for router 4
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet")
- # Interconnect routers 1, 2, and 3
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"], nodeif="r1-sw5")
- switch.add_link(tgen.gears["r2"], nodeif="r2-sw5")
- switch.add_link(tgen.gears["r3"], nodeif="r3-sw5")
+ # Interconnect routers 1, 2, and 3
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"], nodeif="r1-sw5")
+ switch.add_link(tgen.gears["r2"], nodeif="r2-sw5")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-sw5")
- # Interconnect routers 3 and 4
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r3"], nodeif="r3-sw6")
- switch.add_link(tgen.gears["r4"], nodeif="r4-sw6")
+ # Interconnect routers 3 and 4
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-sw6")
+ switch.add_link(tgen.gears["r4"], nodeif="r4-sw6")
#####################################################
@@ -164,7 +154,7 @@ def setup_module(mod):
if result is not True:
pytest.skip("Kernel requirements are not met")
- tgen = Topogen(NetworkTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
logger.info("** %s: Setup Topology" % mod.__name__)
diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py
index e64000b07..c1ff243fd 100644
--- a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py
+++ b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py
@@ -95,33 +95,29 @@ def expect_ospfv3_routes(router, routes, wait=5, detail=False):
assert result is None, assertmsg
-class OSPFv3Topo2(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(OSPFv3Topo2, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py
index 392cca3a1..dfcbf7bcb 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py
@@ -75,13 +75,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_asbr_summary_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
NETWORK = {
"ipv4": [
@@ -132,28 +125,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)
@@ -161,7 +138,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_asbr_summary_topo1.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py
index 3bd4f8b59..a4a946f2e 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py
@@ -75,13 +75,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_asbr_summary_type7_lsa.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
NETWORK = {
"ipv4": [
@@ -135,28 +128,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)
@@ -164,7 +141,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_asbr_summary_type7_lsa.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py b/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py
index 6d1b8d9e9..0ddd7d517 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py
@@ -61,13 +61,6 @@ pytestmark = [pytest.mark.ospfd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_authentication.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 =
Please view in a fixed-width font such as Courier.
@@ -92,28 +85,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)
@@ -121,7 +98,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_authentication.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py b/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py
index d946cca89..eade677ca 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py
@@ -98,29 +98,6 @@ TESTCASES =
3. Verify ospf functionality when staticd is restarted.
"""
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_chaos.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
-
-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):
"""
@@ -128,7 +105,6 @@ def setup_module(mod):
* `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)
@@ -136,7 +112,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_chaos.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py
index 4c5510ca6..6c8571fa9 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py
@@ -73,14 +73,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_ecmp.json".format(CWD)
-
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK = {
@@ -114,28 +106,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)
@@ -143,7 +119,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_ecmp.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py
index eb1c3a914..9ca46082d 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py
@@ -76,14 +76,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
# Reading the data from JSON File for topology creation
-
-jsonFile = "{}/ospf_ecmp_lan.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
NETWORK = {
"ipv4": [
"11.0.20.1/32",
@@ -119,28 +111,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)
@@ -148,7 +124,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_ecmp_lan.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py
index e7a002fb8..d85267a36 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py
@@ -76,13 +76,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_lan.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
NETWORK = {
"ipv4": [
@@ -114,28 +107,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)
@@ -143,7 +120,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_lan.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py b/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py
index 5cb4bd33d..1c2b9a9dd 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py
@@ -68,13 +68,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_nssa.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
NETWORK = {
"ipv4": [
"11.0.20.1/32",
@@ -111,28 +104,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)
@@ -140,7 +117,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_nssa.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py
index 0c2619d2f..43e93e98c 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py
@@ -69,19 +69,12 @@ from lib.ospf import (
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 =
@@ -104,28 +97,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)
@@ -133,7 +110,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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py b/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py
index 34abd0dc4..5620ce60a 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py
@@ -71,13 +71,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_routemaps.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
NETWORK = {
"ipv4": [
@@ -124,28 +117,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)
@@ -153,7 +130,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_routemaps.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py
index 9f05f396a..d89864ac4 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py
@@ -75,14 +75,6 @@ topo = None
# number of retries.
nretry = 5
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_rte_calc.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
NETWORK = {
"ipv4": [
"11.0.20.1/32",
@@ -115,28 +107,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)
@@ -144,7 +120,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_rte_calc.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.
diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py b/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py
index 2773c01ff..4bbc9099d 100644
--- a/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py
+++ b/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py
@@ -73,13 +73,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_single_area.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 =
@@ -106,28 +99,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)
@@ -135,7 +112,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_single_area.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.
diff --git a/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py b/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py
index f4d98fddb..fda9892f2 100644
--- a/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py
+++ b/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py
@@ -48,29 +48,10 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/test_ospf_dual_stack.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
-
-class CreateTopo(Topo):
- """Test topology builder."""
-
- 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."""
- global topo
testsuite_run_time = time.asctime(time.localtime(time.time()))
logger.info("Testsuite start time: {}".format(testsuite_run_time))
logger.info("=" * 40)
@@ -78,7 +59,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 = "{}/test_ospf_dual_stack.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.
diff --git a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper.py b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper.py
index 536382213..6e3147bd0 100644
--- a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper.py
+++ b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper.py
@@ -37,7 +37,6 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
-from mininet.topo import Topo
from lib.topogen import Topogen, get_topogen
# Import topoJson from lib, to create topology and initial configuration
@@ -76,14 +75,6 @@ intf = None
intf1 = None
pkt = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospf_gr_helper.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
"""
Topology:
@@ -118,21 +109,6 @@ TC8. Verify helper functionality when dut is helping RR and new grace lsa
"""
-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
@@ -147,7 +123,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_gr_helper.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.
@@ -169,7 +148,7 @@ def setup_module(mod):
ospf_covergence
)
- sw_name = topo["switches"].keys()[0]
+ sw_name = "s1"
intf = topo["routers"]["r0"]["links"][sw_name]["interface"]
intf1 = topo["routers"]["r1"]["links"][sw_name]["interface"]
pkt = topo["routers"]["r1"]["opq_lsa_hex"]
diff --git a/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py b/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py
index 3520cdf24..0a6e1ea2f 100755
--- a/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py
+++ b/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py
@@ -100,56 +100,50 @@ pytestmark = [pytest.mark.ospfd]
outputs = {}
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ #
+ # Define FRR Routers
+ #
+ for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7"]:
+ tgen.add_router(router)
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1")
- #
- # Define FRR Routers
- #
- for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7"]:
- tgen.add_router(router)
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["rt1"], nodeif="stub1")
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1")
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt3")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt2")
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["rt1"], nodeif="stub1")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt4")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt3")
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt3")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt2")
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt3")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt4")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt3")
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt3")
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt7")
+ switch.add_link(tgen.gears["rt7"], nodeif="eth-rt6")
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
-
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt7")
- switch.add_link(tgen.gears["rt7"], nodeif="eth-rt6")
-
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["rt7"], nodeif="stub1")
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["rt7"], nodeif="stub1")
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py b/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py
index 6146178d8..cf8914111 100755
--- a/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py
+++ b/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py
@@ -98,64 +98,60 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd, pytest.mark.pathd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "dst"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "dst"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
+ #switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
- #switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
+ #switch = tgen.add_switch("s3")
+ #switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
+ #switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
- #switch = tgen.add_switch("s3")
- #switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
- #switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
- 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):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
frrdir = tgen.config.get(tgen.CONFIG_SECTION, "frrdir")
if not os.path.isfile(os.path.join(frrdir, "pathd")):
diff --git a/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py b/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py
index 3f448d4bf..60c87cbb5 100644
--- a/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py
+++ b/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py
@@ -87,59 +87,55 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ospfd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1")
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1")
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1")
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2")
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s7")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
- switch = tgen.add_switch("s7")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4")
-
- switch = tgen.add_switch("s8")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
- switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
+ switch = tgen.add_switch("s8")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6")
+ switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5")
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py b/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py
index 2975e5864..2dcdcba58 100644
--- a/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py
+++ b/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py
@@ -53,33 +53,29 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ospfd]
-class NetworkTopo(Topo):
- "OSPF topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create routers
+ for router in range(1, 4):
+ tgen.add_router("r{}".format(router))
- # Create routers
- for router in range(1, 4):
- tgen.add_router("r{}".format(router))
+ # R1-R2 backbone area
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- # R1-R2 backbone area
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
-
- # R2-R3 NSSA area
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ # R2-R3 NSSA area
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(NetworkTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
# This is a sample of configuration loading.
diff --git a/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py b/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py
index 1678287bb..a8bb2f699 100644
--- a/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py
+++ b/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py
@@ -80,38 +80,34 @@ import pytest
pytestmark = [pytest.mark.ospfd]
-class OspfTeTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *args, **kwargs):
- "Build function"
- tgen = get_topogen(self)
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ # Interconect router 1 and 2 with 2 links
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- # Interconect router 1 and 2 with 2 links
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ # Interconect router 3 and 2
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r2"])
- # Interconect router 3 and 2
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r2"])
+ # Interconect router 4 and 2
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r4"])
+ switch.add_link(tgen.gears["r2"])
- # Interconect router 4 and 2
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r4"])
- switch.add_link(tgen.gears["r2"])
-
- # Interconnect router 3 with next AS
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r3"])
+ # Interconnect router 3 with next AS
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
@@ -119,7 +115,7 @@ def setup_module(mod):
logger.info("\n\n---- Starting OSPF TE tests ----\n")
- tgen = Topogen(OspfTeTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py b/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py
index 956e2ab0a..97ccdbf37 100644
--- a/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py
+++ b/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py
@@ -74,46 +74,42 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ospfd]
-class TemplateTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ #
+ # Define FRR Routers
+ #
+ for router in ["rt1", "rt2", "rt3", "rt4", "rt5"]:
+ tgen.add_router(router)
- #
- # Define FRR Routers
- #
- for router in ["rt1", "rt2", "rt3", "rt4", "rt5"]:
- tgen.add_router(router)
+ #
+ # Define connections
+ #
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1")
- #
- # Define connections
- #
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1")
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1")
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1")
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2")
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2")
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3")
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3")
-
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
- switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
+ switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(TemplateTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospf_topo1/test_ospf_topo1.py b/tests/topotests/ospf_topo1/test_ospf_topo1.py
index 50992503e..175b75f90 100644
--- a/tests/topotests/ospf_topo1/test_ospf_topo1.py
+++ b/tests/topotests/ospf_topo1/test_ospf_topo1.py
@@ -48,48 +48,44 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ospfd]
-class OSPFTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ # Create a empty network for router 1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
- # Create a empty network for router 1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
+ # Create a empty network for router 2
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
- # Create a empty network for router 2
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
+ # Interconect router 1, 2 and 3
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- # Interconect router 1, 2 and 3
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
+ # Create empty netowrk for router3
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r3"])
- # Create empty netowrk for router3
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r3"])
+ # Interconect router 3 and 4
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
- # Interconect router 3 and 4
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r3"])
- switch.add_link(tgen.gears["r4"])
-
- # Create a empty network for router 4
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r4"])
+ # Create a empty network for router 4
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(OSPFTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
ospf6_config = "ospf6d.conf"
diff --git a/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py b/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py
index 711f76c5c..c83c91668 100644
--- a/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py
+++ b/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py
@@ -48,39 +48,35 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ospfd]
-class OSPFTopo(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 3 routers
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
- # Create 3 routers
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
+ # Create a empty network for router 1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
- # Create a empty network for router 1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
+ # Create a empty network for router 2
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
- # Create a empty network for router 2
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
+ # Interconect router 1, 2 and 3
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- # Interconect router 1, 2 and 3
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
-
- # Create empty netowrk for router3
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r3"])
+ # Create empty netowrk for router3
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(OSPFTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospf_topo2/test_ospf_topo2.py b/tests/topotests/ospf_topo2/test_ospf_topo2.py
index 38d424c90..696396d68 100644
--- a/tests/topotests/ospf_topo2/test_ospf_topo2.py
+++ b/tests/topotests/ospf_topo2/test_ospf_topo2.py
@@ -49,34 +49,32 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.ospfd]
-class OSPFTopo(Topo):
- "Test topology builder"
+CWD = os.path.dirname(os.path.realpath(__file__))
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- # Create 4 routers
- for routern in range(1, 3):
- tgen.add_router("r{}".format(routern))
+ # Create 4 routers
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
- # Create a empty network for router 1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
+ # Create a empty network for router 1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
- # Create a empty network for router 2
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
+ # Create a empty network for router 2
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
- # Interconect router 1, 2
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ # Interconect router 1, 2
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(OSPFTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py
index c76da39ca..f2158c36e 100644
--- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py
+++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py
@@ -75,13 +75,6 @@ from lib.ospf import (
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospfv3_asbr_summary_topo1.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
NETWORK = {
"ipv4": [
@@ -149,28 +142,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)
@@ -178,7 +155,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 = "{}/ospfv3_asbr_summary_topo1.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.
diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py
index 6bfe4f199..50f05a2ec 100644
--- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py
+++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py
@@ -78,14 +78,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospfv3_ecmp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
NETWORK = {
"ipv4": [
"11.0.20.1/32",
@@ -118,28 +110,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)
@@ -147,7 +123,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 = "{}/ospfv3_ecmp.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.
diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py
index af1017c6b..9d944f4d9 100644
--- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py
+++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py
@@ -78,13 +78,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospfv3_routemaps.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
NETWORK = {
"ipv4": [
@@ -131,28 +124,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)
@@ -160,7 +137,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 = "{}/ospfv3_routemaps.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.
diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py
index d16cbb76f..f4dc8dc09 100644
--- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py
+++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py
@@ -80,14 +80,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospfv3_rte_calc.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
NETWORK = {
"ipv6": [
"11.0.20.1/32",
@@ -119,28 +111,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)
@@ -148,7 +124,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 = "{}/ospfv3_rte_calc.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.
diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py
index 22593baba..969e9c45b 100644
--- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py
+++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py
@@ -78,14 +78,6 @@ pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
# Global variables
topo = None
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/ospfv3_single_area.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 =
Please view in a fixed-width font such as Courier.
@@ -111,28 +103,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)
@@ -140,7 +116,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 = "{}/ospfv3_single_area.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.
diff --git a/tests/topotests/pbr_topo1/test_pbr_topo1.py b/tests/topotests/pbr_topo1/test_pbr_topo1.py
index 494e27a2a..304a2dd0c 100644
--- a/tests/topotests/pbr_topo1/test_pbr_topo1.py
+++ b/tests/topotests/pbr_topo1/test_pbr_topo1.py
@@ -58,22 +58,18 @@ pytestmark = [pytest.mark.pbrd]
#####################################################
-class NetworkTopo(Topo):
- "PBR Topology 1"
+def build_topo(tgen):
+ "Build function"
- def build(self, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Populate routers
+ for routern in range(1, 2):
+ tgen.add_router("r{}".format(routern))
- # Populate routers
- for routern in range(1, 2):
- tgen.add_router("r{}".format(routern))
-
- # Populate switches
- for switchn in range(1, 6):
- switch = tgen.add_switch("sw{}".format(switchn))
- switch.add_link(tgen.gears["r1"])
+ # Populate switches
+ for switchn in range(1, 6):
+ switch = tgen.add_switch("sw{}".format(switchn))
+ switch.add_link(tgen.gears["r1"])
#####################################################
@@ -85,7 +81,7 @@ class NetworkTopo(Topo):
def setup_module(module):
"Setup topology"
- tgen = Topogen(NetworkTopo, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
krel = platform.release()
diff --git a/tests/topotests/pim_basic/test_pim.py b/tests/topotests/pim_basic/test_pim.py
index e921b37b6..c346a77c0 100644
--- a/tests/topotests/pim_basic/test_pim.py
+++ b/tests/topotests/pim_basic/test_pim.py
@@ -46,48 +46,46 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.pimd]
-class PIMTopo(Topo):
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
-
- for routern in range(1, 4):
- tgen.add_router("r{}".format(routern))
-
- tgen.add_router("rp")
-
- # rp ------ r1 -------- r2
- # \
- # --------- r3
- # r1 -> .1
- # r2 -> .2
- # rp -> .3
- # r3 -> .4
- # loopback network is 10.254.0.X/32
- #
- # r1 <- sw1 -> r2
- # r1-eth0 <-> r2-eth0
- # 10.0.20.0/24
- sw = tgen.add_switch("sw1")
- sw.add_link(tgen.gears["r1"])
- sw.add_link(tgen.gears["r2"])
-
- # r1 <- sw2 -> rp
- # r1-eth1 <-> rp-eth0
- # 10.0.30.0/24
- sw = tgen.add_switch("sw2")
- sw.add_link(tgen.gears["r1"])
- sw.add_link(tgen.gears["rp"])
-
- # 10.0.40.0/24
- sw = tgen.add_switch("sw3")
- sw.add_link(tgen.gears["r1"])
- sw.add_link(tgen.gears["r3"])
+def build_topo(tgen):
+ "Build function"
+
+ for routern in range(1, 4):
+ tgen.add_router("r{}".format(routern))
+
+ tgen.add_router("rp")
+
+ # rp ------ r1 -------- r2
+ # \
+ # --------- r3
+ # r1 -> .1
+ # r2 -> .2
+ # rp -> .3
+ # r3 -> .4
+ # loopback network is 10.254.0.X/32
+ #
+ # r1 <- sw1 -> r2
+ # r1-eth0 <-> r2-eth0
+ # 10.0.20.0/24
+ sw = tgen.add_switch("sw1")
+ sw.add_link(tgen.gears["r1"])
+ sw.add_link(tgen.gears["r2"])
+
+ # r1 <- sw2 -> rp
+ # r1-eth1 <-> rp-eth0
+ # 10.0.30.0/24
+ sw = tgen.add_switch("sw2")
+ sw.add_link(tgen.gears["r1"])
+ sw.add_link(tgen.gears["rp"])
+
+ # 10.0.40.0/24
+ sw = tgen.add_switch("sw3")
+ sw.add_link(tgen.gears["r1"])
+ sw.add_link(tgen.gears["r3"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(PIMTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
# For all registered routers, load the zebra configuration file
diff --git a/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py b/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py
index 2bed11c54..2352a9ab1 100644
--- a/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py
+++ b/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py
@@ -48,33 +48,29 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.pimd]
-class PimBasicTopo2(Topo):
- "Test topology builder"
+def build_topo(tgen):
+ "Build function"
- def build(self, *_args, **_opts):
- "Build function"
- tgen = get_topogen(self)
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"])
- switch.add_link(tgen.gears["r2"])
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r3"])
-
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r2"])
- switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
def setup_module(mod):
"Sets up the pytest environment"
- tgen = Topogen(PimBasicTopo2, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
diff --git a/tests/topotests/rip_topo1/test_rip_topo1.py b/tests/topotests/rip_topo1/test_rip_topo1.py
index 91b4278cd..8cf96777b 100644
--- a/tests/topotests/rip_topo1/test_rip_topo1.py
+++ b/tests/topotests/rip_topo1/test_rip_topo1.py
@@ -38,8 +38,7 @@ from functools import partial
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest
-from lib.micronet_compat import Topo
-from lib.micronet_compat import Mininet
+from lib.topogen import Topogen, get_topogen
fatal_error = ""
@@ -52,47 +51,38 @@ pytestmark = [pytest.mark.ripd]
#####################################################
-class NetworkTopo(Topo):
- "RIP Topology 1"
-
- def build(self, **_opts):
-
- # Setup Routers
- router = {}
- #
- # Setup Main Router
- router[1] = topotest.addRouter(self, "r1")
- #
- # Setup RIP Routers
- for i in range(2, 4):
- router[i] = topotest.addRouter(self, "r%s" % i)
- #
- # Setup Switches
- switch = {}
- #
- # On main router
- # First switch is for a dummy interface (for local network)
- switch[1] = self.addSwitch("sw1")
- self.addLink(switch[1], router[1], intfName2="r1-eth0")
- #
- # Switches for RIP
- # switch 2 switch is for connection to RIP router
- switch[2] = self.addSwitch("sw2")
- self.addLink(switch[2], router[1], intfName2="r1-eth1")
- self.addLink(switch[2], router[2], intfName2="r2-eth0")
- # switch 3 is between RIP routers
- switch[3] = self.addSwitch("sw3")
- self.addLink(switch[3], router[2], intfName2="r2-eth1")
- self.addLink(switch[3], router[3], intfName2="r3-eth1")
- # switch 4 is stub on remote RIP router
- switch[4] = self.addSwitch("sw4")
- self.addLink(switch[4], router[3], intfName2="r3-eth0")
-
- switch[5] = self.addSwitch("sw5")
- self.addLink(switch[5], router[1], intfName2="r1-eth2")
-
- switch[6] = self.addSwitch("sw6")
- self.addLink(switch[6], router[1], intfName2="r1-eth3")
+def build_topo(tgen):
+ # Setup RIP Routers
+ for i in range(1, 4):
+ tgen.add_router("r%s" % i)
+
+ #
+ # On main router
+ # First switch is for a dummy interface (for local network)
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["r1"])
+ #
+ # Switches for RIP
+
+ # switch 2 switch is for connection to RIP router
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+
+ # switch 3 is between RIP routers
+ switch = tgen.add_switch("sw3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"], nodeif="r3-eth1")
+
+ # switch 4 is stub on remote RIP router
+ switch = tgen.add_switch("sw4")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-eth0")
+
+ switch = tgen.add_switch("sw5")
+ switch.add_link(tgen.gears["r1"])
+
+ switch = tgen.add_switch("sw6")
+ switch.add_link(tgen.gears["r1"])
#####################################################
@@ -103,44 +93,36 @@ class NetworkTopo(Topo):
def setup_module(module):
- global topo, net
-
print("\n\n** %s: Setup Topology" % module.__name__)
print("******************************************\n")
- print("Cleanup old Mininet runs")
- os.system("sudo mn -c > /dev/null 2>&1")
-
thisDir = os.path.dirname(os.path.realpath(__file__))
- topo = NetworkTopo()
+ tgen = Topogen(build_topo, module.__name__)
+ tgen.start_topology()
- net = Mininet(controller=None, topo=topo)
- net.start()
+ net = tgen.net
# Starting Routers
#
for i in range(1, 4):
net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i))
net["r%s" % i].loadConf("ripd", "%s/r%s/ripd.conf" % (thisDir, i))
- net["r%s" % i].startRouter()
+ tgen.gears["r%s" % i].start()
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def teardown_module(module):
- global net
-
print("\n\n** %s: Shutdown Topology" % module.__name__)
print("******************************************\n")
-
- # End - Shutdown network
- net.stop()
+ tgen = get_topogen()
+ tgen.stop_topology()
def test_router_running():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -160,7 +142,7 @@ def test_router_running():
def test_converge_protocols():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -172,7 +154,7 @@ def test_converge_protocols():
print("******************************************\n")
# Not really implemented yet - just sleep 11 secs for now
- sleep(11)
+ sleep(21)
# Make sure that all daemons are still running
for i in range(1, 4):
@@ -185,7 +167,7 @@ def test_converge_protocols():
def test_rip_status():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -246,7 +228,7 @@ def test_rip_status():
def test_rip_routes():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -301,7 +283,7 @@ def test_rip_routes():
def test_zebra_ipv4_routingTable():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -367,7 +349,7 @@ def test_zebra_ipv4_routingTable():
def test_shutdown_check_stderr():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
diff --git a/tests/topotests/ripng_topo1/test_ripng_topo1.py b/tests/topotests/ripng_topo1/test_ripng_topo1.py
index 9b3f66111..e2be3abcc 100644
--- a/tests/topotests/ripng_topo1/test_ripng_topo1.py
+++ b/tests/topotests/ripng_topo1/test_ripng_topo1.py
@@ -38,8 +38,7 @@ from functools import partial
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest
-from lib.micronet_compat import Topo
-from lib.micronet_compat import Mininet
+from lib.topogen import Topogen, get_topogen
fatal_error = ""
@@ -52,46 +51,34 @@ pytestmark = [pytest.mark.ripd]
#####################################################
-class NetworkTopo(Topo):
- "RIPng Topology 1"
-
- def build(self, **_opts):
-
- # Setup Routers
- router = {}
- #
- # Setup Main Router
- router[1] = topotest.addRouter(self, "r1")
- #
- # Setup RIPng Routers
- for i in range(2, 4):
- router[i] = topotest.addRouter(self, "r%s" % i)
-
- # Setup Switches
- switch = {}
- #
- # On main router
- # First switch is for a dummy interface (for local network)
- switch[1] = self.addSwitch("sw1")
- self.addLink(switch[1], router[1], intfName2="r1-eth0")
- #
- # Switches for RIPng
- # switch 2 switch is for connection to RIP router
- switch[2] = self.addSwitch("sw2")
- self.addLink(switch[2], router[1], intfName2="r1-eth1")
- self.addLink(switch[2], router[2], intfName2="r2-eth0")
- # switch 3 is between RIP routers
- switch[3] = self.addSwitch("sw3")
- self.addLink(switch[3], router[2], intfName2="r2-eth1")
- self.addLink(switch[3], router[3], intfName2="r3-eth1")
- # switch 4 is stub on remote RIP router
- switch[4] = self.addSwitch("sw4")
- self.addLink(switch[4], router[3], intfName2="r3-eth0")
-
- switch[5] = self.addSwitch("sw5")
- self.addLink(switch[5], router[1], intfName2="r1-eth2")
- switch[6] = self.addSwitch("sw6")
- self.addLink(switch[6], router[1], intfName2="r1-eth3")
+def build_topo(tgen):
+ # Setup RIPng Routers
+ for i in range(1, 4):
+ tgen.add_router("r%s" % i)
+
+ #
+ # On main router
+ # First switch is for a dummy interface (for local network)
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["r1"])
+ #
+ # Switches for RIPng
+ # switch 2 switch is for connection to RIP router
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ # switch 3 is between RIP routers
+ switch = tgen.add_switch("sw3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"], nodeif="r3-eth1")
+ # switch 4 is stub on remote RIP router
+ switch = tgen.add_switch("sw4")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-eth0")
+
+ switch = tgen.add_switch("sw5")
+ switch.add_link(tgen.gears["r1"])
+ switch = tgen.add_switch("sw6")
+ switch.add_link(tgen.gears["r1"])
#####################################################
@@ -102,44 +89,36 @@ class NetworkTopo(Topo):
def setup_module(module):
- global topo, net
-
print("\n\n** %s: Setup Topology" % module.__name__)
print("******************************************\n")
- print("Cleanup old Mininet runs")
- os.system("sudo mn -c > /dev/null 2>&1")
-
thisDir = os.path.dirname(os.path.realpath(__file__))
- topo = NetworkTopo()
+ tgen = Topogen(build_topo, module.__name__)
+ tgen.start_topology()
- net = Mininet(controller=None, topo=topo)
- net.start()
+ net = tgen.net
# Starting Routers
#
for i in range(1, 4):
net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i))
net["r%s" % i].loadConf("ripngd", "%s/r%s/ripngd.conf" % (thisDir, i))
- net["r%s" % i].startRouter()
+ tgen.gears["r%s" % i].start()
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def teardown_module(module):
- global net
-
print("\n\n** %s: Shutdown Topology" % module.__name__)
print("******************************************\n")
-
- # End - Shutdown network
- net.stop()
+ tgen = get_topogen()
+ tgen.stop_topology()
def test_router_running():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -159,7 +138,7 @@ def test_router_running():
def test_converge_protocols():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -184,7 +163,7 @@ def test_converge_protocols():
def test_ripng_status():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -252,7 +231,7 @@ def test_ripng_status():
def test_ripng_routes():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -319,7 +298,7 @@ def test_ripng_routes():
def test_zebra_ipv6_routingTable():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -387,7 +366,7 @@ def test_zebra_ipv6_routingTable():
def test_shutdown_check_stderr():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -416,7 +395,7 @@ def test_shutdown_check_stderr():
def test_shutdown_check_memleak():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py
index 7b9b61fd9..3298be17e 100644
--- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py
+++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py
@@ -68,14 +68,6 @@ 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
-JSONFILE = "{}/static_routes_topo1_ebgp.json".format(CWD)
-try:
- with open(JSONFILE, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(JSONFILE)
-
# Global variables
ADDR_TYPES = check_address_types()
NETWORK = {"ipv4": ["11.0.20.1/32", "11.0.20.2/32"], "ipv6": ["2::1/128", "2::2/128"]}
@@ -84,25 +76,6 @@ NETWORK2 = {"ipv4": "11.0.20.1/32", "ipv6": "2::1/128"}
PREFIX1 = {"ipv4": "110.0.20.1/32", "ipv6": "20::1/128"}
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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 dumdum(self):
- """ Dummy """
- print("%s", self.name)
-
-
def setup_module(mod):
"""
Sets up the pytest environment.
@@ -117,7 +90,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 = "{}/static_routes_topo1_ebgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py
index c0edfef5d..8c98a88bd 100644
--- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py
+++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py
@@ -75,13 +75,6 @@ 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
-jsonFile = "{}/static_routes_topo2_ebgp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@@ -123,21 +116,6 @@ topo_diag = """
"""
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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):
"""
@@ -145,7 +123,6 @@ def setup_module(mod):
* `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)
@@ -153,7 +130,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 = "{}/static_routes_topo2_ebgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py
index f088fd618..703e295e5 100644
--- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py
+++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py
@@ -70,14 +70,6 @@ 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
-jsonFile = "{}/static_routes_topo3_ebgp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@@ -108,21 +100,6 @@ NETWORK2 = {"ipv4": ["11.0.20.1/32"], "ipv6": ["2::1/128"]}
NEXT_HOP_IP = []
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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):
"""
@@ -130,7 +107,6 @@ def setup_module(mod):
* `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)
@@ -138,7 +114,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 = "{}/static_routes_topo3_ebgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py
index 217f8467d..bc85a752a 100644
--- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py
+++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py
@@ -72,16 +72,8 @@ from lib.bgp import (
)
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
-jsonFile = "{}/static_routes_topo4_ebgp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
+pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Global variables
BGP_CONVERGENCE = False
@@ -92,21 +84,6 @@ NEXT_HOP_IP = {}
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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):
"""
Set up the pytest environment.
@@ -120,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 = "{}/static_routes_topo4_ebgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py
index ea888c137..b571e312d 100644
--- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py
+++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py
@@ -68,14 +68,6 @@ 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
-jsonFile = "{}/static_routes_topo1_ibgp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@@ -85,21 +77,6 @@ NETWORK2 = {"ipv4": "11.0.20.1/32", "ipv6": "2::1/128"}
PREFIX1 = {"ipv4": "110.0.20.1/32", "ipv6": "20::1/128"}
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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):
"""
@@ -107,7 +84,6 @@ def setup_module(mod):
* `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)
@@ -115,7 +91,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 = "{}/static_routes_topo1_ibgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py
index b58543cc9..20697bf19 100644
--- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py
+++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py
@@ -77,13 +77,6 @@ from lib.topotest import version_cmp
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/static_routes_topo2_ibgp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@@ -125,21 +118,6 @@ topo_diag = """
"""
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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):
"""
@@ -147,7 +125,6 @@ def setup_module(mod):
* `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)
@@ -155,7 +132,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 = "{}/static_routes_topo2_ibgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py
index 8e769ea66..ac7a80745 100644
--- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py
+++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py
@@ -71,14 +71,6 @@ 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
-jsonFile = "{}/static_routes_topo3_ibgp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
-
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@@ -109,21 +101,6 @@ NETWORK2 = {"ipv4": ["11.0.20.1/32"], "ipv6": ["2::1/128"]}
NEXT_HOP_IP = []
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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):
"""
@@ -131,7 +108,6 @@ def setup_module(mod):
* `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)
@@ -139,7 +115,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 = "{}/static_routes_topo3_ibgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py
index eb828ea03..8dcdc8093 100644
--- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py
+++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py
@@ -70,13 +70,6 @@ from lib.bgp import (
from lib.topojson import build_topo_from_json, build_config_from_json
from lib.topotest import version_cmp
-# Reading the data from JSON File for topology creation
-jsonFile = "{}/static_routes_topo4_ibgp.json".format(CWD)
-try:
- with open(jsonFile, "r") as topoJson:
- topo = json.load(topoJson)
-except IOError:
- assert False, "Could not read file {}".format(jsonFile)
# Global variables
BGP_CONVERGENCE = False
@@ -87,27 +80,11 @@ NEXT_HOP_IP = {}
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
-class CreateTopo(Topo):
- """
- Test CreateTopo - topology 1.
-
- * `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):
"""
Set 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)
@@ -115,7 +92,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 = "{}/static_routes_topo4_ibgp.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers