|
| 1 | +import datetime |
| 2 | +import requests |
| 3 | +import json |
| 4 | +import pprint |
| 5 | +import time |
| 6 | +import os |
| 7 | +import sys |
| 8 | + |
| 9 | +# Note there are fewer git commits in the monorepo than there were svn revisions. |
| 10 | +#LLVM_REV=os.environ["GIT_DISTANCE"] |
| 11 | +#JOB_NAME=f'{os.environ["NODE_NAME"]}_{os.environ["JOB_NAME"]}' |
| 12 | + |
| 13 | +if len(sys.argv) != 2: |
| 14 | + print("Usage: submit-lldb-statistics-to-lnt.py <path/to/stats/directory>") |
| 15 | + sys.exit(1) |
| 16 | + |
| 17 | +LLDB_STATS_PATH=sys.argv[1] |
| 18 | + |
| 19 | +_data = {} |
| 20 | +for filename in os.listdir(LLDB_STATS_PATH): |
| 21 | + if not filename.endswith(".json"): |
| 22 | + continue |
| 23 | + |
| 24 | + json_path = os.path.join(LLDB_STATS_PATH, filename) |
| 25 | + with open(json_path, 'r') as f: |
| 26 | + # Test-case is the filename without the extension |
| 27 | + testcase_name = os.path.splitext(filename)[0] |
| 28 | + _data[testcase_name] = json.load(f) |
| 29 | + |
| 30 | +if len(_data) == 0: |
| 31 | + print("Empty data...exiting.") |
| 32 | + sys.exit(1) |
| 33 | + |
| 34 | +# For each test-case, create a separate LNT entry |
| 35 | +# (so we can compare statistics per test-case over time). |
| 36 | +for testcase_name, stats in _data.items(): |
| 37 | + run_infos = { |
| 38 | + "end_time": datetime.datetime.now().isoformat(), |
| 39 | + "start_time": datetime.datetime.now().isoformat(), |
| 40 | + "llvm_project_revision":LLVM_REV, |
| 41 | + } |
| 42 | + |
| 43 | + to_send = { |
| 44 | + "format_name": 'json', |
| 45 | + "format_version": "2", |
| 46 | + "machine": { |
| 47 | + "name": "%s_%s-v1"%(testcase_name, JOB_NAME), |
| 48 | + }, |
| 49 | + "run": run_infos, |
| 50 | + "tests": stats |
| 51 | + } |
| 52 | + to_send = { |
| 53 | + "merge": "replace", |
| 54 | + 'format_name': 'json', |
| 55 | + 'input_data': json.dumps(to_send), |
| 56 | + 'commit': "1", # compatibility with old servers. |
| 57 | + } |
| 58 | + |
| 59 | + |
| 60 | + pprint.pprint(to_send) |
| 61 | + try: |
| 62 | + requests.post("http://104.154.54.203/db_default/v4/nts/submitRun", data=to_send).raise_for_status() |
| 63 | + except: |
| 64 | + time.sleep(10) |
| 65 | + print("Sleeping because of error.") |
| 66 | + requests.post("http://104.154.54.203/db_default/v4/nts/submitRun", data=to_send).raise_for_status() |
0 commit comments