]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Fix logdir creation
authorAshish Pant <ashish12pant@gmail.com>
Tue, 25 Jun 2019 05:56:46 +0000 (11:26 +0530)
committerAshish Pant <ashish12pant@gmail.com>
Tue, 9 Jul 2019 04:56:53 +0000 (10:26 +0530)
Signed-off-by: Ashish Pant <ashish12pant@gmail.com>
Creates logdir everytime in start_topology, removed stop_topoloy.
Using tgen.stop_topology in test case now.

tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py
tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py
tests/topotests/example-topojson-test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py
tests/topotests/example-topojson-test/test_topo_json_single_link/test_example_topojson.py
tests/topotests/example-topojson-test/test_topo_json_single_link_loopback/test_example_topojson.py
tests/topotests/lib/common_config.py

index fd2102dd7cea97afb9fbfe4559feeaa47a282dd4..095ebe33445e72adb693ec482b0f9ee6f34bb609 100755 (executable)
@@ -59,7 +59,7 @@ from lib.topogen import Topogen, get_topogen
 from mininet.topo import Topo
 
 from lib.common_config import (
-    start_topology, stop_topology, write_test_header,
+    start_topology, write_test_header,
     write_test_footer, reset_config_on_routers, create_static_routes,
     verify_rib, verify_admin_distance_for_static_routes
 )
@@ -135,7 +135,7 @@ def teardown_module():
     tgen = get_topogen()
 
     # Stop toplogy and Remove tmp files
-    stop_topology(tgen)
+    tgen.stop_topology()
 
     logger.info("Testsuite end time: {}".
                 format(time.asctime(time.localtime(time.time()))))
