forked from kubernetes/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flakes-config.yaml
100 lines (99 loc) · 3.63 KB
/
flakes-config.yaml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
metric: flakes
description: Calculates flakiness for each job for the past week and the flakiest tests for each job.
query: |
#standardSQL
select
job,
build_consistency,
commit_consistency,
flakes,
runs,
commits,
array(
select as struct
i.n name,
count(i.failures) flakes
from tt.tests i
group by name
having name not in ('Test', 'DiffResources', 'DumpClusterLogs', 'DumpFederationLogs') /* uninteresting tests */
order by flakes desc
limit 10 /* top ten flakiest tests in this job */
) flakiest
from (
select
job, /* name of job */
round(sum(if(flaked=1,passed,runs))/sum(runs),3) build_consistency, /* percentage of runs that did not flake */
round(1-sum(flaked)/count(distinct commit),3) commit_consistency, /* percentage of commits that did not flake */
sum(flaked) flakes, /* number of times it flaked */
sum(runs) runs, /* number of times the job ran */
count(distinct commit) commits, /* number of commits tested */
array_concat_agg(tests) tests /* array of flaking tests in this job */
from (
select
job,
commit,
if(passed = runs or passed = 0, 0, 1) flaked, /* consistent: always pass or always fail */
passed,
safe_cast(runs as int64) runs,
array(
select as struct
i.name n, /* test name */
countif(i.failed) failures /* number of times it flaked */
from tt.tests i
group by n
having failures > 0 and failures < tt.runs /* same consistency metric */
order by failures desc
) tests
from (
select
job,
commit,
sum(if(result='SUCCESS',1,0)) passed,
count(result) runs, /* count the number of times we ran a job on this commit for this PR */
array_concat_agg(test) tests /* create an array of tests structs */
from (
SELECT
job,
if(substr(job, 0, 3) = 'pr:', 'pull', 'ci') kind, /* pull or ci */
version, /* bootstrap git version, empty for ci */
if(substr(job, 0, 3) = 'pr:',
regexp_extract(
(
select i.value
from t.metadata i
where i.key = 'repos'
),
r'[^,]+,\d+:([a-f0-9]+)"'
),
version
) commit, /* repo commit for PR or version for CI */
result, /* SUCCESS if the build passed */
test /* repeated tuple of tests */
FROM `k8s-gubernator.build.week` as t
where
datetime(started) > datetime_sub(current_datetime(), interval 7 DAY)
and version != 'unknown'
and (
(substr(job, 0, 3) = 'ci-' and version != 'unknown') or
exists(
select as struct
i
from t.metadata i
where i.key = 'repos' and
array_length(split(replace(i.value,', ', ''), ',')) = 2 /*serial pr jobs only (# of PR refs +1 == 2)*/
)
)
)
group by job, commit
) as tt
) as tt
group by job /* summarize info for this job across all commits/builds */
) as tt
order by flakes desc, commit_consistency, build_consistency, job /* flakiest jobs first */
jqfilter: |
[(.[] | select(.job | contains("pr:")) | {(.job): {
consistency: (.commit_consistency|tonumber),
flakes: (.flakes|tonumber),
flakiest: ([(.flakiest[] | select(.flakes|tonumber >= 4) | {
(.name): (.flakes|tonumber)}) ])| add
}})] | add