diff --git a/.env-devel b/.env-devel index 17c9c11929c9..e4f191a0c1ec 100644 --- a/.env-devel +++ b/.env-devel @@ -141,6 +141,7 @@ FUNCTION_SERVICES_AUTHORS='{"UN": {"name": "Unknown", "email": "unknown@osparc.i WEBSERVER_LICENSES={} LICENSES_ITIS_VIP_SYNCER_ENABLED=false +LICENSES_ITIS_VIP_SYNCER_PERIODICITY=1D00:00:00 LICENSES_ITIS_VIP_API_URL=https://replace-with-itis-api/{category} LICENSES_ITIS_VIP_CATEGORIES='{"HumanWholeBody": "Humans", "HumanBodyRegion": "Humans (Region)", "AnimalWholeBody": "Animal"}' LICENSES_SPEAG_PHANTOMS_API_URL=https://replace-with-speag-api/{category} diff --git a/services/docker-compose.yml b/services/docker-compose.yml index 9447381aa638..d4dac05c550a 100644 --- a/services/docker-compose.yml +++ b/services/docker-compose.yml @@ -727,6 +727,7 @@ services: WEBSERVER_LICENSES: ${WEBSERVER_LICENSES} LICENSES_ITIS_VIP_SYNCER_ENABLED : ${LICENSES_ITIS_VIP_SYNCER_ENABLED} + LICENSES_ITIS_VIP_SYNCER_PERIODICITY: ${LICENSES_ITIS_VIP_SYNCER_PERIODICITY} LICENSES_ITIS_VIP_API_URL: ${LICENSES_ITIS_VIP_API_URL} LICENSES_ITIS_VIP_CATEGORIES: ${LICENSES_ITIS_VIP_CATEGORIES} LICENSES_SPEAG_PHANTOMS_API_URL: ${LICENSES_SPEAG_PHANTOMS_API_URL} diff --git a/services/web/server/src/simcore_service_webserver/licenses/_itis_vip_syncer_service.py b/services/web/server/src/simcore_service_webserver/licenses/_itis_vip_syncer_service.py index 36033b13069f..6bcd772cdf57 100644 --- a/services/web/server/src/simcore_service_webserver/licenses/_itis_vip_syncer_service.py +++ b/services/web/server/src/simcore_service_webserver/licenses/_itis_vip_syncer_service.py @@ -104,7 +104,7 @@ async def _lifespan(app_: web.Application): @exclusive_periodic( get_redis_lock_manager_client_sdk(app_), task_interval=resync_after, - retry_after=timedelta(minutes=2), + retry_after=timedelta(minutes=1), ) async def _periodic_sync() -> None: await sync_licensed_resources(app_, categories=categories) diff --git a/services/web/server/tests/unit/isolated/test_licenses_settings.py b/services/web/server/tests/unit/isolated/test_licenses_settings.py new file mode 100644 index 000000000000..6205f16c05f4 --- /dev/null +++ b/services/web/server/tests/unit/isolated/test_licenses_settings.py @@ -0,0 +1,32 @@ +# pylint: disable=protected-access +# pylint: disable=redefined-outer-name +# pylint: disable=too-many-arguments +# pylint: disable=unused-argument +# pylint: disable=unused-variable + + +import datetime + +import pytest +from pytest_simcore.helpers.typing_env import EnvVarsDict +from simcore_service_webserver.licenses.settings import LicensesSettings + + +def test_itis_vip_syncer_settings( + mock_webserver_service_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch +): + + assert "LICENSES_ITIS_VIP_SYNCER_ENABLED" in mock_webserver_service_environment + assert "LICENSES_ITIS_VIP_SYNCER_PERIODICITY" in mock_webserver_service_environment + + settings = LicensesSettings.create_from_envs() + assert settings + + with monkeypatch.context() as patch: + patch.setenv("LICENSES_ITIS_VIP_SYNCER_PERIODICITY", "1D02:03:04") + + settings: LicensesSettings = LicensesSettings.create_from_envs() + assert settings + assert settings.LICENSES_ITIS_VIP_SYNCER_PERIODICITY == datetime.timedelta( + days=1, hours=2, minutes=3, seconds=4 + )