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