Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix CLUSTERS_KEEPER_TASK_INTERVAL env var #6812

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env-devel
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CLUSTERS_KEEPER_EC2_INSTANCES_PREFIX=""
CLUSTERS_KEEPER_LOGLEVEL=INFO
CLUSTERS_KEEPER_MAX_MISSED_HEARTBEATS_BEFORE_CLUSTER_TERMINATION=5
CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES=null
CLUSTERS_KEEPER_TASK_INTERVAL=30
CLUSTERS_KEEPER_TASK_INTERVAL=00:00:30
giancarloromeo marked this conversation as resolved.
Show resolved Hide resolved
CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES=null
CLUSTERS_KEEPER_TRACING={}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,7 @@ def LOG_LEVEL(self) -> LogLevel: # noqa: N802
def _valid_log_level(cls, value: str) -> str:
return cls.validate_log_level(value)

@field_validator(
"CLUSTERS_KEEPER_TASK_INTERVAL", "SERVICE_TRACKING_HEARTBEAT", mode="before"
)
@field_validator("SERVICE_TRACKING_HEARTBEAT", mode="before")
@classmethod
def _validate_interval(
cls, value: str | datetime.timedelta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict
from simcore_service_clusters_keeper.core.settings import ApplicationSettings

_FAST_POLL_INTERVAL = 1


@pytest.fixture
def app_environment(
app_environment: EnvVarsDict,
monkeypatch: pytest.MonkeyPatch,
) -> EnvVarsDict:
return app_environment | setenvs_from_dict(
monkeypatch, {"CLUSTERS_KEEPER_TASK_INTERVAL": f"{_FAST_POLL_INTERVAL}"}
monkeypatch, {"CLUSTERS_KEEPER_TASK_INTERVAL": "00:00:01"}
)


Expand All @@ -43,10 +41,7 @@ async def test_clusters_management_task_created_and_deleted(
initialized_app: FastAPI,
app_settings: ApplicationSettings,
):
assert (
app_settings.CLUSTERS_KEEPER_TASK_INTERVAL.total_seconds()
== _FAST_POLL_INTERVAL
)
assert app_settings.CLUSTERS_KEEPER_TASK_INTERVAL.total_seconds() == 1
assert hasattr(initialized_app.state, "clusters_cleaning_task")
await asyncio.sleep(5 * _FAST_POLL_INTERVAL)
await asyncio.sleep(5)
mock_background_task.assert_called()
Loading