]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: generate support bundles in parallel, fix bugs 8939/head
authorChristian Hopps <chopps@labn.net>
Wed, 30 Jun 2021 15:45:24 +0000 (15:45 +0000)
committerChristian Hopps <chopps@labn.net>
Wed, 30 Jun 2021 15:46:10 +0000 (15:46 +0000)
Speedup (large topo): OLD: ~6 minutes NEW: ~1 second
  (when paired with generate_support_bundle.py changes)
- Collect from each node in parallel

Bug fixes:
- sub-directory test name was the same internal pytest function name
  for any test, and not the actual test name.

Signed-off-by: Christian Hopps <chopps@labn.net>
tests/topotests/lib/common_config.py

index 9e38608631597f0cec893a312a3a1e71b3951b64..d659b8d52df01ef1d1bba3abe28ae888a540d631 100644 (file)
@@ -712,20 +712,36 @@ def generate_support_bundle():
 
     tgen = get_topogen()
     router_list = tgen.routers()
-    test_name = sys._getframe(2).f_code.co_name
+    test_name = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]
+
     TMPDIR = os.path.join(LOGDIR, tgen.modname)
 
+    bundle_procs = {}
     for rname, rnode in router_list.items():
-        logger.info("Generating support bundle for {}".format(rname))
+        logger.info("Spawn collection of support bundle for %s", rname)
         rnode.run("mkdir -p /var/log/frr")
+        bundle_procs[rname] = tgen.net[rname].popen(
+            "/usr/lib/frr/generate_support_bundle.py",
+            stdin=None,
+            stdout=SUB_PIPE,
+            stderr=SUB_PIPE,
+        )
 
-        # Support only python3 going forward
-        bundle_log = rnode.run("env python3 /usr/lib/frr/generate_support_bundle.py")
-
-        logger.info(bundle_log)
-
+    for rname, rnode in router_list.items():
         dst_bundle = "{}/{}/support_bundles/{}".format(TMPDIR, rname, test_name)
         src_bundle = "/var/log/frr"
+
+        output, error = bundle_procs[rname].communicate()
+
+        logger.info("Saving support bundle for %s", rname)
+        if output:
+            logger.info(
+                "Output from collecting support bundle for %s:\n%s", rname, output
+            )
+        if error:
+            logger.warning(
+                "Error from collecting support bundle for %s:\n%s", rname, error
+            )
         rnode.run("rm -rf {}".format(dst_bundle))
         rnode.run("mkdir -p {}".format(dst_bundle))
         rnode.run("mv -f {}/* {}".format(src_bundle, dst_bundle))