@@ -15,7 +15,7 @@ module VCAP::CloudController
1515 let ( :dependency_locator ) { instance_spy ( CloudController ::DependencyLocator ) }
1616 let ( :prometheus_updater ) { spy ( VCAP ::CloudController ::Metrics ::PrometheusUpdater ) }
1717
18- subject do
18+ let ( :test_config ) do
1919 TestConfig . override (
2020 external_port : port ,
2121 nginx : {
@@ -27,7 +27,10 @@ module VCAP::CloudController
2727 max_threads : max_threads
2828 }
2929 )
30- PumaRunner . new ( TestConfig . config_instance , app , logger , periodic_updater , request_logs )
30+ end
31+
32+ subject do
33+ PumaRunner . new ( test_config , app , logger , periodic_updater , request_logs )
3134 end
3235
3336 before do
@@ -93,6 +96,52 @@ module VCAP::CloudController
9396 end
9497 end
9598
99+ context 'when setting "automatic_worker_count" to false' do
100+ let ( :test_config ) do
101+ TestConfig . override (
102+ puma : {
103+ workers : 1 ,
104+ automatic_worker_count : false
105+ }
106+ )
107+ end
108+
109+ before do
110+ allow ( ::Concurrent ) . to receive ( :available_processor_count ) . and_return 8
111+ end
112+
113+ it 'configures number of workers to the detected number of cores' do
114+ subject
115+
116+ expect ( puma_launcher . config . final_options [ :workers ] ) . to eq ( 1 )
117+ expect ( puma_launcher . config . final_options [ :min_threads ] ) . to eq ( 1 )
118+ expect ( puma_launcher . config . final_options [ :max_threads ] ) . to eq ( 1 )
119+ end
120+ end
121+
122+ context 'when setting "automatic_worker_count" to true' do
123+ let ( :test_config ) do
124+ TestConfig . override (
125+ puma : {
126+ workers : 1 ,
127+ automatic_worker_count : true
128+ }
129+ )
130+ end
131+
132+ before do
133+ allow ( ::Concurrent ) . to receive ( :available_processor_count ) . and_return 8
134+ end
135+
136+ it 'configures number of workers the specified number of workers' do
137+ subject
138+
139+ expect ( puma_launcher . config . final_options [ :workers ] ) . to eq ( 8 )
140+ expect ( puma_launcher . config . final_options [ :min_threads ] ) . to eq ( 1 )
141+ expect ( puma_launcher . config . final_options [ :max_threads ] ) . to eq ( 1 )
142+ end
143+ end
144+
96145 it 'configures the app as middleware' do
97146 subject
98147
0 commit comments