]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Adding daemon check for ospfd in common_config.py
authornguggarigoud <nguggarigoud@vmware.com>
Tue, 8 Sep 2020 05:59:21 +0000 (11:29 +0530)
committernguggarigoud <nguggarigoud@vmware.com>
Fri, 18 Sep 2020 09:43:46 +0000 (15:13 +0530)
start ospfd only when ospf config is used.

Signed-off-by: nguggarigoud <nguggarigoud@vmware.com>
tests/topotests/lib/common_config.py
tests/topotests/ospf_basic_functionality/test_ospf_authentication.py
tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py
tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py
tests/topotests/ospf_basic_functionality/test_ospf_lan.py
tests/topotests/ospf_basic_functionality/test_ospf_nssa.py
tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py
tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py
tests/topotests/ospf_basic_functionality/test_ospf_single_area.py

index 09e7fa7873017f408401f2bf0e371ddbb16d0091..9a796938406c9b9317587a0f882b925a7ef319e3 100644 (file)
@@ -685,7 +685,7 @@ def generate_support_bundle():
     return True
 
 
-def start_topology(tgen):
+def start_topology(tgen, daemon=None):
     """
     Starting topology, create tmp files which are loaded to routers
     to start deamons and then start routers
@@ -737,14 +737,16 @@ def start_topology(tgen):
         router.load_config(
             TopoRouter.RD_ZEBRA, "{}/{}/zebra.conf".format(TMPDIR, rname)
         )
+
         # Loading empty bgpd.conf file to router, to start the bgp deamon
         router.load_config(TopoRouter.RD_BGP, "{}/{}/bgpd.conf".format(TMPDIR, rname))
 
-        # Loading empty ospf.conf file to router, to start the bgp deamon
-        router.load_config(
-            TopoRouter.RD_OSPF,
-            '{}/{}/ospfd.conf'.format(TMPDIR, rname)
-        )
+        if daemon and 'ospfd' in daemon:
+            # Loading empty ospf.conf file to router, to start the bgp deamon
+            router.load_config(
+                TopoRouter.RD_OSPF,
+                '{}/{}/ospfd.conf'.format(TMPDIR, rname)
+            )
         # Starting routers
     logger.info("Starting all routers once topology is created")
     tgen.start_router()
@@ -817,6 +819,24 @@ def number_to_column(routerName):
     return ord(routerName[0]) - 97
 
 
+def topo_daemons(tgen, topo):
+    """
+    Returns daemon list required for the suite based on topojson.
+    """
+    daemon_list = []
+
+    router_list = tgen.routers()
+    ROUTER_LIST = sorted(
+        router_list.keys(), key=lambda x: int(re_search("\d+", x).group(0))
+    )
+
+    for rtr in ROUTER_LIST:
+        if 'ospf' in topo['routers'][rtr] and 'ospfd' not in daemon_list:
+            daemon_list.append('ospfd')
+
+    return daemon_list
+
+
 #############################################
 # Common APIs, will be used by all protocols
 #############################################
index e6485de2509c0b203c2ee5f7e59847bb46882936..a2f9c03ab4e00dfa86e8d55751183d6e6b993ca5 100644 (file)
@@ -48,6 +48,7 @@ from lib.common_config import (
     reset_config_on_routers,
     step,
     shutdown_bringup_interface,
+    topo_daemons
 )
 from lib.topolog import logger
 from lib.topojson import build_topo_from_json, build_config_from_json
@@ -119,9 +120,12 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
 
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
index 30f50a78c4d6961cfa86e715cd149c4f2c33cd75..399fa02230f074fd69e7d27efcdbd8c8820dfb6f 100644 (file)
@@ -53,6 +53,7 @@ from lib.common_config import (
     create_route_maps,
     shutdown_bringup_interface,
     create_interfaces_cfg,
+    topo_daemons
 )
 from lib.topolog import logger
 
@@ -141,9 +142,12 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
 
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
index c31f7f2bfd6a48b5082146ee99649dafb519dba8..17a3676e2e17ceb18267be2419691d556cd0c429 100644 (file)
@@ -53,6 +53,7 @@ from lib.common_config import (
     shutdown_bringup_interface,
     stop_router,
     start_router,
+    topo_daemons
 )
 from lib.bgp import verify_bgp_convergence, create_router_bgp
 from lib.topolog import logger
@@ -146,9 +147,13 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
+
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
 
index f1c24ae50d3a22a64eecf678d75a85bc02f3ecc8..968cb608e8cdaada205b9245ce30cce171b23184 100644 (file)
@@ -55,6 +55,7 @@ from lib.common_config import (
     shutdown_bringup_interface,
     stop_router,
     start_router,
+    topo_daemons
 )
 from lib.bgp import verify_bgp_convergence, create_router_bgp
 from lib.topolog import logger
@@ -141,9 +142,12 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
 
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
index 557549db71f79e829311bec574e38d8028aeb0e0..ff4399f19ef25edb3581cf882fa9f5239d01704a 100644 (file)
@@ -44,6 +44,7 @@ from lib.common_config import (
     create_route_maps,
     shutdown_bringup_interface,
     create_interfaces_cfg,
+    topo_daemons
 )
 from ipaddress import IPv4Address
 from lib.topogen import Topogen, get_topogen
@@ -138,9 +139,13 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
+
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
 
index ee7acf535d8f9f12c31f8890a27e662f21623b62..6ebc74a01374864bb02232774b4f9eee992b9ef7 100644 (file)
@@ -52,6 +52,7 @@ from lib.common_config import (
     step,
     create_route_maps,
     verify_prefix_lists,
+    topo_daemons
 )
 from lib.topolog import logger
 from lib.topojson import build_topo_from_json, build_config_from_json
@@ -150,9 +151,12 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
 
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
index a46fa6fccee3ab006aef0e1332eb8c7139f744fd..5e0e35854ee576fa6c45e9fdd8e2f4878cce16a7 100644 (file)
@@ -50,6 +50,7 @@ from lib.common_config import (
     create_static_routes,
     step,
     shutdown_bringup_interface,
+    topo_daemons
 )
 from lib.bgp import verify_bgp_convergence, create_router_bgp
 from lib.topolog import logger
@@ -136,9 +137,12 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
 
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)
index 29f61827f9864ea19cc3bd9326bf06f62db37286..b70c25ff1eef8731583758b1dccc17d56d161ed9 100644 (file)
@@ -53,6 +53,7 @@ from lib.common_config import (
     create_route_maps,
     shutdown_bringup_interface,
     create_interfaces_cfg,
+    topo_daemons
 )
 from lib.topolog import logger
 from lib.topojson import build_topo_from_json, build_config_from_json
@@ -134,9 +135,12 @@ def setup_module(mod):
     tgen = Topogen(CreateTopo, mod.__name__)
     # ... and here it calls Mininet initialization functions.
 
+    # get list of daemons needs to be started for this suite.
+    daemons = topo_daemons(tgen, topo)
+
     # Starting topology, create tmp files which are loaded to routers
     #  to start deamons and then start routers
-    start_topology(tgen)
+    start_topology(tgen, daemons)
 
     # Creating configuration from JSON
     build_config_from_json(tgen, topo)