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

Commit 669e96e

Browse files
deps: update shared (#1150)
1 parent 04e617b commit 669e96e

File tree

9 files changed

+43
-32
lines changed

9 files changed

+43
-32
lines changed

django_scaffold/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"shared.django_apps.labelanalysis",
3636
"shared.django_apps.reports",
3737
"shared.django_apps.staticanalysis",
38+
"shared.django_apps.ta_timeseries",
3839
]
3940

4041
TELEMETRY_VANILLA_DB = "default"

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ services:
3838
- POSTGRES_USER=postgres
3939
- POSTGRES_HOST_AUTH_METHOD=trust
4040
- POSTGRES_PASSWORD=password
41+
volumes:
42+
- ./docker/init_db.sql:/docker-entrypoint-initdb.d/init_db.sql
4143

4244
redis:
4345
image: redis:6-alpine

docker/init_db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE DATABASE test_analytics;

docker/test_codecov_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ setup:
55
encryption_secret: "zp^P9*i8aR3"
66
timeseries:
77
enabled: true
8+
ta_timeseries:
9+
enabled: true
810

911
services:
1012
database_url: postgres://postgres:password@postgres:5432/postgres

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ dev-dependencies = [
8383
[tool.uv.sources]
8484
timestring = { git = "https://github.com/codecov/timestring", rev = "d37ceacc5954dff3b5bd2f887936a98a668dda42" }
8585
test-results-parser = { git = "https://github.com/codecov/test-results-parser", rev = "190bbc8a911099749928e13d5fe57f6027ca1e74" }
86-
shared = { git = "https://github.com/codecov/shared", rev = "290557e977c4ff60d5d9dcb9ee54afea1c1df83f" }
86+
shared = { git = "https://github.com/codecov/shared", rev = "a93b0f1299841e56d8ceb591813974e97bec75b9" }

services/test_analytics/ta_timeseries.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import test_results_parser
88
from django.db import connections
99
from django.db.models import Q
10-
from shared.django_apps.test_analytics.models import Flake
11-
from shared.django_apps.timeseries.models import (
10+
from shared.django_apps.ta_timeseries.models import (
1211
Testrun,
1312
TestrunBranchSummary,
1413
TestrunSummary,
1514
)
15+
from shared.django_apps.test_analytics.models import Flake
1616

1717
from services.test_analytics.utils import calc_test_id
1818
from services.test_results import FlakeInfo
@@ -90,7 +90,7 @@ class TestInstance(TypedDict):
9090

9191

9292
def get_pr_comment_failures(repo_id: int, commit_sha: str) -> list[TestInstance]:
93-
with connections["timeseries"].cursor() as cursor:
93+
with connections["ta_timeseries"].cursor() as cursor:
9494
cursor.execute(
9595
"""
9696
SELECT
@@ -99,7 +99,7 @@ def get_pr_comment_failures(repo_id: int, commit_sha: str) -> list[TestInstance]
9999
LAST(failure_message, timestamp) as failure_message,
100100
LAST(upload_id, timestamp) as upload_id,
101101
LAST(duration_seconds, timestamp) as duration_seconds
102-
FROM timeseries_testrun
102+
FROM ta_timeseries_testrun
103103
WHERE repo_id = %s AND commit_sha = %s AND outcome IN ('failure', 'flaky_failure')
104104
GROUP BY test_id
105105
""",
@@ -124,14 +124,14 @@ class PRCommentAgg(TypedDict):
124124

125125

126126
def get_pr_comment_agg(repo_id: int, commit_sha: str) -> PRCommentAgg:
127-
with connections["timeseries"].cursor() as cursor:
127+
with connections["ta_timeseries"].cursor() as cursor:
128128
cursor.execute(
129129
"""
130130
SELECT outcome, count(*) FROM (
131131
SELECT
132132
test_id,
133133
LAST(outcome, timestamp) as outcome
134-
FROM timeseries_testrun
134+
FROM ta_timeseries_testrun
135135
WHERE repo_id = %s AND commit_sha = %s
136136
GROUP BY test_id
137137
) AS t
@@ -166,9 +166,9 @@ def get_testruns_for_flake_detection(
166166

167167

168168
def update_testrun_to_flaky(timestamp: datetime, test_id: bytes):
169-
with connections["timeseries"].cursor() as cursor:
169+
with connections["ta_timeseries"].cursor() as cursor:
170170
cursor.execute(
171-
"UPDATE timeseries_testrun SET outcome = %s WHERE timestamp = %s AND test_id = %s",
171+
"UPDATE ta_timeseries_testrun SET outcome = %s WHERE timestamp = %s AND test_id = %s",
172172
["flaky_failure", timestamp, test_id],
173173
)
174174

@@ -214,7 +214,7 @@ class BranchSummary:
214214
def get_testrun_branch_summary_via_testrun(
215215
repo_id: int, branch: str
216216
) -> list[BranchSummary]:
217-
with connections["timeseries"].cursor() as cursor:
217+
with connections["ta_timeseries"].cursor() as cursor:
218218
cursor.execute(
219219
"""
220220
select
@@ -233,7 +233,7 @@ def get_testrun_branch_summary_via_testrun(
233233
COUNT(*) FILTER (WHERE outcome = 'flaky_failure') AS flaky_fail_count,
234234
MAX(timestamp) AS updated_at,
235235
array_merge_dedup_agg(flags) as flags
236-
from timeseries_testrun
236+
from ta_timeseries_testrun
237237
where repo_id = %s and branch = %s and timestamp > %s
238238
group by
239239
testsuite, classname, name, timestamp_bin;

services/test_analytics/tests/test_ta_timeseries.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import time
2-
from datetime import datetime
2+
from datetime import datetime, timedelta
33

44
import pytest
55
from django.db import connections
6-
from shared.django_apps.timeseries.models import Testrun
6+
from shared.django_apps.ta_timeseries.models import Testrun
77
from time_machine import travel
88

99
from services.test_analytics.ta_timeseries import (
@@ -18,7 +18,7 @@
1818
)
1919

2020

21-
@pytest.mark.django_db(databases=["timeseries"])
21+
@pytest.mark.django_db(databases=["ta_timeseries"])
2222
def test_insert_testrun():
2323
insert_testrun(
2424
timestamp=datetime.now(),
@@ -55,7 +55,7 @@ def test_insert_testrun():
5555
assert t.outcome == "pass"
5656

5757

58-
@pytest.mark.django_db(databases=["timeseries"])
58+
@pytest.mark.django_db(databases=["ta_timeseries"])
5959
def test_pr_comment_agg():
6060
insert_testrun(
6161
timestamp=datetime.now(),
@@ -90,7 +90,7 @@ def test_pr_comment_agg():
9090
}
9191

9292

93-
@pytest.mark.django_db(databases=["timeseries"])
93+
@pytest.mark.django_db(databases=["ta_timeseries"])
9494
def test_pr_comment_failures():
9595
insert_testrun(
9696
timestamp=datetime.now(),
@@ -129,7 +129,7 @@ def test_pr_comment_failures():
129129
assert failure["upload_id"] == 1
130130

131131

132-
@pytest.mark.django_db(databases=["timeseries"])
132+
@pytest.mark.django_db(databases=["ta_timeseries"])
133133
def test_get_testruns_for_flake_detection(db):
134134
test_ids = {calc_test_id("flaky_test_name", "test_classname", "test_suite")}
135135
insert_testrun(
@@ -204,7 +204,7 @@ def test_get_testruns_for_flake_detection(db):
204204
assert testruns[2].name == "flaky_test_name"
205205

206206

207-
@pytest.mark.django_db(databases=["timeseries"])
207+
@pytest.mark.django_db(databases=["ta_timeseries"])
208208
@travel(datetime(2025, 1, 1), tick=False)
209209
def test_update_testrun_to_flaky():
210210
insert_testrun(
@@ -244,20 +244,22 @@ def test_update_testrun_to_flaky():
244244

245245

246246
@pytest.fixture
247+
@pytest.mark.django_db(databases=["ta_timeseries"], transaction=True)
247248
def continuous_aggregate_policy():
248-
connection = connections["timeseries"]
249+
connection = connections["ta_timeseries"]
249250
with connection.cursor() as cursor:
250251
cursor.execute(
251252
"""
252-
TRUNCATE TABLE timeseries_testrun;
253-
TRUNCATE TABLE timeseries_testrun_summary_1day;
253+
TRUNCATE TABLE ta_timeseries_testrun;
254+
TRUNCATE TABLE ta_timeseries_testrun_summary_1day;
254255
"""
255256
)
256257
cursor.execute(
257258
"""
258-
SELECT remove_continuous_aggregate_policy('timeseries_testrun_summary_1day');
259+
SELECT _timescaledb_internal.start_background_workers();
260+
SELECT remove_continuous_aggregate_policy('ta_timeseries_testrun_summary_1day');
259261
SELECT add_continuous_aggregate_policy(
260-
'timeseries_testrun_summary_1day',
262+
'ta_timeseries_testrun_summary_1day',
261263
start_offset => '7 days',
262264
end_offset => NULL,
263265
schedule_interval => INTERVAL '10 milliseconds'
@@ -270,9 +272,9 @@ def continuous_aggregate_policy():
270272
with connection.cursor() as cursor:
271273
cursor.execute(
272274
"""
273-
SELECT remove_continuous_aggregate_policy('timeseries_testrun_summary_1day');
275+
SELECT remove_continuous_aggregate_policy('ta_timeseries_testrun_summary_1day');
274276
SELECT add_continuous_aggregate_policy(
275-
'timeseries_testrun_summary_1day',
277+
'ta_timeseries_testrun_summary_1day',
276278
start_offset => '7 days',
277279
end_offset => '1 days',
278280
schedule_interval => INTERVAL '1 days'
@@ -282,10 +284,10 @@ def continuous_aggregate_policy():
282284

283285

284286
@pytest.mark.integration
285-
@pytest.mark.django_db(databases=["timeseries"], transaction=True)
287+
@pytest.mark.django_db(databases=["ta_timeseries"], transaction=True)
286288
def test_get_testrun_summary(continuous_aggregate_policy):
287289
insert_testrun(
288-
timestamp=datetime.now(),
290+
timestamp=datetime.now() - timedelta(days=2),
289291
repo_id=1,
290292
commit_sha="commit_sha",
291293
branch="branch",
@@ -309,7 +311,7 @@ def test_get_testrun_summary(continuous_aggregate_policy):
309311
},
310312
)
311313
insert_testrun(
312-
timestamp=datetime.now(),
314+
timestamp=datetime.now() - timedelta(days=2),
313315
repo_id=1,
314316
commit_sha="commit_sha",
315317
branch="branch",
@@ -334,7 +336,7 @@ def test_get_testrun_summary(continuous_aggregate_policy):
334336
)
335337

336338
insert_testrun(
337-
timestamp=datetime.now(),
339+
timestamp=datetime.now() - timedelta(days=2),
338340
repo_id=1,
339341
commit_sha="commit_sha",
340342
branch="branch",
@@ -392,7 +394,7 @@ def test_get_testrun_summary(continuous_aggregate_policy):
392394

393395

394396
@pytest.mark.integration
395-
@pytest.mark.django_db(databases=["timeseries"], transaction=True)
397+
@pytest.mark.django_db(databases=["ta_timeseries"], transaction=True)
396398
def test_get_testrun_branch_summary_via_testrun():
397399
insert_testrun(
398400
timestamp=datetime.now(),

uv.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

worker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fi
1313
if [ "$RUN_ENV" = "ENTERPRISE" ] || [ "$RUN_ENV" = "DEV" ]; then
1414
python manage.py migrate
1515
python manage.py migrate --database "timeseries"
16+
python manage.py migrate --database "ta_timeseries"
1617
fi
1718

1819
if [ -z "$1" ];

0 commit comments

Comments
 (0)