Skip to content

Commit a096340

Browse files
committed
Update test_worker.py
1 parent 4ab436d commit a096340

1 file changed

Lines changed: 0 additions & 48 deletions

File tree

tests/test_serverless/test_worker.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -459,54 +459,6 @@ def mock_is_alive():
459459
with patch("runpod.serverless.modules.rp_scale.JobScaler.is_alive", wraps=mock_is_alive):
460460
runpod.serverless.start(config)
461461

462-
@patch("runpod.serverless.modules.rp_scale.get_job")
463-
@patch("runpod.serverless.worker.run_job")
464-
@patch("runpod.serverless.worker.send_result")
465-
async def test_run_worker_multi_processing_availability_ratio(
466-
self, mock_send_result, mock_run_job, mock_get_job):
467-
'''
468-
Test run_worker with multi processing enabled, the scale-up and
469-
scale-down behavior with availability ratio.
470-
'''
471-
472-
# Let the test be a long running one so we can capture the scale-up and scale-down.
473-
config = {
474-
"handler": MagicMock(),
475-
"refresh_worker": False,
476-
"rp_args": {
477-
"rp_debugger": True,
478-
"rp_log_level": "DEBUG"
479-
}
480-
}
481-
482-
# Let's stop after the 20th call.
483-
scale_behavior = {
484-
'counter': 0
485-
}
486-
487-
def mock_is_alive():
488-
res = scale_behavior['counter'] <= 10
489-
scale_behavior['counter'] += 1
490-
491-
# Mock get_job to return a job every other call.
492-
if scale_behavior['counter'] % 2 == 0:
493-
mock_get_job.return_value = {
494-
"id": "123", "input": {"number": 1}}
495-
else:
496-
mock_get_job.return_value = None
497-
498-
return bool(mock_run_job.call_count < 5)
499-
500-
# Define the mock behaviors
501-
mock_run_job.return_value = {"result": "odd"}
502-
with patch("runpod.serverless.modules.rp_scale.JobScaler.is_alive", wraps=mock_is_alive):
503-
runpod.serverless.start(config)
504-
505-
assert mock_get_job.call_count == 5
506-
# 5 calls with actual jobs
507-
assert mock_run_job.call_count == 5
508-
assert mock_send_result.call_count == 5
509-
510462
# Test with sls-core
511463
async def test_run_worker_with_sls_core(self):
512464
'''

0 commit comments

Comments
 (0)