diff --git a/tests/unittests/test_dispatcher.py b/tests/unittests/test_dispatcher.py index d983de8f..eac056e1 100644 --- a/tests/unittests/test_dispatcher.py +++ b/tests/unittests/test_dispatcher.py @@ -103,6 +103,7 @@ async def test_dispatcher_environment_reload_logging(self): mode (Linux Consumption) """ async with self._ctrl as host: + await host.init_worker() await self._check_if_function_is_ok(host) # Reload environment variable on specialization @@ -155,6 +156,7 @@ async def test_dispatcher_sync_threadpool_invalid_worker_count(self): os.environ.update({PYTHON_THREADPOOL_THREAD_COUNT: 'invalid'}) async with self._ctrl as host: + await host.init_worker() await self._check_if_function_is_ok(host) await self._assert_workers_threadpool(self._ctrl, host, self._default_workers) @@ -169,6 +171,7 @@ async def test_dispatcher_sync_threadpool_below_min_setting(self): # Configure thread pool max worker to an invalid value os.environ.update({PYTHON_THREADPOOL_THREAD_COUNT: '0'}) async with self._ctrl as host: + await host.init_worker() await self._check_if_function_is_ok(host) await self._assert_workers_threadpool(self._ctrl, host, self._default_workers) @@ -187,6 +190,7 @@ async def test_dispatcher_sync_threadpool_exceed_max_setting(self): os.environ.update({PYTHON_THREADPOOL_THREAD_COUNT: f'{self._over_max_workers}'}) async with self._ctrl as host: + await host.init_worker('4.15.1') await self._check_if_function_is_ok(host) # Ensure the dispatcher sync threadpool should fallback to max @@ -198,6 +202,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder(self): mode (Linux Consumption) """ async with self._ctrl as host: + await host.init_worker() await self._check_if_function_is_ok(host) # Reload environment variable on specialization @@ -213,6 +218,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_invalid(self): """ with patch('azure_functions_worker.dispatcher.logger') as mock_logger: async with self._ctrl as host: + await host.init_worker() await self._check_if_function_is_ok(host) # Reload environment variable on specialization @@ -234,6 +240,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_above_max(self): """ with patch('azure_functions_worker.dispatcher.logger'): async with self._ctrl as host: + await host.init_worker() await self._check_if_function_is_ok(host) # Reload environment variable on specialization @@ -249,6 +256,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_below_min(self): """ with patch('azure_functions_worker.dispatcher.logger') as mock_logger: async with self._ctrl as host: + await host.init_worker() await self._check_if_function_is_ok(host) # Reload environment variable on specialization @@ -268,6 +276,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_below_min(self): async def test_sync_invocation_request_log(self): with patch('azure_functions_worker.dispatcher.logger') as mock_logger: async with self._ctrl as host: + await host.init_worker() request_id: str = self._ctrl._worker._request_id func_id, invoke_id, func_name = ( await self._check_if_function_is_ok(host) @@ -286,6 +295,7 @@ async def test_sync_invocation_request_log(self): async def test_async_invocation_request_log(self): with patch('azure_functions_worker.dispatcher.logger') as mock_logger: async with self._ctrl as host: + await host.init_worker() request_id: str = self._ctrl._worker._request_id func_id, invoke_id, func_name = ( await self._check_if_async_function_is_ok(host) @@ -543,6 +553,7 @@ async def test_dispatcher_functions_metadata_request(self): when a functions metadata request is received """ async with self._ctrl as host: + await host.init_worker() r = await host.get_functions_metadata() self.assertIsInstance(r.response, protos.FunctionMetadataResponse) self.assertFalse(r.response.use_default_metadata_indexing) @@ -554,6 +565,7 @@ async def test_dispatcher_functions_metadata_request_with_retry(self): when a functions metadata request is received """ async with self._ctrl as host: + await host.init_worker() r = await host.get_functions_metadata() self.assertIsInstance(r.response, protos.FunctionMetadataResponse) self.assertFalse(r.response.use_default_metadata_indexing) @@ -609,7 +621,7 @@ async def test_dispatcher_load_azfunc_in_init(self): """Test if azure functions is loaded during init """ async with self._ctrl as host: - r = await host.init_worker('4.15.1') + r = await host.init_worker() self.assertEqual( len([log for log in r.logs if log.message.startswith( 'Received WorkerInitRequest' @@ -625,7 +637,7 @@ async def test_dispatcher_load_modules_dedicated_app(self): # Dedicated Apps where placeholder mode is not set async with self._ctrl as host: - r = await host.init_worker('4.15.1') + r = await host.init_worker() logs = [log.message for log in r.logs] self.assertIn( "Applying prioritize_customer_dependencies: " @@ -643,7 +655,7 @@ async def test_dispatcher_load_modules_con_placeholder_enabled(self): os.environ["CONTAINER_NAME"] = "test" os.environ["WEBSITE_PLACEHOLDER_MODE"] = "1" async with self._ctrl as host: - r = await host.init_worker('4.15.1') + r = await host.init_worker() logs = [log.message for log in r.logs] self.assertNotIn( "Applying prioritize_customer_dependencies: " @@ -660,7 +672,7 @@ async def test_dispatcher_load_modules_con_app_placeholder_disabled(self): os.environ["WEBSITE_PLACEHOLDER_MODE"] = "0" os.environ["CONTAINER_NAME"] = "test" async with self._ctrl as host: - r = await host.init_worker('4.15.1') + r = await host.init_worker() logs = [log.message for log in r.logs] self.assertIn( "Applying prioritize_customer_dependencies: " diff --git a/tests/utils/testutils.py b/tests/utils/testutils.py index 6f6fb76a..57fd0a4e 100644 --- a/tests/utils/testutils.py +++ b/tests/utils/testutils.py @@ -514,7 +514,7 @@ def worker_id(self): def request_id(self): return self._request_id - async def init_worker(self, host_version: str): + async def init_worker(self, host_version: str = '4.28.0'): r = await self.communicate( protos.StreamingMessage( worker_init_request=protos.WorkerInitRequest(