Merge pull request #149 from fluent/fix_unstable_spec_on_circle_ci

Fix unstable spec on circle ci
This commit is contained in:
uu59 2015-02-04 11:03:18 +09:00
commit fea5561c43
4 changed files with 17 additions and 4 deletions

View File

@ -17,9 +17,12 @@ 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`
if $? && $?.exitstatus != 0 # NOTE: $? will be nil on CircleCI, so check $? at first
raise GemError, "failed command: `#{gem} list`"
last_status = $?
output = `#{gem} list 2>&1`
# 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
end

View File

@ -21,7 +21,11 @@ module FluentdUI
end
def self.data_dir
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

View File

@ -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|
backuped_time = now - (i + 1).hours
FileUtils.touch File.join(daemon.agent.config_backup_dir , "#{backuped_time.strftime('%Y%m%d_%H%M%S')}.conf")

View File

@ -61,4 +61,8 @@ RSpec.configure do |config|
# rspec 2.99
config.infer_spec_type_from_file_location!
config.after(:suite) do
FileUtils.rm_rf FluentdUI.data_dir
end
end