Skip to content

Commit 9efdb98

Browse files
committed
contest: status: break down flakiness query by week (not 2 weeks)
Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9028c86 commit 9efdb98

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

contest/backend/query.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ def flaky_tests():
245245

246246
print(f"Query for flaky tests took: {str(datetime.datetime.now() - t)}")
247247

248-
target_date = datetime.datetime.now() - datetime.timedelta(days=14)
249-
two_weeks = target_date.strftime("%Y-%m-%d--%H-%M")
250-
target_date = datetime.datetime.now() - datetime.timedelta(days=28)
251-
four_weeks = target_date.strftime("%Y-%m-%d--%H-%M")
248+
weeks_ago = []
249+
for weeks in range(1, 5):
250+
target_date = datetime.datetime.now() - datetime.timedelta(weeks=weeks)
251+
weeks_ago.append(target_date.strftime("%Y-%m-%d--%H-%M"))
252+
252253
cnt = 0
253254
res = {}
254255
for row in rows:
@@ -258,13 +259,14 @@ def flaky_tests():
258259
res[key] = res.get(key, 0) + 1
259260
else:
260261
if key not in res:
261-
res[key] = [0, 0]
262-
if br_date >= two_weeks:
263-
res[key][0] += 1
264-
elif br_date >= four_weeks:
265-
res[key][1] += 1
262+
res[key] = [0, 0, 0, 0]
263+
264+
for i in range(len(weeks_ago)):
265+
if br_date >= weeks_ago[i]:
266+
res[key][i] += 1
267+
break
266268
else:
267-
break
269+
break # stop looking at rows, the records are sorted by date
268270
cnt += 1
269271
# JSON needs a simple array, not a dict
270272
data = []

ui/status.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ <h3>Flakiest tests</h3>
5959
<th>Remote</th>
6060
<th>Executor</th>
6161
<th>Test</th>
62-
<th>Flakes (now - 2w)</th>
63-
<th>Flakes (2w - 4w)</th>
62+
<th colspan="4">Flakes (by week: this, 1, 2, 3 ago)</th>
6463
<th>Ignored</th>
6564
</tr>
6665
</table>

ui/status.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,8 @@ function flakes_doit(data_raw)
10141014
return b["count"][0] - a["count"][0];
10151015
if (a["count"][1] != b["count"][1])
10161016
return b["count"][1] - a["count"][1];
1017+
if (a["count"][2] != b["count"][2])
1018+
return b["count"][2] - a["count"][2];
10171019
return 0;
10181020
})
10191021

@@ -1022,7 +1024,7 @@ function flakes_doit(data_raw)
10221024
let reported = nipa_pw_reported(v, v);
10231025
let ignored = "";
10241026

1025-
if (v["count"][0] < 3 && reported)
1027+
if (v["count"][0] + v["count"][1] + v["count"][2] < 4 && reported)
10261028
return 1;
10271029
if (!reported)
10281030
ignored = "yes";
@@ -1032,7 +1034,9 @@ function flakes_doit(data_raw)
10321034
row.insertCell(2).innerText = v["test"];
10331035
row.insertCell(3).innerText = v["count"][0];
10341036
row.insertCell(4).innerText = v["count"][1];
1035-
row.insertCell(5).innerText = ignored;
1037+
row.insertCell(5).innerText = v["count"][2];
1038+
row.insertCell(6).innerText = v["count"][3];
1039+
row.insertCell(7).innerText = ignored;
10361040
});
10371041
}
10381042

0 commit comments

Comments
 (0)