@@ -84,6 +84,48 @@ def test_household_worker_exposes_post_snapshot_reset_hook(worker_app):
8484 assert hasattr (worker_cls , "reset_post_snapshot_state" )
8585
8686
87+ def test_worker_concurrency_options_set_max_inputs (worker_app ):
88+ """Each container processes up to 5 requests in parallel. Keeping this
89+ consistent across environments ensures staging behavior mirrors
90+ production so concurrency-related issues surface in staging tests."""
91+ assert worker_app .worker_concurrency_options ()["max_inputs" ] == 5
92+
93+
94+ def test_worker_concurrency_options_set_target_inputs (worker_app ):
95+ """`target_inputs=4` keeps the autoscaler aiming for 80% steady-state
96+ utilisation, so each container retains a free slot to absorb a
97+ single-request spike without waiting on a cold start."""
98+ assert worker_app .worker_concurrency_options ()["target_inputs" ] == 4
99+
100+
101+ def test_worker_function_options_do_not_use_deprecated_concurrency_kwarg (
102+ worker_app ,
103+ ):
104+ for environment in ("main" , "staging" , "testing" ):
105+ options = worker_app .worker_function_options (
106+ modal_environment = environment
107+ )
108+ assert "allow_concurrent_inputs" not in options , (
109+ "`allow_concurrent_inputs` is deprecated; use "
110+ f"`@modal.concurrent` for `{ environment } ` worker concurrency"
111+ )
112+
113+
114+ def test_worker_function_options_max_containers_capped_in_all_envs (
115+ worker_app ,
116+ ):
117+ """A hard ceiling on autoscale prevents runaway scaling from a buggy
118+ client or traffic spike from racking up unbounded cost."""
119+ for environment in ("main" , "staging" , "testing" ):
120+ options = worker_app .worker_function_options (
121+ modal_environment = environment
122+ )
123+ assert options ["max_containers" ] == 100 , (
124+ f"max_containers must be 100 in `{ environment } ` to bound "
125+ "autoscale cost"
126+ )
127+
128+
87129def test_country_package_install_specs_use_release_package_versions_only ():
88130 assert country_package_install_specs (
89131 {
0 commit comments