Skip to content

Commit 5fec053

Browse files
committed
Merge remote-tracking branch 'origin/vameru/implicit-output-binding-return' into vameru/implicit-output-binding-return
2 parents d4b1834 + 517782c commit 5fec053

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

tests/unittests/test_dispatcher.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ async def test_dispatcher_environment_reload_logging(self):
103103
mode (Linux Consumption)
104104
"""
105105
async with self._ctrl as host:
106+
await host.init_worker()
106107
await self._check_if_function_is_ok(host)
107108

108109
# Reload environment variable on specialization
@@ -155,6 +156,7 @@ async def test_dispatcher_sync_threadpool_invalid_worker_count(self):
155156
os.environ.update({PYTHON_THREADPOOL_THREAD_COUNT: 'invalid'})
156157

157158
async with self._ctrl as host:
159+
await host.init_worker()
158160
await self._check_if_function_is_ok(host)
159161
await self._assert_workers_threadpool(self._ctrl, host,
160162
self._default_workers)
@@ -169,6 +171,7 @@ async def test_dispatcher_sync_threadpool_below_min_setting(self):
169171
# Configure thread pool max worker to an invalid value
170172
os.environ.update({PYTHON_THREADPOOL_THREAD_COUNT: '0'})
171173
async with self._ctrl as host:
174+
await host.init_worker()
172175
await self._check_if_function_is_ok(host)
173176
await self._assert_workers_threadpool(self._ctrl, host,
174177
self._default_workers)
@@ -187,6 +190,7 @@ async def test_dispatcher_sync_threadpool_exceed_max_setting(self):
187190
os.environ.update({PYTHON_THREADPOOL_THREAD_COUNT:
188191
f'{self._over_max_workers}'})
189192
async with self._ctrl as host:
193+
await host.init_worker('4.15.1')
190194
await self._check_if_function_is_ok(host)
191195

192196
# Ensure the dispatcher sync threadpool should fallback to max
@@ -198,6 +202,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder(self):
198202
mode (Linux Consumption)
199203
"""
200204
async with self._ctrl as host:
205+
await host.init_worker()
201206
await self._check_if_function_is_ok(host)
202207

203208
# Reload environment variable on specialization
@@ -213,6 +218,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_invalid(self):
213218
"""
214219
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
215220
async with self._ctrl as host:
221+
await host.init_worker()
216222
await self._check_if_function_is_ok(host)
217223

218224
# Reload environment variable on specialization
@@ -234,6 +240,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_above_max(self):
234240
"""
235241
with patch('azure_functions_worker.dispatcher.logger'):
236242
async with self._ctrl as host:
243+
await host.init_worker()
237244
await self._check_if_function_is_ok(host)
238245

239246
# Reload environment variable on specialization
@@ -249,6 +256,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_below_min(self):
249256
"""
250257
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
251258
async with self._ctrl as host:
259+
await host.init_worker()
252260
await self._check_if_function_is_ok(host)
253261

254262
# Reload environment variable on specialization
@@ -268,6 +276,7 @@ async def test_dispatcher_sync_threadpool_in_placeholder_below_min(self):
268276
async def test_sync_invocation_request_log(self):
269277
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
270278
async with self._ctrl as host:
279+
await host.init_worker()
271280
request_id: str = self._ctrl._worker._request_id
272281
func_id, invoke_id, func_name = (
273282
await self._check_if_function_is_ok(host)
@@ -286,6 +295,7 @@ async def test_sync_invocation_request_log(self):
286295
async def test_async_invocation_request_log(self):
287296
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
288297
async with self._ctrl as host:
298+
await host.init_worker()
289299
request_id: str = self._ctrl._worker._request_id
290300
func_id, invoke_id, func_name = (
291301
await self._check_if_async_function_is_ok(host)
@@ -543,6 +553,7 @@ async def test_dispatcher_functions_metadata_request(self):
543553
when a functions metadata request is received
544554
"""
545555
async with self._ctrl as host:
556+
await host.init_worker()
546557
r = await host.get_functions_metadata()
547558
self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
548559
self.assertFalse(r.response.use_default_metadata_indexing)
@@ -554,6 +565,7 @@ async def test_dispatcher_functions_metadata_request_with_retry(self):
554565
when a functions metadata request is received
555566
"""
556567
async with self._ctrl as host:
568+
await host.init_worker()
557569
r = await host.get_functions_metadata()
558570
self.assertIsInstance(r.response, protos.FunctionMetadataResponse)
559571
self.assertFalse(r.response.use_default_metadata_indexing)
@@ -609,7 +621,7 @@ async def test_dispatcher_load_azfunc_in_init(self):
609621
"""Test if azure functions is loaded during init
610622
"""
611623
async with self._ctrl as host:
612-
r = await host.init_worker('4.15.1')
624+
r = await host.init_worker()
613625
self.assertEqual(
614626
len([log for log in r.logs if log.message.startswith(
615627
'Received WorkerInitRequest'
@@ -625,7 +637,7 @@ async def test_dispatcher_load_modules_dedicated_app(self):
625637

626638
# Dedicated Apps where placeholder mode is not set
627639
async with self._ctrl as host:
628-
r = await host.init_worker('4.15.1')
640+
r = await host.init_worker()
629641
logs = [log.message for log in r.logs]
630642
self.assertIn(
631643
"Applying prioritize_customer_dependencies: "
@@ -643,7 +655,7 @@ async def test_dispatcher_load_modules_con_placeholder_enabled(self):
643655
os.environ["CONTAINER_NAME"] = "test"
644656
os.environ["WEBSITE_PLACEHOLDER_MODE"] = "1"
645657
async with self._ctrl as host:
646-
r = await host.init_worker('4.15.1')
658+
r = await host.init_worker()
647659
logs = [log.message for log in r.logs]
648660
self.assertNotIn(
649661
"Applying prioritize_customer_dependencies: "
@@ -660,7 +672,7 @@ async def test_dispatcher_load_modules_con_app_placeholder_disabled(self):
660672
os.environ["WEBSITE_PLACEHOLDER_MODE"] = "0"
661673
os.environ["CONTAINER_NAME"] = "test"
662674
async with self._ctrl as host:
663-
r = await host.init_worker('4.15.1')
675+
r = await host.init_worker()
664676
logs = [log.message for log in r.logs]
665677
self.assertIn(
666678
"Applying prioritize_customer_dependencies: "

tests/utils/testutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def worker_id(self):
514514
def request_id(self):
515515
return self._request_id
516516

517-
async def init_worker(self, host_version: str):
517+
async def init_worker(self, host_version: str = '4.28.0'):
518518
r = await self.communicate(
519519
protos.StreamingMessage(
520520
worker_init_request=protos.WorkerInitRequest(

0 commit comments

Comments
 (0)