[LNT] r318075 - Allow submissions without start_time/end_time field.

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 11:39:53 PST 2017


Author: matze
Date: Mon Nov 13 11:39:53 2017
New Revision: 318075

URL: http://llvm.org/viewvc/llvm-project?rev=318075&view=rev
Log:
Allow submissions without start_time/end_time field.

Simply set start_time/end_time to the current time if the fields are not
specified at submission time.

Added:
    lnt/trunk/tests/lnttool/Inputs/minimal.json
Modified:
    lnt/trunk/docs/importing_data.rst
    lnt/trunk/lnt/testing/__init__.py
    lnt/trunk/lnt/util/ImportData.py
    lnt/trunk/tests/lnttool/checkformat.shtest
    lnt/trunk/tests/lnttool/submit.shtest

Modified: lnt/trunk/docs/importing_data.rst
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docs/importing_data.rst?rev=318075&r1=318074&r2=318075&view=diff
==============================================================================
--- lnt/trunk/docs/importing_data.rst (original)
+++ lnt/trunk/docs/importing_data.rst Mon Nov 13 11:39:53 2017
@@ -42,9 +42,9 @@ First, make sure you've understood the u
           (_String_: _String_)* // optional extra info
       },
       "run": {
-          "start_time": "%Y-%m-%dT%H:%M:%S", // mandatory, ISO8061 timestamp
-          "end_time": "%Y-%m-%dT%H:%M:%S",   // mandatory, ISO8061 timestamp, can equal start_time if not known.
-          (_String_: _String_)* // optional extra info about the run.
+          ("start_time": "%Y-%m-%dT%H:%M:%S",)? // optional, ISO8061 timestamp
+          ("end_time": "%Y-%m-%dT%H:%M:%S",)?   // optional, ISO8061 timestamp, can equal start_time if not known.
+          (_String_: _String_,)* // optional extra info about the run.
           // At least one of the extra fields is used as ordering and is
           // mandatory. For the 'nts' and 'Compile' schemas this is the
           // 'llvm_project_revision' field.

Modified: lnt/trunk/lnt/testing/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/__init__.py?rev=318075&r1=318074&r2=318075&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/__init__.py (original)
+++ lnt/trunk/lnt/testing/__init__.py Mon Nov 13 11:39:53 2017
@@ -348,10 +348,13 @@ def upgrade_1_to_2(data, ts_name):
 
     # Flatten Result.Info into result
     Run = data['Run']
-    result_run = {
-        'end_time': Run['End Time'],
-        'start_time': Run['Start Time'],
-    }
+    result_run = {}
+    start_time = Run.get('Start Time')
+    if start_time is not None:
+        result_run['start_time'] = start_time
+    end_time = Run.get('End Time')
+    if end_time is not None:
+        result_run['end_time'] = end_time
     for key, value in Run['Info'].items():
         newname = upgrade.run_param_rename.get(key, key)
         if newname in result_run:
@@ -417,11 +420,12 @@ def upgrade_1_to_2(data, ts_name):
     return result
 
 
-def upgrade_report(data, ts_name):
+def upgrade_and_normalize_report(data, ts_name):
     # Get the report version. V2 has it at the top level, older version
     # in Run.Info.
     format_version = _get_format_version(data)
     if format_version is None:
+        data['format_version'] = '2'
         format_version = 2
 
     if format_version == 0:
@@ -430,7 +434,26 @@ def upgrade_report(data, ts_name):
     if format_version == 1:
         data = upgrade_1_to_2(data, ts_name)
         format_version = 2
-    assert(format_version == 2)
+
+    if format_version != 2 or data['format_version'] != '2':
+        raise ValueError("Unknown format version")
+    if 'run' not in data:
+        import pprint
+        logger.info(pprint.pformat(data))
+        raise ValueError("No 'run' section in submission")
+    if 'machine' not in data:
+        raise ValueError("No 'machine' section in submission")
+    if 'tests' not in data:
+        raise ValueError("No 'tests' section in submission")
+
+    run = data['run']
+    if not 'start_time' in run:
+        time = datetime.datetime.utcnow().replace(microsecond=0).isoformat()
+        run['start_time'] = time
+        run['end_time'] = time
+    elif not 'end_time' in run:
+        run['end_time'] = run['start_time']
+
     return data
 
 

Modified: lnt/trunk/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/ImportData.py?rev=318075&r1=318074&r2=318075&view=diff
==============================================================================
--- lnt/trunk/lnt/util/ImportData.py (original)
+++ lnt/trunk/lnt/util/ImportData.py Mon Nov 13 11:39:53 2017
@@ -67,7 +67,13 @@ def import_and_report(config, db_name, d
     result['load_time'] = time.time() - startTime
 
     # Auto-upgrade the data, if necessary.
-    data = lnt.testing.upgrade_report(data, ts_name)
+    try:
+        data = lnt.testing.upgrade_and_normalize_report(data, ts_name)
+    except ValueError as e:
+        import traceback
+        result['error'] = "Invalid input format: %s" % e
+        result['message'] = traceback.format_exc()
+        return result
 
     # Find the database config, if we have a configuration object.
     if config:

Added: lnt/trunk/tests/lnttool/Inputs/minimal.json
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/Inputs/minimal.json?rev=318075&view=auto
==============================================================================
--- lnt/trunk/tests/lnttool/Inputs/minimal.json (added)
+++ lnt/trunk/tests/lnttool/Inputs/minimal.json Mon Nov 13 11:39:53 2017
@@ -0,0 +1,5 @@
+{
+    "machine": { "name": "minimal" },
+    "run": { "llvm_project_revision": "311066" },
+    "tests": []
+}

Modified: lnt/trunk/tests/lnttool/checkformat.shtest
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/checkformat.shtest?rev=318075&r1=318074&r2=318075&view=diff
==============================================================================
--- lnt/trunk/tests/lnttool/checkformat.shtest (original)
+++ lnt/trunk/tests/lnttool/checkformat.shtest Mon Nov 13 11:39:53 2017
@@ -43,6 +43,12 @@
 # CHECK2: PASS : 10
 #
 #
+# RUN: lnt checkformat %S/Inputs/minimal.json 2>&1 | FileCheck %s --check-prefix=MINIMAL
+# MINIMAL: Import succeeded.
+# MINIMAL: Added Machines: 1
+# MINIMAL: Added Runs    : 1
+#
+#
 # Check invalid format
 # RUN: lnt checkformat %S/Inputs/invalid_submission0.json 2>&1 | FileCheck %s --check-prefix=CHECKFAIL0
 #

Modified: lnt/trunk/tests/lnttool/submit.shtest
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/submit.shtest?rev=318075&r1=318074&r2=318075&view=diff
==============================================================================
--- lnt/trunk/tests/lnttool/submit.shtest (original)
+++ lnt/trunk/tests/lnttool/submit.shtest Mon Nov 13 11:39:53 2017
@@ -88,21 +88,36 @@ lnt submit "http://localhost:9091/db_def
 # CHECK-COMPILE1: Results available at: http://localhost:9091/db_default/v4/compile/6
 
 # Check some error handling/reporting
+# RUN: FileCheck %s --check-prefix=CHECK-ERRORS < %t.tmp/submit_errors.txt
 rm -f "${OUTPUT_DIR}/submit_errors.txt"
+
+echo "=== compile_submission.json badsuite" >> "${OUTPUT_DIR}/submit_errors.txt"
 not lnt submit "http://localhost:9091/db_default/v4/badsuite/submitRun" "${INPUTS}/compile_submission.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
-# RUN: FileCheck %s --check-prefix=CHECK-ERRORS < %t.tmp/submit_errors.txt
+# CHECK-ERRORS-LABEL: === compile_submission.json badsuite
 # CHECK-ERRORS: error: lnt server: Unknown test suite 'badsuite'!
+
+echo "=== compile_submission.json baddb" >> "${OUTPUT_DIR}/submit_errors.txt"
 not lnt submit "http://localhost:9091/db_baddb/v4/compile/submitRun" "${INPUTS}/compile_submission.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
+# CHECK_ERROR-LABEL: === compile_submission.json baddb
 # CHECK-ERRORS: error: lnt server: The page you are looking for does not exist.
+
+echo "=== invalid_submission0.json" >> "${OUTPUT_DIR}/submit_errors.txt"
 not lnt submit "http://localhost:9091/db_default/v4/compile/submitRun" "${INPUTS}/invalid_submission0.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
+# CHECK-ERRORS-LABEL: === invalid_submission0.json
 # CHECK-ERRORS: error: lnt server: could not parse input format
 # ...
 # CHECK-ERRORS: ValueError: unable to guess input format for
+
+echo "=== invalid_submission1.json" >> "${OUTPUT_DIR}/submit_errors.txt"
 not lnt submit "http://localhost:9091/db_default/v4/compile/submitRun" "${INPUTS}/invalid_submission1.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
-# CHECK-ERRORS: error: lnt server: import failure: machine
+# CHECK-ERRORS-LABEL: === invalid_submission1.json
+# CHECK-ERRORS: error: lnt server: Invalid input format: No 'run' section in submission
 # ...
-# CHECK-ERRORS: KeyError: 'machine'
+# CHECK-ERRORS: ValueError: No 'run' section in submission
+
+echo "=== compile_submission_machine_diff_reject.json" >> "${OUTPUT_DIR}/submit_errors.txt"
 not lnt submit "http://localhost:9091/db_default/v4/compile/submitRun" "${INPUTS}/compile_submission_machine_diff_reject.json" >> "${OUTPUT_DIR}/submit_errors.txt" 2>&1
+# CHECK-ERRORS-LABEL: === compile_submission_machine_diff_reject.json
 # CHECK-ERRORS: error: lnt server: import failure: 'hw.activecpu' on machine 'some-compile-suite-machine' changed.
 # ...
 # CHECK-ERRORS: MachineInfoChanged: 'hw.activecpu' on machine 'some-compile-suite-machine' changed.




More information about the llvm-commits mailing list