Skip to content

Commit

Permalink
Add possible test case for deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
MattFenelon committed Mar 28, 2024
1 parent 2a462ee commit 464295e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions spec/scope_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,17 @@
it 'resolves sideloads concurrently with the threadpool' do
allow(sideload).to receive(:resolve).and_return(sideload)
expect(Concurrent::Promise).to receive(:execute).with(executor: an_instance_of(Concurrent::ThreadPoolExecutor)).and_call_original
instance.resolve_sideloads(results)
expect { instance.resolve_sideloads(results) }.not_to raise_error
end

context 'with more sideloads than the thread pool size' do
before { allow(Graphiti.config).to receive(:concurrency_max_threads).and_return(0) }

it 'deadlocks' do
expect { instance.resolve_sideloads(results) }.to raise_error do |e|
expect(e.message).to start_with('No live threads left. Deadlock?')
end
end
end
end

Expand All @@ -141,7 +151,7 @@
end
end
end

describe "cache_key" do
let(:employee1) {
time = Time.parse("2022-06-24 16:36:00.000000000 -0500")
Expand Down Expand Up @@ -186,7 +196,7 @@
expect(instance1.cache_key_with_version).not_to eq(instance2.cache_key)
end
end

describe '.global_thread_pool_executor' do
it 'memoizes the thread pool executor' do
one = described_class.global_thread_pool_executor
Expand Down

0 comments on commit 464295e

Please sign in to comment.