Skip to content

Commit c742206

Browse files
authored
Don't use threads to prevent 'isolation: :truncation' (#4781)
1 parent 11f090a commit c742206

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

spec/unit/lib/cloud_controller/diego/tasks_sync_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,30 @@ module Diego
4545
end
4646
end
4747

48-
context 'when a running CC task is missing from BBS', isolation: :truncation do
49-
# Can't use transactions for isolation because we're using multiple threads
48+
context 'when a running CC task is missing from BBS' do
5049
let!(:running_task) { TaskModel.make(:running, created_at: 1.minute.ago) }
5150
let!(:canceling_task) { TaskModel.make(:canceling, created_at: 1.minute.ago) }
5251
let!(:start_event_for_running_task) { AppUsageEvent.make(task_guid: running_task.guid, state: 'TASK_STARTED') }
5352
let!(:start_event_for_canceling_task) { AppUsageEvent.make(task_guid: canceling_task.guid, state: 'TASK_STARTED') }
5453
let(:bbs_tasks) { [] }
5554

55+
before do
56+
# Don't use threads in this spec as it would require the use of 'isolation: :truncation' which is slow
57+
class InlineWorkPool
58+
def submit(*args, &block)
59+
block.call(*args)
60+
end
61+
62+
def drain; end
63+
64+
def exceptions
65+
[]
66+
end
67+
end
68+
69+
allow(WorkPool).to receive(:new).and_return(InlineWorkPool.new)
70+
end
71+
5672
it 'marks the tasks as failed' do
5773
subject.sync
5874

0 commit comments

Comments
 (0)