2020from pytest_simcore .helpers .monkeypatch_envs import delenvs_from_dict , setenvs_from_dict
2121from pytest_simcore .helpers .typing_env import EnvVarsDict
2222from servicelib .fastapi .celery .app_server import FastAPIAppServer
23- from settings_library . celery import CeleryPoolType
23+ from servicelib . tracing import TracingConfig
2424from settings_library .redis import RedisSettings
2525from simcore_service_api_server .clients import celery_task_manager
2626from simcore_service_api_server .core .application import create_app
@@ -108,23 +108,37 @@ def add_worker_tasks() -> bool:
108108
109109
110110@pytest .fixture
111- async def with_api_server_celery_worker (
111+ def app_server_factory_with_worker_mode (
112112 app_environment : EnvVarsDict ,
113- celery_app : Celery ,
114113 monkeypatch : pytest .MonkeyPatch ,
115- register_celery_tasks : Callable [[Celery ], None ],
116- add_worker_tasks : bool ,
117- ) -> AsyncIterator [TestWorkController ]:
118- # Signals must be explicitily connected
119- monkeypatch .setenv ("API_SERVER_WORKER_MODE" , "true" )
120- app_settings = ApplicationSettings .create_from_envs ()
114+ ) -> Callable [[], FastAPIAppServer ]:
115+ monkeypatch .setenv ("STORAGE_WORKER_MODE" , "true" )
121116
122117 def _app_server_factory () -> FastAPIAppServer :
123- return FastAPIAppServer (app = create_app (app_settings ))
118+ app_settings = ApplicationSettings .create_from_envs ()
119+
120+ assert app_settings .API_SERVER_WORKER_MODE is True
121+
122+ tracing_config = TracingConfig .create (
123+ tracing_settings = None ,
124+ service_name = "api-worker" ,
125+ )
126+ return FastAPIAppServer (app = create_app (app_settings , tracing_config ))
127+
128+ return _app_server_factory
124129
130+
131+ @pytest .fixture
132+ async def with_api_server_celery_worker (
133+ celery_app : Celery ,
134+ app_server_factory_with_worker_mode : Callable [[], FastAPIAppServer ],
135+ register_celery_tasks : Callable [[Celery ], None ],
136+ add_worker_tasks : bool ,
137+ ) -> AsyncIterator [TestWorkController ]:
125138 # NOTE: explicitly connect the signals in tests
126139 worker_init .connect (
127- _worker_init_wrapper (celery_app , _app_server_factory ), weak = False
140+ _worker_init_wrapper (celery_app , app_server_factory_with_worker_mode ),
141+ weak = False ,
128142 )
129143 worker_shutdown .connect (_worker_shutdown_wrapper (celery_app ), weak = False )
130144
@@ -134,7 +148,7 @@ def _app_server_factory() -> FastAPIAppServer:
134148
135149 with start_worker (
136150 celery_app ,
137- pool = CeleryPoolType . THREADS ,
151+ pool = "threads" ,
138152 concurrency = 1 ,
139153 loglevel = "info" ,
140154 perform_ping_check = False ,
0 commit comments