This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,11 @@ def maximum_duration_seconds
2222 end
2323
2424 def maximum_duration_seconds = ( duration )
25- @maximum_duration = duration if duration < default_maximum_duration_seconds
25+ @maximum_duration = if duration . present? && duration < default_maximum_duration_seconds
26+ duration
27+ else
28+ default_maximum_duration_seconds
29+ end
2630 end
2731
2832 def polling_interval_seconds
Original file line number Diff line number Diff line change @@ -25,10 +25,10 @@ def perform
2525 raise_if_cannot_proceed!
2626
2727 client = VCAP ::Services ::ServiceClientProvider . provide ( { instance : service_instance } )
28+ compute_maximum_duration
2829
2930 begin
3031 if @first_time
31- compute_maximum_duration
3232 execute_request ( client )
3333 compatibility_checks
3434 @first_time = false
@@ -139,7 +139,7 @@ def fetch_last_operation(client)
139139
140140 def compute_maximum_duration
141141 max_poll_duration_on_plan = service_instance . service_plan . try ( :maximum_polling_duration )
142- self . maximum_duration_seconds = max_poll_duration_on_plan if max_poll_duration_on_plan
142+ self . maximum_duration_seconds = max_poll_duration_on_plan
143143 end
144144
145145 def service_instance
Original file line number Diff line number Diff line change @@ -238,6 +238,27 @@ def send_broker_request(_) end
238238 job . perform
239239 end
240240
241+ context 'the maximum duration' do
242+ it 'recomputes the value' do
243+ job . maximum_duration_seconds = 90009
244+ TestConfig . override ( { broker_client_max_async_poll_duration_minutes : 8088 } )
245+ job . perform
246+ expect ( job . maximum_duration_seconds ) . to eq ( 8088 . minutes )
247+ end
248+
249+ context 'when the plan value changes between calls' do
250+ before do
251+ job . maximum_duration_seconds = 90009
252+ service_plan . update ( maximum_polling_duration : 5000 )
253+ job . perform
254+ end
255+
256+ it 'sets to the new plan value' do
257+ expect ( job . maximum_duration_seconds ) . to eq ( 5000 )
258+ end
259+ end
260+ end
261+
241262 it 'does not send any operation request to the broker' do
242263 job . perform
243264 expect ( job ) . to have_received ( :send_broker_request ) . once
You can’t perform that action at this time.
0 commit comments