Skip to content

Commit 6abcce0

Browse files
committed
contest: subcases: handle retry cases
In case of failure, some tests are restarted. That's great, but when parsing the subcases (nested tests), the previous results were overridden. Also, when displaying the results, the 'retry' field from the main test was re-used in each subcases: quite confusing for the reader. Now, in case of retry, a new dictionary under the 'results-retry' key is stored in the 'json_full' entry in the DB. This dictionary uses the subcase titles as keys, and the results as values. Thanks to that, when querying the subcases results, this dictionary is used to properly set the 'retry' field for each subcase. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent f08356b commit 6abcce0

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

contest/backend/query.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ def result_as_l2(raw):
6161
for case in l1["results"]:
6262
data = l1.copy()
6363
del data["results"]
64-
if "time" in data:
65-
del data["time"]
64+
for del_key in ("results-retry", "time", "retry"):
65+
if del_key in data:
66+
del data[del_key]
67+
6668
data |= case
6769
data["test"] = l1["test"] + '.' + case["test"]
70+
if "results-retry" in l1 and case["test"] in l1["results-retry"]:
71+
data["retry"] = l1["results-retry"][case["test"]]
72+
6873
flat.append(data)
6974
row["results"] = flat
7075
return json.dumps(row)

contest/remote/vmksft-p.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ def get_prog_list(vm, targets):
6969
return [(e.split(":")[0].strip(), e.split(":")[1].strip()) for e in targets]
7070

7171

72-
def _parse_nested_tests(full_run):
73-
tests = []
72+
def _parse_nested_tests(full_run, flat):
73+
if flat:
74+
tests = {}
75+
else:
76+
tests = []
7477
nested_tests = False
7578

7679
result_re = re.compile(r"(not )?ok (\d+)( -)? ([^#]*[^ ])( +# +)?([^ ].*)?$")
@@ -110,7 +113,10 @@ def _parse_nested_tests(full_run):
110113

111114
r['result'] = result
112115

113-
tests.append(r)
116+
if flat:
117+
tests[r['test']] = r['result']
118+
else:
119+
tests.append(r)
114120

115121
return tests
116122

@@ -196,9 +202,10 @@ def _vm_thread(config, results_path, thr_id, hard_stop, in_queue, out_queue):
196202

197203
if config.getboolean('ksft', 'nested_tests', fallback=False):
198204
# this will only parse nested tests inside the TAP comments
199-
nested_tests = _parse_nested_tests(vm.log_out)
205+
nested_tests = _parse_nested_tests(vm.log_out, is_retry)
200206
if nested_tests:
201-
outcome['results'] = nested_tests
207+
nested_key = 'results-retry' if is_retry else 'results'
208+
outcome[nested_key] = nested_tests
202209

203210
print(f"INFO: thr-{thr_id} {prog} >> nested tests: {len(nested_tests)}")
204211

@@ -318,7 +325,7 @@ def test(binfo, rinfo, cbarg):
318325
'result': r["result"],
319326
'link': link + '/' + r['file_name']
320327
}
321-
for key in ['time', 'retry', 'crashes', 'results']:
328+
for key in ['time', 'retry', 'crashes', 'results', 'results-retry']:
322329
if key in r:
323330
outcome[key] = r[key]
324331
cases.append(outcome)

contest/results-fetcher.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ def psql_json_split(self, data):
9696
full = None
9797

9898
for row in normal["results"]:
99-
if "results" in row:
100-
full = True
101-
del row["results"]
99+
for rkey in ("results", "results-retry"):
100+
if rkey in row:
101+
full = True
102+
del row[rkey]
102103

103104
if full:
104105
full = json.dumps(data)

0 commit comments

Comments
 (0)