summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-05-08 22:29:30 -0700
committerStan Hu <stanhu@gmail.com>2018-05-09 14:33:42 -0700
commit204af2e1019e661fddc451ad0cfb982453d4085b (patch)
tree3b6484d2eba16771b96a41f8f2e994678f278ecb /spec/spec_helper.rb
parent5b0e96d09a7b6309384ef4c300c56872adba0626 (diff)
downloadgitlab-ce-204af2e1019e661fddc451ad0cfb982453d4085b.tar.gz
Support resetting of Prometheus metrics between test runs
Adding the :prometheus tag to an rspec test will clear out memory-mapped files and reset the registry. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/39968
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b4fc596a751..d3de2331244 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -137,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