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

Commit 0698784

Browse files
committed
enable new TA tasks on new repos
1 parent 7a25b06 commit 0698784

4 files changed

Lines changed: 364 additions & 1 deletion

File tree

services/test_analytics/ta_metrics.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from shared.metrics import Summary
1+
from shared.metrics import Counter, Summary
22

33
write_tests_summary = Summary(
44
"write_tests_summary",
@@ -37,3 +37,9 @@
3737
"The time it takes to process flakes",
3838
["impl"],
3939
)
40+
41+
42+
new_ta_tasks_repo_summary = Counter(
43+
"new_ta_tasks_repo_summary",
44+
"Number of repos that were processed using 'new' ta tasks, due to being created after 2025-04-25",
45+
)
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
interactions:
2+
- request:
3+
body: ''
4+
headers:
5+
accept:
6+
- application/json
7+
accept-encoding:
8+
- gzip, deflate, zstd
9+
connection:
10+
- keep-alive
11+
host:
12+
- api.github.com
13+
user-agent:
14+
- Default
15+
method: GET
16+
uri: https://api.github.com/repos/ThiagoCodecov/example-python/contents?ref=abf6d4df662c47e32460020ab14abf9303581429
17+
response:
18+
body:
19+
string: '{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}'
20+
headers:
21+
Access-Control-Allow-Origin:
22+
- '*'
23+
Access-Control-Expose-Headers:
24+
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
25+
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes,
26+
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO,
27+
X-GitHub-Request-Id, Deprecation, Sunset
28+
Content-Length:
29+
- '95'
30+
Content-Security-Policy:
31+
- default-src 'none'
32+
Content-Type:
33+
- application/json; charset=utf-8
34+
Date:
35+
- Tue, 22 Apr 2025 20:46:29 GMT
36+
Referrer-Policy:
37+
- origin-when-cross-origin, strict-origin-when-cross-origin
38+
Server:
39+
- github.com
40+
Strict-Transport-Security:
41+
- max-age=31536000; includeSubdomains; preload
42+
Vary:
43+
- Accept-Encoding, Accept, X-Requested-With
44+
X-Content-Type-Options:
45+
- nosniff
46+
X-Frame-Options:
47+
- deny
48+
X-GitHub-Media-Type:
49+
- github.v3
50+
X-GitHub-Request-Id:
51+
- 6CED:3692BE:371DFE8:6DB056D:68080025
52+
X-RateLimit-Limit:
53+
- '60'
54+
X-RateLimit-Remaining:
55+
- '59'
56+
X-RateLimit-Reset:
57+
- '1745358389'
58+
X-RateLimit-Resource:
59+
- core
60+
X-RateLimit-Used:
61+
- '1'
62+
X-XSS-Protection:
63+
- '0'
64+
status:
65+
code: 401
66+
message: Unauthorized
67+
- request:
68+
body: ''
69+
headers:
70+
accept:
71+
- application/json
72+
accept-encoding:
73+
- gzip, deflate, zstd
74+
connection:
75+
- keep-alive
76+
host:
77+
- api.github.com
78+
user-agent:
79+
- Default
80+
method: GET
81+
uri: https://api.github.com/repos/ThiagoCodecov/example-python/commits/abf6d4df662c47e32460020ab14abf9303581429
82+
response:
83+
body:
84+
string: '{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}'
85+
headers:
86+
Access-Control-Allow-Origin:
87+
- '*'
88+
Access-Control-Expose-Headers:
89+
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
90+
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes,
91+
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO,
92+
X-GitHub-Request-Id, Deprecation, Sunset
93+
Content-Length:
94+
- '95'
95+
Content-Security-Policy:
96+
- default-src 'none'
97+
Content-Type:
98+
- application/json; charset=utf-8
99+
Date:
100+
- Tue, 22 Apr 2025 20:46:29 GMT
101+
Referrer-Policy:
102+
- origin-when-cross-origin, strict-origin-when-cross-origin
103+
Server:
104+
- github.com
105+
Strict-Transport-Security:
106+
- max-age=31536000; includeSubdomains; preload
107+
Vary:
108+
- Accept-Encoding, Accept, X-Requested-With
109+
X-Content-Type-Options:
110+
- nosniff
111+
X-Frame-Options:
112+
- deny
113+
X-GitHub-Media-Type:
114+
- github.v3
115+
X-GitHub-Request-Id:
116+
- D17F:29F048:35D3BF4:6B2DD7B:68080025
117+
X-RateLimit-Limit:
118+
- '60'
119+
X-RateLimit-Remaining:
120+
- '58'
121+
X-RateLimit-Reset:
122+
- '1745358389'
123+
X-RateLimit-Resource:
124+
- core
125+
X-RateLimit-Used:
126+
- '2'
127+
X-XSS-Protection:
128+
- '0'
129+
status:
130+
code: 401
131+
message: Unauthorized
132+
- request:
133+
body: ''
134+
headers:
135+
accept:
136+
- application/json
137+
accept-encoding:
138+
- gzip, deflate, zstd
139+
connection:
140+
- keep-alive
141+
host:
142+
- api.github.com
143+
user-agent:
144+
- Default
145+
method: GET
146+
uri: https://api.github.com/repos/ThiagoCodecov/example-python/commits/abf6d4df662c47e32460020ab14abf9303581429
147+
response:
148+
body:
149+
string: '{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}'
150+
headers:
151+
Access-Control-Allow-Origin:
152+
- '*'
153+
Access-Control-Expose-Headers:
154+
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
155+
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes,
156+
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO,
157+
X-GitHub-Request-Id, Deprecation, Sunset
158+
Content-Length:
159+
- '95'
160+
Content-Security-Policy:
161+
- default-src 'none'
162+
Content-Type:
163+
- application/json; charset=utf-8
164+
Date:
165+
- Tue, 22 Apr 2025 20:46:29 GMT
166+
Referrer-Policy:
167+
- origin-when-cross-origin, strict-origin-when-cross-origin
168+
Server:
169+
- github.com
170+
Strict-Transport-Security:
171+
- max-age=31536000; includeSubdomains; preload
172+
Vary:
173+
- Accept-Encoding, Accept, X-Requested-With
174+
X-Content-Type-Options:
175+
- nosniff
176+
X-Frame-Options:
177+
- deny
178+
X-GitHub-Media-Type:
179+
- github.v3
180+
X-GitHub-Request-Id:
181+
- D17F:29F048:35D3C1A:6B2DDD3:68080025
182+
X-RateLimit-Limit:
183+
- '60'
184+
X-RateLimit-Remaining:
185+
- '57'
186+
X-RateLimit-Reset:
187+
- '1745358389'
188+
X-RateLimit-Resource:
189+
- core
190+
X-RateLimit-Used:
191+
- '3'
192+
X-XSS-Protection:
193+
- '0'
194+
status:
195+
code: 401
196+
message: Unauthorized
197+
- request:
198+
body: ''
199+
headers:
200+
accept:
201+
- application/json
202+
accept-encoding:
203+
- gzip, deflate, zstd
204+
connection:
205+
- keep-alive
206+
host:
207+
- api.github.com
208+
user-agent:
209+
- Default
210+
method: GET
211+
uri: https://api.github.com/repos/ThiagoCodecov/example-python/commits/abf6d4df662c47e32460020ab14abf9303581429
212+
response:
213+
body:
214+
string: '{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}'
215+
headers:
216+
Access-Control-Allow-Origin:
217+
- '*'
218+
Access-Control-Expose-Headers:
219+
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
220+
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes,
221+
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO,
222+
X-GitHub-Request-Id, Deprecation, Sunset
223+
Content-Length:
224+
- '95'
225+
Content-Security-Policy:
226+
- default-src 'none'
227+
Content-Type:
228+
- application/json; charset=utf-8
229+
Date:
230+
- Tue, 22 Apr 2025 20:46:29 GMT
231+
Referrer-Policy:
232+
- origin-when-cross-origin, strict-origin-when-cross-origin
233+
Server:
234+
- github.com
235+
Strict-Transport-Security:
236+
- max-age=31536000; includeSubdomains; preload
237+
Vary:
238+
- Accept-Encoding, Accept, X-Requested-With
239+
X-Content-Type-Options:
240+
- nosniff
241+
X-Frame-Options:
242+
- deny
243+
X-GitHub-Media-Type:
244+
- github.v3
245+
X-GitHub-Request-Id:
246+
- D17F:29F048:35D3C3F:6B2DE17:68080025
247+
X-RateLimit-Limit:
248+
- '60'
249+
X-RateLimit-Remaining:
250+
- '56'
251+
X-RateLimit-Reset:
252+
- '1745358389'
253+
X-RateLimit-Resource:
254+
- core
255+
X-RateLimit-Used:
256+
- '4'
257+
X-XSS-Protection:
258+
- '0'
259+
status:
260+
code: 401
261+
message: Unauthorized
262+
version: 1

