[LNT] r308402 - Improve submission error handling

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 18:14:23 PDT 2017


Author: matze
Date: Tue Jul 18 18:14:23 2017
New Revision: 308402

URL: http://llvm.org/viewvc/llvm-project?rev=308402&view=rev
Log:
Improve submission error handling

- Set 400 status on the submitRun response if the 'error' field is not
  empty.
- Fix some error messages not getting displayed
- Move stacktraces into the 'message' part of the reply
- Print errors to stderr instead of stdout
- Only show extended message if there is one
- Add a bunch of tests

Modified:
    lnt/trunk/lnt/server/ui/views.py
    lnt/trunk/lnt/util/ImportData.py
    lnt/trunk/lnt/util/ServerUtil.py
    lnt/trunk/tests/lnttool/submit.shtest

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=308402&r1=308401&r2=308402&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Tue Jul 18 18:14:23 2017
@@ -146,7 +146,10 @@ def _do_submit():
     if result.get('result_url'):
         result['result_url'] = request.url_root + result['result_url']
 
-    return flask.jsonify(**result)
+    response = flask.jsonify(**result)
+    if result['error'] is not None:
+        response.status_code=400
+    return response
 
 
 @db_route('/submitRun', only_v3=False, methods=('GET', 'POST'))

Modified: lnt/trunk/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/ImportData.py?rev=308402&r1=308401&r2=308402&view=diff
==============================================================================
--- lnt/trunk/lnt/util/ImportData.py (original)
+++ lnt/trunk/lnt/util/ImportData.py Tue Jul 18 18:14:23 2017
@@ -52,7 +52,8 @@ def import_and_report(config, db_name, d
         raise
     except:
         import traceback
-        result['error'] = "load failure: %s" % traceback.format_exc()
+        result['error'] = "could not parse input format"
+        result['message'] = traceback.format_exc()
         return result
 
     result['load_time'] = time.time() - startTime
@@ -83,16 +84,17 @@ def import_and_report(config, db_name, d
     try:
         data_schema = data.get('schema')
         if data_schema is not None and data_schema != ts_name:
-            raise ValueError("Importing '%s' data into test suite '%s'" %
-                             (data_schema, ts_name))
+            result['error'] = ("Importing '%s' data into test suite '%s'" %
+                               (data_schema, ts_name))
+            return result
 
         success, run = ts.importDataFromDict(data, commit, config=db_config)
     except KeyboardInterrupt:
         raise
-    except:
-        raise
+    except Exception as e:
         import traceback
-        result['error'] = "import failure: %s" % traceback.format_exc()
+        result['error'] = "import failure: %s" % e.message
+        result['message'] = traceback.format_exc()
         return result
 
     # If the import succeeded, save the import path.
@@ -180,6 +182,8 @@ def print_report_result(result, out, err
         out.flush()
         print >>err, "Import Failed:"
         print >>err, "--\n%s--\n" % result['error']
+        if result['message']:
+            print >>err, "%s\n" % result['message']
         err.flush()
         return
         

Modified: lnt/trunk/lnt/util/ServerUtil.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/ServerUtil.py?rev=308402&r1=308401&r2=308402&view=diff
==============================================================================
--- lnt/trunk/lnt/util/ServerUtil.py (original)
+++ lnt/trunk/lnt/util/ServerUtil.py Tue Jul 18 18:14:23 2017
@@ -23,8 +23,10 @@ def _show_json_error(reply):
     except ValueError:
         print "error: {}".format(reply)
         return
-    print "lnt server error: {}".format(error.get('error'))
-    print "error: {}".format(error.get('message'))
+    sys.stderr.write("lnt server error: {}\n".format(error.get('error')))
+    message = error.get('message', '')
+    if message:
+        sys.stderr.write(message + '\n')
 
 def submitFileToServer(url, file, commit):
     with open(file, 'rb') as f:

Modified: lnt/trunk/tests/lnttool/submit.shtest
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/submit.shtest?rev=308402&r1=308401&r2=308402&view=diff
==============================================================================
--- lnt/trunk/tests/lnttool/submit.shtest (original)
+++ lnt/trunk/tests/lnttool/submit.shtest Tue Jul 18 18:14:23 2017
@@ -85,3 +85,19 @@ lnt submit "http://localhost:9091/db_def
 # CHECK-COMPILE1: ----------------
 # CHECK-COMPILE1: PASS : 10
 # CHECK-COMPILE1: Results available at: http://localhost:9091/db_default/v4/compile/5
+
+# Check some error handling/reporting
+rm -f "${OUTPUT_DIR}/submit_errors.txt"
+lnt submit "http://localhost:9091/db_default/v4/badsuite/submitRun" --commit "${INPUTS}/compile_submission.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
+# RUN: FileCheck %s --check-prefix=CHECK-ERRORS < %T/submit_errors.txt
+# CHECK-ERRORS: lnt server error: Unknown test suite 'badsuite'!
+lnt submit "http://localhost:9091/db_baddb/v4/compile/submitRun" --commit "${INPUTS}/compile_submission.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
+# CHECK-ERRORS: lnt server error: The page you are looking for does not exist.
+lnt submit "http://localhost:9091/db_default/v4/compile/submitRun" --commit "${INPUTS}/invalid_submission0.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
+# CHECK-ERRORS: lnt server error: could not parse input format
+# ...
+# CHECK-ERRORS: SystemExit: unable to guess input format for
+lnt submit "http://localhost:9091/db_default/v4/compile/submitRun" --commit "${INPUTS}/invalid_submission1.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
+# CHECK-ERRORS: lnt server error: import failure: machine
+# ...
+# CHECK-ERRORS: KeyError: 'machine'




More information about the llvm-commits mailing list