Skip to content

Commit b49b9cc

Browse files
authored
fix flaky calculation (#8539)
1 parent e923efd commit b49b9cc

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

.github/scripts/analytics/flaky_tests_history_n_runs.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ def callee(session):
3434
`build_type` Utf8 NOT NULL,
3535
`branch` Utf8 NOT NULL,
3636
`runs_window` Uint64 NOT NULL,
37+
`first_run` Timestamp,
38+
`last_run` Timestamp ,
39+
`owners` Utf8 NOT NULL,
3740
`history` String,
3841
`history_class` String,
3942
`pass_count` Uint64,
4043
`mute_count` Uint64,
4144
`fail_count` Uint64,
4245
`skip_count` Uint64,
43-
PRIMARY KEY (`test_name`, `suite_folder`, `full_name`,date_window,runs_window,build_type,branch)
46+
PRIMARY KEY (`test_name`, `suite_folder`, `full_name`,date_window,runs_window,build_type,branch,owners)
4447
)
4548
PARTITION BY HASH(`full_name`,build_type,branch)
4649
WITH (STORE = COLUMN)
@@ -59,6 +62,9 @@ def bulk_upsert(table_client, table_path, rows):
5962
.add_column("branch", ydb.OptionalType(ydb.PrimitiveType.Utf8))
6063
.add_column("full_name", ydb.OptionalType(ydb.PrimitiveType.Utf8))
6164
.add_column("date_window", ydb.OptionalType(ydb.PrimitiveType.Date))
65+
.add_column("first_run", ydb.OptionalType(ydb.PrimitiveType.Timestamp))
66+
.add_column("last_run", ydb.OptionalType(ydb.PrimitiveType.Timestamp))
67+
.add_column("owners", ydb.OptionalType(ydb.PrimitiveType.Utf8))
6268
.add_column("runs_window", ydb.OptionalType(ydb.PrimitiveType.Uint64))
6369
.add_column("history", ydb.OptionalType(ydb.PrimitiveType.String))
6470
.add_column("history_class", ydb.OptionalType(ydb.PrimitiveType.String))
@@ -150,7 +156,10 @@ def main():
150156
history_list,
151157
dist_hist,
152158
suite_folder,
153-
test_name
159+
test_name,
160+
owners,
161+
first_run,
162+
last_run
154163
from (
155164
select
156165
full_name,
@@ -160,13 +169,20 @@ def main():
160169
AGG_LIST(status) as history_list ,
161170
String::JoinFromList( AGG_LIST_DISTINCT(status) ,',') as dist_hist,
162171
suite_folder,
163-
test_name
172+
test_name,
173+
owners,
174+
min(run_timestamp) as first_run,
175+
max(run_timestamp) as last_run
164176
from (
165177
select * from (
166-
select t1.test_name, t1.suite_folder, t1.full_name,
167-
Date('{date}') as date_base,
168-
'{build_type}' as build_type,
169-
'{branch}' as branch
178+
select
179+
t1.suite_folder,
180+
t1.test_name,
181+
t1.full_name,
182+
t1.owners,
183+
Date('{date}') as date_base,
184+
'{build_type}' as build_type,
185+
'{branch}' as branch
170186
from `test_results/analytics/testowners` as t1
171187
) as test_and_date
172188
left JOIN (
@@ -175,11 +191,11 @@ def main():
175191
suite_folder || '/' || test_name as full_name,
176192
run_timestamp,
177193
status ,
178-
ROW_NUMBER() OVER (PARTITION BY test_name ORDER BY run_timestamp DESC) AS run_number
194+
ROW_NUMBER() OVER (PARTITION BY suite_folder,test_name ORDER BY run_timestamp DESC) AS run_number
179195
from `test_results/test_runs_column`
180196
where
181-
run_timestamp <= Date('{date}')
182-
and run_timestamp >= Date('{date}') -14*Interval("P1D")
197+
run_timestamp <= Date('{date}') + Interval("P1D")
198+
and run_timestamp >= Date('{date}') -13*Interval("P1D")
183199
and job_name in ('Postcommit_relwithdebinfo','Postcommit_asan')
184200
and build_type = '{build_type}'
185201
and status != 'skipped'
@@ -189,7 +205,7 @@ def main():
189205
) as hist
190206
ON test_and_date.full_name=hist.full_name
191207
)
192-
GROUP BY full_name,suite_folder,test_name,date_base,build_type,branch
208+
GROUP BY full_name,suite_folder,test_name,date_base,build_type,branch,owners
193209
194210
)
195211
"""
@@ -217,6 +233,9 @@ def main():
217233
prepared_for_update_rows.append({
218234
'suite_folder': row['suite_folder'],
219235
'test_name': row['test_name'],
236+
'first_run': row['first_run'],
237+
'last_run': row['last_run'],
238+
'owners': row['owners'],
220239
'full_name': row['full_name'],
221240
'date_window': row['date_base'],
222241
'build_type': row['build_type'],

.github/workflows/collect_analytics.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ jobs:
3737
run: python3 .github/scripts/analytics/flaky_tests_history_n_runs.py --runs=10
3838
- name: Collect test history data with window 10 run release-asan for main
3939
run: python3 .github/scripts/analytics/flaky_tests_history_n_runs.py --runs=10 --build_type=release-asan
40+
- name: Collect test history data with window 50 run relwithdebinfo for main
41+
run: python3 .github/scripts/analytics/flaky_tests_history_n_runs.py --runs=50
42+
- name: Collect test history data with window 50 run release-asan for main
43+
run: python3 .github/scripts/analytics/flaky_tests_history_n_runs.py --runs=50 --build_type=release-asan
4044

4145

0 commit comments

Comments
 (0)