index 7400d9ee54e8337c6e0567492d86bf83f144b855..abd6b396d109f55e21289de8cebd36e757928425 100755 (executable)
@@ -72,7 +72,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
 
 # Required to instantiate the topology builder class.
 from lib.common_config import (
-    start_topology, stop_topology, write_test_header,
+    start_topology, write_test_header,
     write_test_footer, reset_config_on_routers,
     verify_rib, create_static_routes,
     create_prefix_lists, verify_prefix_lists,
@@ -158,7 +158,7 @@ def teardown_module():
     tgen = get_topogen()
 
     # Stop toplogy and Remove tmp files
-    stop_topology(tgen)
+    tgen.stop_topology()
 
     logger.info("Testsuite end time: %s",
                 time.asctime(time.localtime(time.time())))
index f77fea770252f5516cc7ddc25f45bc6b1bbd7b79..25a346f20d6b22e442aebd86a2f381cffbec78dc 100755 (executable)
@@ -60,7 +60,7 @@ from lib.topogen import Topogen, get_topogen
 
 # Import topoJson from lib, to create topology and initial configuration
 from lib.common_config import (
-    start_topology, stop_topology, write_test_header,
+    start_topology, write_test_header,
     write_test_footer, reset_config_on_routers,
     verify_rib, create_static_routes,
     create_prefix_lists, verify_prefix_lists
@@ -151,7 +151,7 @@ def teardown_module(mod):
     tgen = get_topogen()
 
     # Stop toplogy and Remove tmp files
-    stop_topology(tgen)
+    tgen.stop_topology()
 
     logger.info("Testsuite end time: {}".
                 format(time.asctime(time.localtime(time.time()))))
index aff8874f980aa2d99932e5ea7d68c71f4e94363e..8e794b9946b9fa2a3969477050055717562ddc5f 100755 (executable)
@@ -44,7 +44,7 @@ from mininet.topo import Topo
 
 # Import topoJson from lib, to create topology and initial configuration
 from lib.common_config import (
-    start_topology, stop_topology, write_test_header,
+    start_topology, write_test_header,
     write_test_footer, verify_rib
 )
 from lib.topolog import logger
@@ -137,7 +137,7 @@ def teardown_module(mod):
     tgen = get_topogen()
 
     # Stop toplogy and Remove tmp files
-    stop_topology(tgen)
+    tgen.stop_topology()
 
 
 def test_bgp_convergence(request):
index 592174bae5d1313ed100f2c3a2baa2820d3a1aab..315c7b3f2d31276ad418e26116ef0a22d3bfffba 100755 (executable)
@@ -43,7 +43,7 @@ from mininet.topo import Topo
 
 # Import topoJson from lib, to create topology and initial configuration
 from lib.common_config import (
-    start_topology, stop_topology, write_test_header,
+    start_topology, write_test_header,
     write_test_footer, verify_rib
 )
 from lib.topolog import logger
@@ -134,7 +134,7 @@ def teardown_module(mod):
     tgen = get_topogen()
 
     # Stop toplogy and Remove tmp files
-    stop_topology(tgen)
+    tgen.stop_topology()
 
 
 def test_bgp_convergence(request):
index c5ff7c80ebe6b73d12558623b92bff8b8f0a8a02..b794b96a631e26b9402f8969047642148c24cdf5 100755 (executable)
@@ -45,7 +45,7 @@ from mininet.topo import Topo
 
 # Import topoJson from lib, to create topology and initial configuration
 from lib.common_config import (
-    start_topology, stop_topology, write_test_header,
+    start_topology, write_test_header,
     write_test_footer, verify_rib
 )
 from lib.topolog import logger
@@ -139,7 +139,7 @@ def teardown_module(mod):
     tgen = get_topogen()
 
     # Stop toplogy and Remove tmp files
-    stop_topology(tgen)
+    tgen.stop_topology()
 
 
 def test_bgp_convergence(request):
index df0b853dc503e72fe037535aab5cb6c6eab48382..0598a154dd351a976e5f660187f63fd1e5bbf7d9 100644 (file)
@@ -340,24 +340,25 @@ def start_topology(tgen):
     router_list = tgen.routers()
     TMPDIR = os.path.join(LOGDIR, tgen.modname)
 
-    # Deleting temporary created dir if exists
-    if os.path.exists("{}".format(TMPDIR)):
-        os.system("rm -rf {}".format(TMPDIR))
-
-    # Create testsuite named temporary dir to save
-    # tmp files
-    os.mkdir("{}".format(TMPDIR))
-
     for rname, router in router_list.iteritems():
         try:
             os.chdir(TMPDIR)
 
             # Creating rouer named dir and empty zebra.conf bgpd.conf files
             # inside the current directory
-            os.mkdir("{}".format(rname))
-            os.system("chmod -R go+rw {}".format(rname))
-            os.chdir("{}/{}".format(TMPDIR, rname))
-            os.system("touch zebra.conf bgpd.conf")
+
+            if os.path.isdir('{}'.format(rname)):
+                os.system("rm -rf {}".format(rname))
+                os.mkdir('{}'.format(rname))
+                os.system('chmod -R go+rw {}'.format(rname))
+                os.chdir('{}/{}'.format(TMPDIR, rname))
+                os.system('touch zebra.conf bgpd.conf')
+            else:
+                os.mkdir('{}'.format(rname))
+                os.system('chmod -R go+rw {}'.format(rname))
+                os.chdir('{}/{}'.format(TMPDIR, rname))
+                os.system('touch zebra.conf bgpd.conf')
+
 
         except IOError as (errno, strerror):
             logger.error("I/O error({0}): {1}".format(errno, strerror))
@@ -365,37 +366,21 @@ def start_topology(tgen):
         # Loading empty zebra.conf file to router, to start the zebra deamon
         router.load_config(
             TopoRouter.RD_ZEBRA,
-            "{}/{}/zebra.conf".format(TMPDIR, rname)
-            # os.path.join(TMPDIR, "{}/zebra.conf".format(rname))
+            '{}/{}/zebra.conf'.format(TMPDIR, rname)
+            # os.path.join(tmpdir, '{}/zebra.conf'.format(rname))
         )
         # Loading empty bgpd.conf file to router, to start the bgp deamon
         router.load_config(
             TopoRouter.RD_BGP,
-            "{}/{}/bgpd.conf".format(TMPDIR, rname)
-            # os.path.join(TMPDIR, "{}/bgpd.conf".format(rname))
+            '{}/{}/bgpd.conf'.format(TMPDIR, rname)
+            # os.path.join(tmpdir, '{}/bgpd.conf'.format(rname))
         )
 
-    # Starting routers
+        # Starting routers
     logger.info("Starting all routers once topology is created")
     tgen.start_router()
 
 
-def stop_topology(tgen):
-    """
-    It will stop topology and remove temporary dirs and files.
-    * `tgen`  : topogen object
-    """
-
-    # This function tears down the whole topology.
-    tgen.stop_topology()
-
-    # Removing tmp dirs and files, once the topology is deleted
-    try:
-        os.system("rm -rf {}".format(TMPDIR))
-    except IOError as (errno, strerror):
-        logger.error("I/O error({0}): {1}".format(errno, strerror))
-
-
 def number_to_row(routerName):
     """
     Returns the number for the router.