11import time
2- from datetime import datetime
2+ from datetime import datetime , timedelta
33
44import pytest
55from django .db import connections
6- from shared .django_apps .timeseries .models import Testrun
6+ from shared .django_apps .ta_timeseries .models import Testrun
77from time_machine import travel
88
99from services .test_analytics .ta_timeseries import (
1818)
1919
2020
21- @pytest .mark .django_db (databases = ["timeseries " ])
21+ @pytest .mark .django_db (databases = ["ta_timeseries " ])
2222def 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 " ])
5959def 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 " ])
9494def 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 " ])
133133def 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 )
209209def 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 )
247248def 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 )
286288def 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 )
396398def test_get_testrun_branch_summary_via_testrun ():
397399 insert_testrun (
398400 timestamp = datetime .now (),
0 commit comments