sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
194 stars 713 forks source link

Nice to have ptf_runner print the entire error from ptf command line instead of "Exception". #5215

Open rraghav-cisco opened 2 years ago

rraghav-cisco commented 2 years ago

Description

Current ptf_runner is raising "Exception" when the ptf command line has a problem. This doesn't give much clue on what went wrong in the ptf command.

Steps to reproduce the issue:

  1. Run any script that uses tests/ptf_runner.py.
  2. If it fails due to ptf program, we get an error with Exception.

Describe the results you received: We see the following output:

            traceback_msg = traceback.format_exc()
            logger.error("Exception caught while executing case: {}. Error message: {}"\
                .format(testname, traceback_msg))
>           raise Exception
E           Exception

cmd        = 'ptf --test-dir acstests everflow_policer_test.EverflowPolicerTest --platform-dir ptftests --qlen=15000 --platform rem...g --log-file /tmp/TestEverflowV4IngressAclIngressMirror.test_everflow_dscp_with_policer.log --socket-recv-size 1048576'
debug_level = 'debug'
device_sockets = []
host       = <tests.common.devices.ptf.PTFHost object at 0x7f91d7015290>
k          = 'acl_stage'
log_file   = '/tmp/TestEverflowV4IngressAclIngressMirror.test_everflow_dscp_with_policer.log'
module_ignore_errors = False
params     = {'acl_stage': 'ingress', 'asic_type': 'cisco-8000', 'cbs': '1024', 'check_ttl': 'True', ...}
platform   = 'remote'
platform_dir = 'ptftests'
ptf_test_params = "session_dst_ip='2.2.2.2';session_src_ip='1.1.1.1';dst_ports='0,1';session_ttl='4';check_ttl='True';cbs='1024';send_ti...ter_mac=u'64:3a:ea:c1:73:f8';cir='100';meter_type='packets';asic_type=u'cisco-8000';tolerance='10';acl_stage='ingress'"
qlen       = 15000
relax      = True
socket_recv_size = 1048576
testdir    = 'acstests'
testname   = 'everflow_policer_test.EverflowPolicerTest'
timeout    = 0
traceback_msg = 'Traceback (most recent call last):\n  File "/data/tests/ptf_runner.py", line 47, in ptf_runner\n    result = host.she...      "max_range=1126.4", \n        "check_ttl=True", \n        "#", \n        "# Run test", \n        "#"\n    ]\n}\n'
v          = 'ingress'

Describe the results you expected: Expecing the full traceback containing the error from ptf commandline.

Additional information you deem important: This is the proposed solution:

--- a/sonic-mgmt/tests/ptf_runner.py
+++ b/sonic-mgmt/tests/ptf_runner.py
@@ -52,5 +52,5 @@ def ptf_runner(host, testdir, testname, platform_dir=None, params={},
         traceback_msg = traceback.format_exc()
         logger.error("Exception caught while executing case: {}. Error message: {}"\
             .format(testname, traceback_msg))
-        raise Exception
+        raise
     return True
rraghav-cisco commented 2 years ago

@vaibhavhd , @neethajohn , @daall , @lguohan , @dawnbeauty , @stepanblyschak : Can someone take pls this up?