-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy paththreads_use_cases_spec.rb
More file actions
52 lines (41 loc) · 1.55 KB
/
threads_use_cases_spec.rb
File metadata and controls
52 lines (41 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true
RSpec.describe 'Session' do
describe 'thread interrupted after acquiring connection' do
context 'with thread#raise' do
it 'releases connection back into pool' do
driver = Neo4j::Driver::GraphDatabase.driver(uri, basic_auth_token)
session = driver.session
session.read_transaction {}
channel_pool = DriverInternalDataAccessor.channel_pool_from_session(session)
expect(channel_pool.busy?).to be false
thr = Thread.new do
thr_session = driver.session
thr_session.read_transaction { |_tx| sleep(60) }
end
wait_till { channel_pool.busy? }
expect(channel_pool.busy?).to be true
thr.raise("Bhadako!")
wait_till { !channel_pool.busy? }
expect(channel_pool.busy?).to be false
end
end
context 'with thread#kill' do
it 'releases connection back into pool' do
driver = Neo4j::Driver::GraphDatabase.driver(uri, basic_auth_token)
session = driver.session
session.read_transaction {}
channel_pool = DriverInternalDataAccessor.channel_pool_from_session(session)
expect(channel_pool.busy?).to be false
thr = Thread.new do
thr_session = driver.session
thr_session.read_transaction { |_tx| sleep(60) }
end
wait_till { channel_pool.busy? }
expect(channel_pool.busy?).to be true
thr.kill
wait_till { !channel_pool.busy? }
expect(channel_pool.busy?).to be false
end
end
end
end