tasks/tests/unit/test_upload_task.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,83 @@ def test_upload_task_call_test_results(
438438
notify_sig = test_results_finisher_task.signature(kwargs=kwargs)
439439
chain.assert_called_with(*[processor_sig, notify_sig])
440440

441+
@pytest.mark.django_db(databases={"default"}, transaction=True)
442+
def test_upload_task_call_test_results_new_repo(
443+
self,
444+
mocker,
445+
mock_configuration,
446+
dbsession,
447+
codecov_vcr,
448+
mock_storage,
449+
mock_redis,
450+
celery_app,
451+
):
452+
chain = mocker.patch("tasks.upload.chain")
453+
storage_path = "v4/raw/2019-05-22/C3C4715CA57C910D11D5EB899FC86A7E/4c4e4654ac25037ae869caeb3619d485970b6304/a84d445c-9c1e-434f-8275-f18f1f320f81.txt"
454+
redis_queue = [{"url": storage_path, "build_code": "some_random_build"}]
455+
jsonified_redis_queue = [json.dumps(x) for x in redis_queue]
456+
mocker.patch.object(UploadTask, "app", celery_app)
457+
458+
commit = CommitFactory.create(
459+
message="",
460+
commitid="abf6d4df662c47e32460020ab14abf9303581429",
461+
repository__owner__oauth_token="GHTZB+Mi+kbl/ubudnSKTJYb/fgN4hRJVJYSIErtidEsCLDJBb8DZzkbXqLujHAnv28aKShXddE/OffwRuwKug==",
462+
repository__owner__username="ThiagoCodecov",
463+
repository__owner__service="github",
464+
repository__yaml={"codecov": {"max_report_age": "1y ago"}},
465+
repository__name="example-python",
466+
pullid=1,
467+
# Setting the time to _before_ patch centric default YAMLs start date of 2024-04-30
468+
repository__owner__createstamp=datetime(2023, 1, 1, tzinfo=timezone.utc),
469+
)
470+
dbsession.add(commit)
471+
dbsession.flush()
472+
dbsession.refresh(commit)
473+
474+
mock_redis.lists[f"uploads/{commit.repoid}/{commit.commitid}/test_results"] = (
475+
jsonified_redis_queue
476+
)
477+
478+
UploadTask().run_impl(
479+
dbsession,
480+
commit.repoid,
481+
commit.commitid,
482+
report_type="test_results",
483+
)
484+
commit_report = commit.commit_report(report_type=ReportType.TEST_RESULTS)
485+
assert commit_report
486+
uploads = commit_report.uploads
487+
assert len(uploads) == 1
488+
upload = dbsession.query(Upload).filter_by(report_id=commit_report.id).first()
489+
processor_sig = test_results_processor_task.s(
490+
False,
491+
repoid=commit.repoid,
492+
commitid=commit.commitid,
493+
commit_yaml={"codecov": {"max_report_age": "1y ago"}},
494+
arguments_list=[
495+
{
496+
"url": storage_path,
497+
"flags": [],
498+
"build_code": "some_random_build",
499+
"upload_id": upload.id,
500+
"upload_pk": upload.id,
501+
}
502+
],
503+
report_code=None,
504+
impl_type="old",
505+
)
506+
kwargs = dict(
507+
repoid=commit.repoid,
508+
commitid=commit.commitid,
509+
commit_yaml={"codecov": {"max_report_age": "1y ago"}},
510+
checkpoints_TestResultsFlow=None,
511+
impl_type="old",
512+
)
513+
514+
kwargs[_kwargs_key(TestResultsFlow)] = mocker.ANY
515+
notify_sig = test_results_finisher_task.signature(kwargs=kwargs)
516+
chain.assert_called_with(*[processor_sig, notify_sig])
517+
441518
@pytest.mark.django_db(databases={"default"}, transaction=True)
442519
def test_upload_task_call_new_ta_tasks(
443520
self,

0 commit comments

Comments
 (0)