diff options
Diffstat (limited to 'spec/spec_helper.rb')
| -rw-r--r-- | spec/spec_helper.rb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cc61cd7d838..d3de2331244 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -86,6 +86,7 @@ RSpec.configure do |config| config.include WaitForRequests, :js config.include LiveDebugger, :js config.include MigrationsHelpers, :migration + config.include RedisHelpers if ENV['CI'] # This includes the first try, i.e. tests will be run 4 times before failing. @@ -136,6 +137,13 @@ RSpec.configure do |config| reset_delivered_emails! end + config.before(:example, :prometheus) do + matching_files = File.join(::Prometheus::Client.configuration.multiprocess_files_dir, "*.db") + Dir[matching_files].map { |filename| File.delete(filename) if File.file?(filename) } + + Gitlab::Metrics.reset_registry! + end + config.around(:each, :use_clean_rails_memory_store_caching) do |example| caching_store = Rails.cache Rails.cache = ActiveSupport::Cache::MemoryStore.new @@ -146,21 +154,27 @@ RSpec.configure do |config| end config.around(:each, :clean_gitlab_redis_cache) do |example| - Gitlab::Redis::Cache.with(&:flushall) + redis_cache_cleanup! example.run - Gitlab::Redis::Cache.with(&:flushall) + redis_cache_cleanup! end config.around(:each, :clean_gitlab_redis_shared_state) do |example| - Gitlab::Redis::SharedState.with(&:flushall) - Sidekiq.redis(&:flushall) + redis_shared_state_cleanup! + + example.run + + redis_shared_state_cleanup! + end + + config.around(:each, :clean_gitlab_redis_queues) do |example| + redis_queues_cleanup! example.run - Gitlab::Redis::SharedState.with(&:flushall) - Sidekiq.redis(&:flushall) + redis_queues_cleanup! end # The :each scope runs "inside" the example, so this hook ensures the DB is in the |
