From 46be2efde1c538bd43d1fa5339122b4c4041d294 Mon Sep 17 00:00:00 2001 From: Karol Bucek Date: Sun, 22 Mar 2020 16:45:55 +0100 Subject: [PATCH 1/5] Test: fix flaky test caused by LS bug identified and expected to be fixed in LS 7.6.2 ... for reference see elastic/logstash#11694 --- spec/inputs/file_tail_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/inputs/file_tail_spec.rb b/spec/inputs/file_tail_spec.rb index 367ce07..7aefc69 100644 --- a/spec/inputs/file_tail_spec.rb +++ b/spec/inputs/file_tail_spec.rb @@ -67,7 +67,7 @@ path => "#{path_path}" start_position => "beginning" sincedb_path => "#{sincedb_path}" - "file_sort_by" => "path" + file_sort_by => "path" delimiter => "#{TEST_FILE_DELIMITER}" } } @@ -176,7 +176,7 @@ context "when sincedb_path is a directory" do let(:name) { "E" } subject { LogStash::Inputs::File.new("path" => path_path, "sincedb_path" => directory) } - + after :each do FileUtils.rm_rf(sincedb_path) end From 3dbedbf5fe9507a62ccabeff77715672e05ff596 Mon Sep 17 00:00:00 2001 From: Karol Bucek Date: Sun, 22 Mar 2020 18:25:15 +0100 Subject: [PATCH 2/5] Test: wait longer (due CI being a bit slow) --- spec/inputs/file_read_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/inputs/file_read_spec.rb b/spec/inputs/file_read_spec.rb index 9b38dc6..298b5f2 100644 --- a/spec/inputs/file_read_spec.rb +++ b/spec/inputs/file_read_spec.rb @@ -70,7 +70,7 @@ end events = input(conf) do |pipeline, queue| - wait(0.5).for{IO.read(log_completed_path)}.to match(/A\.log/) + wait(0.75).for { IO.read(log_completed_path) }.to match(/A\.log/) 2.times.collect { queue.pop } end expect(events.map{|e| e.get("message")}).to contain_exactly("hello", "world") @@ -137,7 +137,7 @@ CONFIG events = input(conf) do |pipeline, queue| - wait(0.5).for{IO.read(log_completed_path)}.to match(/#{file_path.to_s}/) + wait(0.75).for { IO.read(log_completed_path) }.to match(/#{file_path.to_s}/) 2.times.collect { queue.pop } end @@ -171,7 +171,7 @@ CONFIG events = input(conf) do |pipeline, queue| - wait(0.5).for{IO.read(log_completed_path)}.to match(/uncompressed\.log/) + wait(0.75).for{ IO.read(log_completed_path) }.to match(/uncompressed\.log/) 2.times.collect { queue.pop } end @@ -205,7 +205,7 @@ CONFIG events = input(conf) do |pipeline, queue| - wait(0.5).for{IO.read(log_completed_path).scan(/compressed\.log\.gz(ip)?/).size}.to eq(2) + wait(0.75).for { IO.read(log_completed_path).scan(/compressed\.log\.gz(ip)?/).size }.to eq(2) 4.times.collect { queue.pop } end From 12a1275332f24ecd8d70a1e3c5965046bb8bb5bb Mon Sep 17 00:00:00 2001 From: Karol Bucek Date: Sun, 22 Mar 2020 18:38:40 +0100 Subject: [PATCH 3/5] Refactor: actually require rspec/wait --- spec/filewatch/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/filewatch/spec_helper.rb b/spec/filewatch/spec_helper.rb index 0490536..f2d32d7 100644 --- a/spec/filewatch/spec_helper.rb +++ b/spec/filewatch/spec_helper.rb @@ -1,6 +1,6 @@ # encoding: utf-8 require "rspec_sequencing" -# require 'rspec/wait' +require 'rspec/wait' require "logstash/devutils/rspec/spec_helper" require "concurrent" require "timecop" From 1f00eb456f5db40054d4cbd73016added0822416 Mon Sep 17 00:00:00 2001 From: Karol Bucek Date: Sun, 22 Mar 2020 18:42:36 +0100 Subject: [PATCH 4/5] Test: sleep a bit to avoid delete to happen --- spec/filewatch/rotate_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/filewatch/rotate_spec.rb b/spec/filewatch/rotate_spec.rb index cf85704..f4e5979 100644 --- a/spec/filewatch/rotate_spec.rb +++ b/spec/filewatch/rotate_spec.rb @@ -73,7 +73,8 @@ module FileWatch FileUtils.mv(directory.join("1.logtmp").to_path, file1_path) end .then("wait for expectation") do - wait(2).for{listener1.calls}.to eq([:open, :accept, :accept, :accept]) + sleep(0.25) # if ENV['CI'] + wait(2).for { listener1.calls }.to eq([:open, :accept, :accept, :accept]) end .then("quit") do tailing.quit From 978b7688e796b4e6076b9454dc842b0ebb7e2c7f Mon Sep 17 00:00:00 2001 From: Karol Bucek Date: Sun, 22 Mar 2020 18:49:39 +0100 Subject: [PATCH 5/5] Chore: let's not leave gradle daemon around --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index e1595e1..ca92ecf 100644 --- a/Rakefile +++ b/Rakefile @@ -8,6 +8,6 @@ require "logstash/devutils/rake" desc "Compile and put filewatch jar into lib/jars" task :vendor do - exit(1) unless system './gradlew clean jar' + exit(1) unless system './gradlew --no-daemon clean jar' puts "-------------------> built filewatch jar via rake" end