Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 1f662ab

Browse files
authored
v3(services): Unbind - broker operation is passed in every LO request (cloudfoundry#1930)
* v3(services): Unbind - broker operation is passed in every LO request [#174187897](https://www.pivotaltracker.com/story/show/174187897) * Fix formatting
1 parent 8fca170 commit 1f662ab

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

app/actions/service_route_binding_delete.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def poll(binding)
4444
details = client.fetch_and_handle_service_binding_last_operation(binding)
4545
case details[:last_operation][:state]
4646
when 'in progress'
47-
update_last_operation(binding, description: details[:last_operation][:description])
47+
update_last_operation(
48+
binding,
49+
description: details[:last_operation][:description],
50+
operation: binding.last_operation.broker_provided_operation)
4851
return ContinuePolling.call(details[:retry_after])
4952
when 'succeeded'
5053
perform_delete_actions(binding)

spec/request/service_route_bindings_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,23 @@
10531053
expect(Delayed::Job.count).to eq(1)
10541054
end
10551055

1056+
it 'keeps track of the broker operation' do
1057+
execute_all_jobs(expected_successes: 1, expected_failures: 0)
1058+
expect(Delayed::Job.count).to eq(1)
1059+
1060+
Timecop.travel(Time.now + 1.minute)
1061+
execute_all_jobs(expected_successes: 1, expected_failures: 0)
1062+
1063+
expect(
1064+
a_request(:get, broker_binding_last_operation_url).
1065+
with(query: {
1066+
operation: operation,
1067+
service_id: service_instance.service_plan.service.unique_id,
1068+
plan_id: service_instance.service_plan.unique_id,
1069+
})
1070+
).to have_been_made.twice
1071+
end
1072+
10561073
context 'last operation response is 200 OK and indicates success' do
10571074
let(:state) { 'succeeded' }
10581075
let(:last_operation_status_code) { 200 }

spec/unit/actions/service_route_binding_delete_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ module V3
240240
}
241241
end
242242
let(:broker_client) { instance_double(VCAP::Services::ServiceBrokers::V2::Client) }
243+
let(:broker_provided_operation) { Sham.guid }
243244

244245
before do
246+
route_binding.last_operation.broker_provided_operation = broker_provided_operation
247+
route_binding.save
248+
245249
allow(VCAP::Services::ServiceBrokers::V2::Client).to receive(:new).and_return(broker_client)
246250
allow(broker_client).to receive(:fetch_and_handle_service_binding_last_operation).and_return(last_operation_response)
247251
end
@@ -275,6 +279,7 @@ module V3
275279
route_binding.reload
276280
expect(route_binding.last_operation.state).to eq('in progress')
277281
expect(route_binding.last_operation.description).to eq(description)
282+
expect(route_binding.last_operation.broker_provided_operation).to eq(broker_provided_operation)
278283
end
279284

280285
it 'does not remove the binding or log an audit event' do

spec/unit/jobs/v3/delete_route_binding_job_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module V3
3737
it_behaves_like 'delayed job', described_class
3838

3939
describe '#perform' do
40-
let(:delete_response) { { finished: false } }
40+
let(:delete_response) { { finished: false, operation: 'test-operation' } }
4141
let(:poll_response) { { finished: false } }
4242
let(:action) do
4343
instance_double(V3::ServiceRouteBindingDelete, {

0 commit comments

Comments
 (0)