2017-03-28 13:27:44 -04:00
|
|
|
RSpec.configure do |config|
|
|
|
|
config.before(:each, :repository) do
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
end
|
2017-05-17 12:17:15 -04:00
|
|
|
|
|
|
|
config.before(:all, :broken_storage) do
|
2018-03-14 09:42:49 -04:00
|
|
|
FileUtils.rm_rf Gitlab.config.repositories.storages.broken.legacy_disk_path
|
2017-05-17 12:17:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
config.before(:each, :broken_storage) do
|
|
|
|
allow(Gitlab::GitalyClient).to receive(:call) do
|
|
|
|
raise GRPC::Unavailable.new('Gitaly broken in this spec')
|
|
|
|
end
|
|
|
|
|
2017-11-13 10:52:07 -05:00
|
|
|
# Track the maximum number of failures
|
|
|
|
first_failure = Time.parse("2017-11-14 17:52:30")
|
|
|
|
last_failure = Time.parse("2017-11-14 18:54:37")
|
2018-02-02 13:39:55 -05:00
|
|
|
failure_count = Gitlab::CurrentSettings.circuitbreaker_failure_count_threshold + 1
|
2017-11-13 10:52:07 -05:00
|
|
|
cache_key = "#{Gitlab::Git::Storage::REDIS_KEY_PREFIX}broken:#{Gitlab::Environment.hostname}"
|
|
|
|
|
|
|
|
Gitlab::Git::Storage.redis.with do |redis|
|
|
|
|
redis.pipelined do
|
|
|
|
redis.zadd(Gitlab::Git::Storage::REDIS_KNOWN_KEYS, 0, cache_key)
|
|
|
|
redis.hset(cache_key, :first_failure, first_failure.to_i)
|
|
|
|
redis.hset(cache_key, :last_failure, last_failure.to_i)
|
|
|
|
redis.hset(cache_key, :failure_count, failure_count.to_i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
config.after(:each, :broken_storage) do
|
|
|
|
Gitlab::Git::Storage.redis.with(&:flushall)
|
2017-05-17 12:17:15 -04:00
|
|
|
end
|
2017-03-28 13:27:44 -04:00
|
|
|
end
|