tests: Auto generate support bundle when a test fails

Tests can fail, let's be proactive and gather up a support
bundle when they fail.  It will help diagnose the problem
to some extent.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-12-21 10:22:22 -05:00
parent bbda45a825
commit 7477d8732f
3 changed files with 6 additions and 17 deletions

View File

@ -58,7 +58,6 @@ from lib.common_config import (
step,
write_test_header,
write_test_footer,
generate_support_bundle,
)
# Required to instantiate the topology builder class.
@ -277,8 +276,6 @@ def test_evpn_gateway_ip_basic_topo(request):
result, assertmsg = evpn_gateway_ip_show_op_check("base")
if result is not None:
generate_support_bundle()
assert result is None, assertmsg
write_test_footer(tc_name)
@ -319,8 +316,6 @@ def test_evpn_gateway_ip_flap_rt5(request):
)
result, assertmsg = evpn_gateway_ip_show_op_check("no_rt5")
if result is not None:
generate_support_bundle()
assert result is None, assertmsg
step("Advertise type-5 routes again")
@ -339,8 +334,6 @@ def test_evpn_gateway_ip_flap_rt5(request):
)
result, assertmsg = evpn_gateway_ip_show_op_check("base")
if result is not None:
generate_support_bundle()
assert result is None, assertmsg
@ -371,8 +364,6 @@ def test_evpn_gateway_ip_flap_rt2(request):
pe1.cmd_raises("ip link set dev vxlan100 down")
result, assertmsg = evpn_gateway_ip_show_op_check("no_rt2")
if result is not None:
generate_support_bundle()
assert result is None, assertmsg
step("Bring up VxLAN interface at PE1 and advertise type-2 routes again")
@ -380,8 +371,6 @@ def test_evpn_gateway_ip_flap_rt2(request):
pe1.cmd_raises("ip link set dev vxlan100 up")
result, assertmsg = evpn_gateway_ip_show_op_check("base")
if result is not None:
generate_support_bundle()
assert result is None, assertmsg
write_test_footer(tc_name)

View File

@ -51,7 +51,6 @@ 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 lib.common_config import generate_support_bundle
# Required to instantiate the topology builder class.
@ -140,10 +139,7 @@ def test_bgp_convergence():
)
_, res = topotest.run_and_expect(test_func, None, count=210, wait=1)
assertmsg = "BGP router network did not converge"
if res is not None:
generate_support_bundle()
assert res is None, assertmsg
generate_support_bundle()
assert res is None, assertmsg
def test_bgp_flowspec():

View File

@ -26,7 +26,7 @@ from munet.base import Commander, proc_error
from munet.cleanup import cleanup_current, cleanup_previous
from munet.config import ConfigOptionsProxy
from munet.testing.util import pause_test
from lib.common_config import generate_support_bundle
from lib import topolog, topotest
try:
@ -600,6 +600,10 @@ def pytest_runtest_setup(item):
os.environ["PYTEST_TOPOTEST_SCRIPTDIR"] = script_dir
def pytest_exception_interact(node, call, report):
generate_support_bundle()
def pytest_runtest_makereport(item, call):
"Log all assert messages to default logger with error level"