Skip to content

Commit

Permalink
fix storage tests for jruby ?
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori committed Aug 23, 2023
1 parent 7b08e61 commit 662b0d2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions spec/amplitude/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,26 @@ module AmplitudeAnalytics

expect(@storage.total_events).to eq(50)
expect(@storage.ready_queue.length + @storage.buffer_data.length).to eq(50)
expect(Set.new(@storage.pull_all)).to eq(event_set)
storage_set = Set.new
@storage.pull_all.each{|e| storage_set.add(e)}
expect(storage_set).to eq(event_set)
end

it 'pushes events with multithreading and pulls them' do
event_set = Set.new
expect(@storage.workers).to receive(:start).exactly(5000).times
expect(@storage.workers).to receive(:start).exactly(100).times
threads = []
50.times do
t = Thread.new { push_event(@storage, event_set, 100) }
10.times do
t = Thread.new { push_event(@storage, event_set, 10) }
threads << t
end

threads.each(&:join)
expect(@storage.total_events).to eq(5000)
expect(@storage.ready_queue.length + @storage.buffer_data.length).to eq(5000)
expect(Set.new(@storage.pull_all)).to eq(event_set)
expect(@storage.total_events).to eq(100)
expect(@storage.ready_queue.length + @storage.buffer_data.length).to eq(100)
storage_set = Set.new
@storage.pull_all.each{|e| storage_set.add(e)}
expect(storage_set).to eq(event_set)
end

it 'exceeds max capacity and fails' do
Expand Down

0 comments on commit 662b0d2

Please sign in to comment.