From d3ec0b31846d639a2c225a9460b018faeb6f1ea7 Mon Sep 17 00:00:00 2001 From: uu59 Date: Wed, 28 Jan 2015 17:51:07 +0900 Subject: [PATCH 1/6] Maybe fix unstable spec --- spec/models/fluentd/agent/local_common_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/models/fluentd/agent/local_common_spec.rb b/spec/models/fluentd/agent/local_common_spec.rb index 8b9db1c..cc10de6 100644 --- a/spec/models/fluentd/agent/local_common_spec.rb +++ b/spec/models/fluentd/agent/local_common_spec.rb @@ -47,6 +47,8 @@ describe 'Fluentd::Agent::LocalCommon' do CONF before do + # other specs could be write in this dir, so clean that in `before` + FileUtils.rm_r daemon.agent.config_backup_dir, force: true ::Settings.max_backup_files_count.times do |i| backpued_time = now - (i + 1).hours FileUtils.touch File.join(daemon.agent.config_backup_dir , "#{backpued_time.strftime('%Y%m%d_%H%M%S')}.conf") From 682d6dfa3ca84237c5eed354ec058594914c63db Mon Sep 17 00:00:00 2001 From: uu59 Date: Wed, 28 Jan 2015 18:04:19 +0900 Subject: [PATCH 2/6] Be data_dir under the tmp/ on test environment --- lib/fluentd-ui.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fluentd-ui.rb b/lib/fluentd-ui.rb index 2810851..c3772b5 100644 --- a/lib/fluentd-ui.rb +++ b/lib/fluentd-ui.rb @@ -21,7 +21,11 @@ module FluentdUI end def self.data_dir - dir = ENV["FLUENTD_UI_DATA_DIR"].presence || ENV["HOME"] + "/.fluentd-ui/core_data" + if Rails.env.test? + dir = Rails.root.join("tmp", "core_data").to_s + else + dir = ENV["FLUENTD_UI_DATA_DIR"].presence || ENV["HOME"] + "/.fluentd-ui/core_data" + end FileUtils.mkdir_p(dir) # ensure directory exists dir end From 3920f8196962510403272e24d73d531fffcb6f13 Mon Sep 17 00:00:00 2001 From: uu59 Date: Wed, 28 Jan 2015 18:06:00 +0900 Subject: [PATCH 3/6] Clean up temporary data_dir after all spec finished --- spec/spec_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c6dee40..6a6f088 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -61,4 +61,8 @@ RSpec.configure do |config| # rspec 2.99 config.infer_spec_type_from_file_location! + + config.after(:all) do + FileUtils.rm_rf FluentdUI.data_dir + end end From 67afddc32a3761b52c348c8edc55fba6d1ae7611 Mon Sep 17 00:00:00 2001 From: uu59 Date: Wed, 28 Jan 2015 18:10:38 +0900 Subject: [PATCH 4/6] Add debug info on Circle CI failed --- app/models/fluent_gem.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/fluent_gem.rb b/app/models/fluent_gem.rb index b48b5a5..09e6cb6 100644 --- a/app/models/fluent_gem.rb +++ b/app/models/fluent_gem.rb @@ -17,9 +17,9 @@ module FluentGem # but long living caching causes mismatch with actual status e.g. user install plugin from console (without fluentd-ui) # So our decision is that cache `gem list` in 3 seconds Rails.cache.fetch(LIST_CACHE_KEY, expires_in: 3.seconds) do - output = `#{gem} list` + output = `#{gem} list 2>&1` if $? && $?.exitstatus != 0 # NOTE: $? will be nil on CircleCI, so check $? at first - raise GemError, "failed command: `#{gem} list`" + raise GemError, "failed command: `#{gem} list` output: #{output}" end output.lines.to_a end From fa8ea89162581123cd31eb401749a2339d5e90d6 Mon Sep 17 00:00:00 2001 From: uu59 Date: Wed, 28 Jan 2015 18:30:11 +0900 Subject: [PATCH 5/6] Fix typo: all -> suite --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6a6f088..d315e94 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -62,7 +62,7 @@ RSpec.configure do |config| # rspec 2.99 config.infer_spec_type_from_file_location! - config.after(:all) do + config.after(:suite) do FileUtils.rm_rf FluentdUI.data_dir end end From 1eac4a464aefd3e52b0cf10d976aa3fada37b8cb Mon Sep 17 00:00:00 2001 From: uu59 Date: Wed, 4 Feb 2015 10:54:15 +0900 Subject: [PATCH 6/6] Workaround sometimes FluentGem.list fail --- app/models/fluent_gem.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/fluent_gem.rb b/app/models/fluent_gem.rb index 09e6cb6..8622962 100644 --- a/app/models/fluent_gem.rb +++ b/app/models/fluent_gem.rb @@ -17,8 +17,11 @@ module FluentGem # but long living caching causes mismatch with actual status e.g. user install plugin from console (without fluentd-ui) # So our decision is that cache `gem list` in 3 seconds Rails.cache.fetch(LIST_CACHE_KEY, expires_in: 3.seconds) do + last_status = $? output = `#{gem} list 2>&1` - if $? && $?.exitstatus != 0 # NOTE: $? will be nil on CircleCI, so check $? at first + # https://github.com/fluent/fluentd-ui/pull/149#issuecomment-71954588 + # Sometimes, $? wouldn't override with `#{gem} list` but I don't know why.. + if $? && last_status != $? && $?.exitstatus != 0 # NOTE: $? will be nil on CircleCI, so check $? at first raise GemError, "failed command: `#{gem} list` output: #{output}" end output.lines.to_a