Skip to content

Commit c1b44af

Browse files
committed
nxy
1 parent 31a3346 commit c1b44af

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

spec/filewatch/rotate_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,19 @@ module FileWatch
193193
let(:listener2) { observer.listener_for(second_file.to_path) }
194194
let(:actions) do
195195
RSpec::Sequencing
196-
.run_after(0.25, "create original - write line 1, 66 bytes") do
196+
.run_after(1.5, "create original - write line 1, 66 bytes") do
197197
file_path.open("wb") { |file| file.write("#{line1}\n") }
198198
end
199-
.then_after(0.25, "rename to 2.log") do
199+
.then_after(1.5, "rename to 2.log") do
200200
file_path.rename(second_file)
201201
file_path.open("wb") { |file| file.write("#{line2}\n") }
202202
end
203-
.then_after(0.25, "rename to 2.log again") do
203+
.then_after(1.5, "rename to 2.log again") do
204204
file_path.rename(second_file)
205205
file_path.open("wb") { |file| file.write("#{line3}\n") }
206206
end
207207
.then("wait for expectations to be met") do
208-
wait(0.5).for{listener1.lines.size == 3 && listener2.lines.empty?}.to eq(true)
208+
wait(1).for{listener1.lines.size == 3 && listener2.lines.empty?}.to eq(true)
209209
end
210210
.then("quit") do
211211
tailing.quit

spec/filewatch/tailing_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ module FileWatch
482482
tailing.watch_this(watch_dir)
483483
end
484484
.then("wait for lines") do
485-
wait(1.5).for{listener1.calls}.to eq([:open, :accept, :accept, :timed_out])
485+
wait(2.5).for{listener1.calls}.to eq([:open, :accept, :accept, :timed_out])
486486
end
487487
.then("quit") do
488488
tailing.quit

spec/inputs/file_read_spec.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,10 @@
284284
wait_for_start_processing(@run_thread)
285285
end
286286

287-
after { plugin.stop }
287+
after {
288+
plugin.stop
289+
@run_thread.join
290+
}
288291

289292
it 'processes a file' do
290293
wait_for_file_removal(sample_file) # watched discovery
@@ -330,7 +333,10 @@
330333
wait_for_start_processing(@run_thread)
331334
end
332335

333-
after { plugin.stop }
336+
after {
337+
plugin.stop
338+
@run_thread.join
339+
}
334340

335341
it 'cleans up sincedb entry' do
336342
wait_for_file_removal(sample_file) # watched discovery
@@ -350,7 +356,7 @@
350356

351357
private
352358

353-
def wait_for_start_processing(run_thread, timeout: 1.0)
359+
def wait_for_start_processing(run_thread, timeout: 10.0)
354360
begin
355361
Timeout.timeout(timeout) do
356362
# sleep(0.01) while run_thread.status != 'sleep'
@@ -363,7 +369,13 @@ def wait_for_start_processing(run_thread, timeout: 1.0)
363369
sleep(0.1)
364370
puts "no queue"
365371
end
366-
end
372+
puts "the queue size is #{plugin.queue.size}"
373+
# sleep(0.1) while !plugin.queue
374+
while plugin.queue.size == 0
375+
sleep(0.1)
376+
puts "no item on queue"
377+
end
378+
end
367379
rescue Timeout::Error => e
368380
puts "plugin timed out #{e}"
369381
raise "plugin did not start processing (timeout: #{timeout})" unless plugin.queue

0 commit comments

Comments
 (0)