11from collections .abc import Callable , Iterator
2- from datetime import datetime , timedelta , timezone
2+ from datetime import UTC , datetime , timedelta
33
44import pytest
55import sqlalchemy as sa
2121)
2222from simcore_service_resource_usage_tracker .models .service_runs import ServiceRunDB
2323from simcore_service_resource_usage_tracker .services .background_task_periodic_heartbeat_check import (
24- periodic_check_of_running_services_task ,
24+ check_running_services ,
2525)
2626
2727pytest_simcore_core_services_selection = ["postgres" , "rabbit" ]
3333_SERVICE_RUN_ID_S4L_10_MIN_OLD = "2"
3434_SERVICE_RUN_ID_OSPARC_NOW = "3"
3535
36- _LAST_HEARTBEAT_10_MIN_OLD = datetime .now (tz = timezone . utc ) - timedelta (minutes = 10 )
37- _LAST_HEARTBEAT_NOW = datetime .now (tz = timezone . utc )
36+ _LAST_HEARTBEAT_10_MIN_OLD = datetime .now (tz = UTC ) - timedelta (minutes = 10 )
37+ _LAST_HEARTBEAT_NOW = datetime .now (tz = UTC )
3838
3939
4040@pytest .fixture ()
@@ -131,11 +131,11 @@ async def test_process_event_functions(
131131 app_settings : ApplicationSettings = initialized_app .state .settings
132132
133133 for _ in range (app_settings .RESOURCE_USAGE_TRACKER_MISSED_HEARTBEAT_COUNTER_FAIL ):
134- await periodic_check_of_running_services_task (initialized_app )
134+ await check_running_services (initialized_app )
135135 # NOTE: As we are doing check that the modified field needs to be older then some
136136 # threshold, we need to make this field artificaly older in this test
137137 with postgres_db .connect () as con :
138- fake_old_modified_at = datetime .now (tz = timezone . utc ) - timedelta (minutes = 5 )
138+ fake_old_modified_at = datetime .now (tz = UTC ) - timedelta (minutes = 5 )
139139 update_stmt = resource_tracker_service_runs .update ().values (
140140 modified = fake_old_modified_at
141141 )
@@ -160,7 +160,7 @@ async def test_process_event_functions(
160160 assert service_run .service_run_status == ServiceRunStatus .RUNNING
161161
162162 # Now we call the function one more time and it should consider some of running services as unhealthy
163- await periodic_check_of_running_services_task (initialized_app )
163+ await check_running_services (initialized_app )
164164
165165 with postgres_db .connect () as con :
166166 result = con .execute (sa .select (resource_tracker_service_runs ))
0 commit comments