Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 905d703

Browse files
fix new ta tasks bugs (#1008)
1 parent 40613b5 commit 905d703

8 files changed

Lines changed: 110 additions & 97 deletions

ta_storage/pg.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,18 @@ def modify_structures(
6363
framework: str | None,
6464
):
6565
flags_hash = generate_flags_hash(upload.flag_names)
66+
67+
test_name = f"{testrun['classname']}\x1f{testrun['name']}"
6668
test_id = generate_test_id(
6769
repoid,
6870
testrun["testsuite"],
69-
testrun["name"],
71+
test_name,
7072
flags_hash,
7173
)
7274

73-
test = generate_test_dict(test_id, repoid, testrun, flags_hash, framework)
75+
test = generate_test_dict(
76+
test_id, test_name, repoid, testrun, flags_hash, framework
77+
)
7478
tests_to_write[test_id] = test
7579

7680
test_instance = generate_test_instance_dict(
@@ -83,10 +87,10 @@ def modify_structures(
8387
{"test_id": test_id, "flag_id": flag_id} for flag_id in repo_flag_ids
8488
)
8589

86-
if test["id"] in daily_totals:
90+
if test_id in daily_totals:
8791
update_daily_totals(
8892
daily_totals,
89-
test["id"],
93+
test_id,
9094
testrun["duration"],
9195
testrun["outcome"],
9296
)
@@ -105,6 +109,7 @@ def modify_structures(
105109

106110
def generate_test_dict(
107111
test_id: str,
112+
test_name: str,
108113
repoid: int,
109114
testrun: test_results_parser.Testrun,
110115
flags_hash: str,
@@ -113,7 +118,7 @@ def generate_test_dict(
113118
return {
114119
"id": test_id,
115120
"repoid": repoid,
116-
"name": f"{testrun['classname']}\x1f{testrun['name']}",
121+
"name": test_name,
117122
"testsuite": testrun["testsuite"],
118123
"flags_hash": flags_hash,
119124
"framework": framework,

tasks/ta_finisher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_uploads(db_session: Session, commit: Commit) -> dict[int, Upload]:
7070
.filter(
7171
CommitReport.commit_id == commit.id,
7272
CommitReport.report_type == ReportType.TEST_RESULTS.value,
73-
Upload.state == "v2_processed",
73+
Upload.state.in_(["v2_processed", "v2_finished"]),
7474
)
7575
.all()
7676
)

tasks/ta_processor.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def process_individual_upload(
111111
else:
112112
flaky_test_set = get_flake_set(db_session, upload.report.commit.repoid)
113113
pg = PGDriver(db_session, flaky_test_set)
114-
bq = BQDriver()
114+
bq_enabled = False
115+
if get_config("services", "bigquery", "enabled", default=False):
116+
bq = BQDriver()
117+
bq_enabled = True
115118

116119
for parsing_info in parsing_infos:
117120
framework = parsing_info["framework"]
@@ -126,15 +129,16 @@ def process_individual_upload(
126129
testruns,
127130
)
128131

129-
bq.write_testruns(
130-
None,
131-
repoid,
132-
commitid,
133-
branch,
134-
upload,
135-
framework,
136-
testruns,
137-
)
132+
if bq_enabled:
133+
bq.write_testruns(
134+
None,
135+
repoid,
136+
commitid,
137+
branch,
138+
upload,
139+
framework,
140+
testruns,
141+
)
138142

139143
upload.state = "v2_processed"
140144
db_session.commit()

tasks/tests/unit/snapshots/ta_finisher_task__analytics__0.json

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"tests": [
33
{
44
"repoid": 1,
5-
"name": "tests.test_parsers.TestParsers\u001ftest_subtract",
5+
"name": "tests.test_parsers.TestParsers\u001ftest_add",
66
"testsuite": "hello_world",
77
"flags_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
88
"framework": null,
@@ -29,7 +29,7 @@
2929
},
3030
{
3131
"repoid": 1,
32-
"name": "tests.test_parsers.TestParsers\u001ftest_add",
32+
"name": "tests.test_parsers.TestParsers\u001ftest_subtract",
3333
"testsuite": "hello_world",
3434
"flags_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
3535
"framework": null,
@@ -39,7 +39,7 @@
3939
],
4040
"test_instances": [
4141
{
42-
"test_id": "7741ad6f22bd0b1e1f0dee0978162ffeed170807b08e926b2ea7518cb214f667",
42+
"test_id": "6080920d6523ea1e4fafb11a373eb8fb135602ff7533f216a8afbb6902d4ebad",
4343
"duration_seconds": 0.001,
4444
"outcome": "failure",
4545
"upload_id": 1,
@@ -49,29 +49,29 @@
4949
"repoid": 1
5050
},
5151
{
52-
"test_id": "cdc5500179182edbe26b3b0934408a2f0a015592e4311ae709bcedd3235b1486",
53-
"duration_seconds": 0.002,
54-
"outcome": "pass",
52+
"test_id": "60cc388df55fc4f02578bb9eb69604f0641e8b97fc36be57c941fa0dc2b705dc",
53+
"duration_seconds": 0.003,
54+
"outcome": "skip",
5555
"upload_id": 1,
5656
"failure_message": null,
5757
"branch": "main",
5858
"commitid": "cd76b0821854a780b60012aed85af0a8263004ad",
5959
"repoid": 1
6060
},
6161
{
62-
"test_id": "e0f2e4b242b5dcb8b7ddc273936d217ca755ef3a47a9824ec025c4ce1b418ef7",
63-
"duration_seconds": 0.003,
64-
"outcome": "skip",
62+
"test_id": "97634e0504c2070fb13fc5a1fd66a085c920cb09981da2441656717de0b79784",
63+
"duration_seconds": 0.004,
64+
"outcome": "error",
6565
"upload_id": 1,
6666
"failure_message": null,
6767
"branch": "main",
6868
"commitid": "cd76b0821854a780b60012aed85af0a8263004ad",
6969
"repoid": 1
7070
},
7171
{
72-
"test_id": "11b8beeee314d9674013cacdddc40d56d9ec3eb0c4bc38d75e74312888e31306",
73-
"duration_seconds": 0.004,
74-
"outcome": "error",
72+
"test_id": "b5bc0c2f4f84a8a117e2c95583053a0f473031aa82a79b6a1fe56f18622b8898",
73+
"duration_seconds": 0.002,
74+
"outcome": "pass",
7575
"upload_id": 1,
7676
"failure_message": null,
7777
"branch": "main",
@@ -81,39 +81,53 @@
8181
],
8282
"rollups": [
8383
{
84-
"test_id": "11b8beeee314d9674013cacdddc40d56d9ec3eb0c4bc38d75e74312888e31306",
84+
"test_id": "6080920d6523ea1e4fafb11a373eb8fb135602ff7533f216a8afbb6902d4ebad",
8585
"date": "2025-01-01",
8686
"repoid": 1,
8787
"branch": "main",
8888
"fail_count": 1,
8989
"flaky_fail_count": 0,
9090
"skip_count": 0,
9191
"pass_count": 0,
92-
"last_duration_seconds": 0.004,
93-
"avg_duration_seconds": 0.004,
92+
"last_duration_seconds": 0.001,
93+
"avg_duration_seconds": 0.001,
9494
"latest_run": "2025-01-01T00:00:00+00:00",
9595
"commits_where_fail": [
9696
"cd76b0821854a780b60012aed85af0a8263004ad"
9797
]
9898
},
9999
{
100-
"test_id": "7741ad6f22bd0b1e1f0dee0978162ffeed170807b08e926b2ea7518cb214f667",
100+
"test_id": "60cc388df55fc4f02578bb9eb69604f0641e8b97fc36be57c941fa0dc2b705dc",
101+
"date": "2025-01-01",
102+
"repoid": 1,
103+
"branch": "main",
104+
"fail_count": 0,
105+
"flaky_fail_count": 0,
106+
"skip_count": 1,
107+
"pass_count": 0,
108+
"last_duration_seconds": 0.003,
109+
"avg_duration_seconds": 0.003,
110+
"latest_run": "2025-01-01T00:00:00+00:00",
111+
"commits_where_fail": []
112+
},
113+
{
114+
"test_id": "97634e0504c2070fb13fc5a1fd66a085c920cb09981da2441656717de0b79784",
101115
"date": "2025-01-01",
102116
"repoid": 1,
103117
"branch": "main",
104118
"fail_count": 1,
105119
"flaky_fail_count": 0,
106120
"skip_count": 0,
107121
"pass_count": 0,
108-
"last_duration_seconds": 0.001,
109-
"avg_duration_seconds": 0.001,
122+
"last_duration_seconds": 0.004,
123+
"avg_duration_seconds": 0.004,
110124
"latest_run": "2025-01-01T00:00:00+00:00",
111125
"commits_where_fail": [
112126
"cd76b0821854a780b60012aed85af0a8263004ad"
113127
]
114128
},
115129
{
116-
"test_id": "cdc5500179182edbe26b3b0934408a2f0a015592e4311ae709bcedd3235b1486",
130+
"test_id": "b5bc0c2f4f84a8a117e2c95583053a0f473031aa82a79b6a1fe56f18622b8898",
117131
"date": "2025-01-01",
118132
"repoid": 1,
119133
"branch": "main",
@@ -125,20 +139,6 @@
125139
"avg_duration_seconds": 0.002,
126140
"latest_run": "2025-01-01T00:00:00+00:00",
127141
"commits_where_fail": []
128-
},
129-
{
130-
"test_id": "e0f2e4b242b5dcb8b7ddc273936d217ca755ef3a47a9824ec025c4ce1b418ef7",
131-
"date": "2025-01-01",
132-
"repoid": 1,
133-
"branch": "main",
134-
"fail_count": 0,
135-
"flaky_fail_count": 0,
136-
"skip_count": 1,
137-
"pass_count": 0,
138-
"last_duration_seconds": 0.003,
139-
"avg_duration_seconds": 0.003,
140-
"latest_run": "2025-01-01T00:00:00+00:00",
141-
"commits_where_fail": []
142142
}
143143
]
144144
}

tasks/tests/unit/snapshots/ta_processor_task__TestUploadTestProcessorTask__ta_processor_task_call__0.json

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"tests": [
33
{
44
"repoid": 1,
5-
"name": "api.temp.calculator.test_calculator\u001ftest_multiply",
5+
"name": "api.temp.calculator.test_calculator\u001ftest_add",
66
"testsuite": "pytest",
77
"flags_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
88
"framework": "Pytest",
9-
"computed_name": "api.temp.calculator.test_calculator::test_multiply",
9+
"computed_name": "api.temp.calculator.test_calculator::test_add",
1010
"filename": null
1111
},
1212
{
@@ -20,11 +20,11 @@
2020
},
2121
{
2222
"repoid": 1,
23-
"name": "api.temp.calculator.test_calculator\u001ftest_add",
23+
"name": "api.temp.calculator.test_calculator\u001ftest_multiply",
2424
"testsuite": "pytest",
2525
"flags_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
2626
"framework": "Pytest",
27-
"computed_name": "api.temp.calculator.test_calculator::test_add",
27+
"computed_name": "api.temp.calculator.test_calculator::test_multiply",
2828
"filename": null
2929
},
3030
{
@@ -39,17 +39,17 @@
3939
],
4040
"test_instances": [
4141
{
42-
"test_id": "6cbd65e47887eda0f4c0355b0a03e549284499e1acf80cb16bfd7797b546a3cb",
42+
"test_id": "904b835b97b7697b036b217530783b194dcdd014d2fd1b717cf22641c8ee339c",
4343
"duration_seconds": 0.001,
44-
"outcome": "pass",
44+
"outcome": "failure",
4545
"upload_id": 1,
46-
"failure_message": null,
46+
"failure_message": "def test_divide():\n> assert Calculator.divide(1, 2) == 0.5\nE assert 1.0 == 0.5\nE + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)\nE + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide\n\napi/temp/calculator/test_calculator.py:30: AssertionError",
4747
"branch": null,
4848
"commitid": "cd76b0821854a780b60012aed85af0a8263004ad",
4949
"repoid": 1
5050
},
5151
{
52-
"test_id": "80ee2bcfe6727cd875914bc1fa2995fd5feea6171803907dfd3383154f643038",
52+
"test_id": "d01ca01cb4b8dede6201a0ebadf9471dcc0e972b257417a79dc531665794afe0",
5353
"duration_seconds": 0.001,
5454
"outcome": "pass",
5555
"upload_id": 1,
@@ -59,8 +59,8 @@
5959
"repoid": 1
6060
},
6161
{
62-
"test_id": "277ea9e35f1a02d0a8b441b9b74ecd48d35168929ff5ee9fa3dce48a6c4ea0ea",
63-
"duration_seconds": 0.0,
62+
"test_id": "d0abb665403924c55f02d0b79ed3be6b3ece9cdebf4c1c40b91a8a8d07319281",
63+
"duration_seconds": 0.001,
6464
"outcome": "pass",
6565
"upload_id": 1,
6666
"failure_message": null,
@@ -69,49 +69,49 @@
6969
"repoid": 1
7070
},
7171
{
72-
"test_id": "3ffa89c17705abeeff8728d3cd030c563ac1d40c67ae5e6e84c1bc66d4d6e012",
73-
"duration_seconds": 0.001,
74-
"outcome": "failure",
72+
"test_id": "d4259940b7b895581e9e8eeecf94803ea0148df4a7c48d7984d57bfb5e122209",
73+
"duration_seconds": 0.0,
74+
"outcome": "pass",
7575
"upload_id": 1,
76-
"failure_message": "def test_divide():\n> assert Calculator.divide(1, 2) == 0.5\nE assert 1.0 == 0.5\nE + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)\nE + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide\n\napi/temp/calculator/test_calculator.py:30: AssertionError",
76+
"failure_message": null,
7777
"branch": null,
7878
"commitid": "cd76b0821854a780b60012aed85af0a8263004ad",
7979
"repoid": 1
8080
}
8181
],
8282
"rollups": [
8383
{
84-
"test_id": "277ea9e35f1a02d0a8b441b9b74ecd48d35168929ff5ee9fa3dce48a6c4ea0ea",
84+
"test_id": "904b835b97b7697b036b217530783b194dcdd014d2fd1b717cf22641c8ee339c",
8585
"date": "2025-01-01",
8686
"repoid": 1,
8787
"branch": null,
88-
"fail_count": 0,
88+
"fail_count": 1,
8989
"flaky_fail_count": 0,
9090
"skip_count": 0,
91-
"pass_count": 1,
92-
"last_duration_seconds": 0.0,
93-
"avg_duration_seconds": 0.0,
91+
"pass_count": 0,
92+
"last_duration_seconds": 0.001,
93+
"avg_duration_seconds": 0.001,
9494
"latest_run": "2025-01-01T00:00:00+00:00",
95-
"commits_where_fail": []
95+
"commits_where_fail": [
96+
"cd76b0821854a780b60012aed85af0a8263004ad"
97+
]
9698
},
9799
{
98-
"test_id": "3ffa89c17705abeeff8728d3cd030c563ac1d40c67ae5e6e84c1bc66d4d6e012",
100+
"test_id": "d01ca01cb4b8dede6201a0ebadf9471dcc0e972b257417a79dc531665794afe0",
99101
"date": "2025-01-01",
100102
"repoid": 1,
101103
"branch": null,
102-
"fail_count": 1,
104+
"fail_count": 0,
103105
"flaky_fail_count": 0,
104106
"skip_count": 0,
105-
"pass_count": 0,
107+
"pass_count": 1,
106108
"last_duration_seconds": 0.001,
107109
"avg_duration_seconds": 0.001,
108110
"latest_run": "2025-01-01T00:00:00+00:00",
109-
"commits_where_fail": [
110-
"cd76b0821854a780b60012aed85af0a8263004ad"
111-
]
111+
"commits_where_fail": []
112112
},
113113
{
114-
"test_id": "6cbd65e47887eda0f4c0355b0a03e549284499e1acf80cb16bfd7797b546a3cb",
114+
"test_id": "d0abb665403924c55f02d0b79ed3be6b3ece9cdebf4c1c40b91a8a8d07319281",
115115
"date": "2025-01-01",
116116
"repoid": 1,
117117
"branch": null,
@@ -125,18 +125,18 @@
125125
"commits_where_fail": []
126126
},
127127
{
128-
"test_id": "80ee2bcfe6727cd875914bc1fa2995fd5feea6171803907dfd3383154f643038",
128+
"test_id": "d4259940b7b895581e9e8eeecf94803ea0148df4a7c48d7984d57bfb5e122209",
129129
"date": "2025-01-01",
130130
"repoid": 1,
131131
"branch": null,
132132
"fail_count": 0,
133133
"flaky_fail_count": 0,
134134
"skip_count": 0,
135135
"pass_count": 1,
136-
"last_duration_seconds": 0.001,
137-
"avg_duration_seconds": 0.001,
136+
"last_duration_seconds": 0.0,
137+
"avg_duration_seconds": 0.0,
138138
"latest_run": "2025-01-01T00:00:00+00:00",
139139
"commits_where_fail": []
140140
}
141141
]
142-
}
142+
}

0 commit comments

Comments
 (0)